2014年3月16日 星期日

chroot: failed to run command : No such file or directory

   If you use chroot and it said "chroot: failed to run command  : No such file or directory",  how to slove it? Ok, follow me.


   For example, if you type "chroot /tmp/root /bin/bash" and get error. First of all, check whether the file "/tmp/root/bin/bash" exists. If not, create it.

   But if the file exists and got "No such file or directory", use "file /tmp/root /bin/bash" to check the file. If the file is "statically linked", I don't know what happen to your system. If the file is "dynamically linked (uses shared libs)", you have two way to go. The one is that you can compile the file to "statically linked". The another is that copy the shared libs which your program use to the right path(here is /tmp/root/lib).
 
    You can use "ldd to find out all shared libs your prcess use. The output is like below.

    linux-vdso.so.1 =>  (0x00007fff747fe000)
libtinfo.so.5 => /lib/x86_64-linux-gnu/libtinfo.so.5 (0x00007fd6544bc000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fd6542b8000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fd653eef000)
/lib64/ld-linux-x86-64.so.2 (0x00007fd6546ff000)

沒有留言:

張貼留言