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