Chroot Usage

chroot means change root,you can constarins a user's filestem view,from the perspective,the user consider the NEWROOT(a paramter of chroot) as its base root directory.


A simple use case for you(Ubuntu 12.01 64 bit Desktop)

first,mkdir for all directory,like bin,etc,lib and so on

mkdir ~/newroot
cd ~/newroot
mkdir bin etc lib var home lib64

because my os version is 64bit version,so i should create lib64.some library will use it

then we should copy /bin/bash to ~/newroot/bin directory.

bash need some dependency lib,how to get the dependency lib of bash

ldd will be a good choice.eg.

laicb@laicb-OptiPlex-3010:~$ ldd /bin/bash
	linux-vdso.so.1 =>  (0x00007fff5d5d3000)
	libtinfo.so.5 => /lib/x86_64-linux-gnu/libtinfo.so.5 (0x00007fa707207000)
	libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fa707003000)

/lib64/ld-linux-x86-64.so.2


 
so the bash depend on  /lib/x86_64-linux-gnu/libtinfo.so.5,/lib/x86_64-linux-gnu/libdl.so.2,/lib/x86_64-linux-gnu/libc.so.6, /lib64/ld-linux-x86-64.so.2 

next, we copy this library to ~/newroot/lib or lib64,and copy /bin/bash to ~/newroot/bin ,now Everything is already ready.

execue chroot commadn

chroot ~/newroot/ then we could see a new bash has been created.


you can try to input some command,but it say can't find command.yes ,in this environment,we just have a command bash,we can operator like bash,copy exectuteable program,dependency library.

then we can execute command as we want.

a simple use case,next i will utilize debootstrap to install a system then chroot to this directory.

reference: http://www.antionline.com/showthread.php?156511-CHROOT-Tutorial

Sina Weibo:ChampionLai

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值