Ubuntu: '/bin/bash': no such file or Directory



Question:

I have been following these instruction on how to create a live CD of my current ubuntu 14.04 installation. When i try to runsudo chroot ${WORK}/rootfs /bin/bash where WORK=/some/dir/that/REALLY/exist

I get an error that bin/bash is not file or directory. I can ls /bin and i see a file called bash, but cant open it, telling me that it is not a text file(makes sense).

none@none-ubuntu:/$ sudo chroot ${WORK}/rootfs /bin/bash  chroot: failed to run command ‘/bin/bash’: No such file or directory  

bash file is there since i can see it on ls

none@none-ubuntu:/$ ls /bin  bash                  fgconsole   nc                       sed  bunzip2               fgrep       nc.openbsd               setfacl  ...(lot more files here)......  

and since i was asked about the permissions

none@none-ubuntu:/$ ls -l /bin  total 9880  -rwxr-xr-x 1 root root 1017016 Î'πρ  24  2014 bash  -rwxr-xr-x 1 root root   31152 Οκτ  21  2013 bunzip2  -rwxr-xr-x 1 root root 1918032 Νοέ  14  2013 busybox  

I have been looking around the web, but unfortunately using "no such file or directory" comes up with a lot of unrelated posts

edit:

none@none-ubuntu:/$ ls -l ${WORK}/rootfs/bin  total 9866  -rwxrwx--- 1 root vboxsf 1017016 Î'πρ  24  2014 bash  -rwxrwx--- 1 root vboxsf   31152 Οκτ  21  2013 bunzip2       none@none-ubuntu:/$ ldd ${WORK}/rootfs/bin/bash   linux-vdso.so.1 =>  (0x00007fff183fe000)   libtinfo.so.5 => /lib/x86_64-linux-gnu/libtinfo.so.5 (0x00007f4569d8e000)   libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f4569b8a000)   libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f45697c4000)   /lib64/ld-linux-x86-64.so.2 (0x00007f4569fce000)    none@none-ubuntu:/$ ls -l ${WORK}/rootfs/lib  total 304  drwxrwx--- 1 root vboxsf     0 Ιούλ 23  2014 apparmor  drwxrwx--- 1 root vboxsf  8192 Ιούλ 23  2014 brltty  drwxrwx--- 1 root vboxsf     0 Ιούλ 23  2014 crda  drwxrwx--- 1 root vboxsf 36864 Ιούλ 23  2014 firmware  drwxrwx--- 1 root vboxsf     0 Ιούλ 23  2014 hdparm  drwxrwx--- 1 root vboxsf     0 Ιούλ 23  2014 ifupdown  drwxrwx--- 1 root vboxsf  4096 Ιούλ 23  2014 init  -rwxrwx--- 1 root vboxsf 71512 Î"εκ  24  2013 klibc-P2s_k-gf23VtrGgO2_4pGkQgwMY.so  -rwxrwx--- 1 root vboxsf 27392 Ιαν   9  2014 libip4tc.so.0.1.0  -rwxrwx--- 1 root vboxsf 31520 Ιαν   9  2014 libip6tc.so.0.1.0  -rwxrwx--- 1 root vboxsf  5816 Ιαν   9  2014 libiptc.so.0.0.0  -rwxrwx--- 1 root vboxsf 47712 Ιαν   9  2014 libxtables.so.10.0.0  drwxrwx--- 1 root vboxsf     0 Ιούλ 23  2014 linux-sound-base  drwxrwx--- 1 root vboxsf     0 Ιούλ 23  2014 lsb  drwxrwx--- 1 root vboxsf     0 Î'πρ  10  2014 modprobe.d  drwxrwx--- 1 root vboxsf     0 Ιούλ 23  2014 modules  drwxrwx--- 1 root vboxsf     0 Ιούλ 23  2014 modules-load.d  drwxrwx--- 1 root vboxsf     0 Ιούλ 23  2014 plymouth  drwxrwx--- 1 root vboxsf     0 Ιούλ 23  2014 recovery-mode  drwxrwx--- 1 root vboxsf     0 Ιούλ 23  2014 resolvconf  drwxrwx--- 1 root vboxsf  4096 Ιούλ 23  2014 systemd  drwxrwx--- 1 root vboxsf  4096 Μάρ  22  2014 terminfo  drwxrwx--- 1 root vboxsf  4096 Ιούν  2 13:10 udev  drwxrwx--- 1 root vboxsf  4096 Ιούλ 23  2014 ufw  drwxrwx--- 1 root vboxsf 28672 Ιούν  7 22:08 x86_64-linux-gnu  drwxrwx--- 1 root vboxsf 24576 Ιούλ 23  2014 xtables  

Update

Thank you all for the help and information provided. Unfortunately i could complete this task. It seems that the solution must have been the creation of a Virtual drive(as suggested by Germar). Did that and did the whole process from the beginning. but when i had to apt-get while chroot, i was getting errors saying that it cant connect to the ppa site. while trying to fix that with some things found on the internet, the VM stoped working and now doesnt boot at all! I guess that the best way to create a live cd from an installation of ubuntu on the hard drive is to actually have ubuntu on the hard drive and not on some VM.

Thanks again(not sure if i should delete this or not, but i will keep it for future reference)


Solution:1

errno codes sometimes aren't very specific. As well as possibly meaning that the specific file at hand (/bin/bash) doesn't exist, when executing a program "No such file or directory" (ENOENT) can also mean that its ELF interpreter doesn't exist, or that one of the shared libraries it needs doesn't exist. I suspect that /lib or /lib64 inside the chroot environment you're building is broken somehow, perhaps because symlinks are pointing to the wrong places.

Try ls -l $WORK/lib64/ld-linux-x86-64.so.2, and if it reports a symlink then try likewise for whatever the target of that symlink is except relative to $WORK (so if ls says that the link points to /lib/x86_64-linux-gnu/ld-2.19.so, then you'd run ls -l $WORK/lib/x86_64-linux-gnu/ld-2.19.so). Repeat for the various library paths under /lib listed in the output of ldd until you find the thing that's actually missing in the context of the chroot.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »