Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm a chroot novice trying to make a simple chroot jail but am banging my head against the same problem time and time again... Any help would be massively appreciated

I've created a directory /usr/chroot that I want to use as a jail and created subdirectories under it and copied the dependencies of /bin/bash into it:

[root@WIG001-001 ~]# cd /usr/chroot/
[root@WIG001-001 chroot]# ls
[root@WIG001-001 chroot]# mkdir bin etc lib var home

[root@WIG001-001 chroot]# ldd /bin/bash =>  (0x00007fff99dba000) => /lib64/ (0x00000037a2000000) => /lib64/ (0x000000379fc00000) => /lib64/ (0x000000379f800000)        
/lib64/ (0x000000379f400000)

[root@WIG001-001 chroot]# cp /lib64/ /usr/chroot/lib/  
[root@WIG001-001 chroot]# cp /lib64/ /udr/csr/chroot/lib/  
[root@WIG001-001 chroot]# cp /lib64/ /usr/chroot/lib/  
[root@WIG001-001 chroot]# cp /lib64/ /usr/chroot/lib/  
[root@WIG001-001 chroot]# cp /bin/bash bin  
[root@WIG001-001 chroot]# pwd  
[root@WIG001-001 chroot]# /usr/sbin/chroot .  
/usr/sbin/chroot: cannot run command `/bin/bash': No such file or directory  

it looks like the /bin/bash created under /usr/chroot is fine as the below works:  
[root@WIG001-001 chroot]# su - nobody -s /usr/chroot/bin/bash  

Can anyone give me any idea where to go from here?

share|improve this question
Is this a typo in the question or an error in the steps you performed? cp /lib64/ /udr/csr/chroot/lib/ (should be /usr instead of /udr) – Dennis Williamson Jul 20 '10 at 21:22
That's an artefact from using Putty to log the telnet session, sorry. As you suggest, the actual command entered was cp /lib64/ /usr/chroot/lib/ – Mike Atkinson Jul 20 '10 at 21:45
up vote 24 down vote accepted

The error message is misleading: /bin/bash: No such file or directory can mean either that /bin/bash doesn't exist, or that the dynamic loader used by /bin/bash doesn't exist. (You'll also get this message for a script if the interpreter on the #! line doesn't exist.)

/bin/bash is looking for /lib64/ but you provided /lib/ Make /usr/chroot/lib64 a symbolic to lib or vice versa.

share|improve this answer
Sorry, I really appreciate the help & I'm sure you're right, but I'm still confused! I'm not sure where you see /bin/bash is being provided with /lib/ & I'm further confused as /usr/chroot/lib64 doesn't exist. Would it be too cheeky to ask for a list of commands? I understand sym links & how to create them, but am really confused by what's happening here and what you're suggesting to correct it. Thanks very much for your help! – Mike Atkinson Jul 20 '10 at 21:05
@Mike: Look at your cp commands: you copied files from /lib64 in the base system into /lib in the chroot. But the bash binary is still looking for in /lib64 (which you haven't created), not /lib. You'll save yourself headaches by making /lib and /lib64 equivalent in the chroot, so run ln -s lib /usr/chroot/lib64. As for why the error message is about bash and not about, see my first paragraph. – Gilles Jul 20 '10 at 22:16
That works perfectly, thank you so much for taking the time, it's massively appreciated! – Mike Atkinson Jul 21 '10 at 6:51
Great answer. In my case the problem was caused by rsync without the preserve links flag – gtsouk Oct 14 '14 at 18:03
Note this can also happen if you are using a different architecture via qemu and have files of the wrong architecture, or install the wrong version of qemu into the chroot. – Tully Mar 16 at 6:45

Just do this: mv /usr/chroot/lib /usr/chroot/lib64

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.