Gentoo Archives: gentoo-user

From: Alan McKinnon <alan.mckinnon@×××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] chroot complain not able to find file/directory when it's actually there
Date: Sun, 04 Jan 2009 07:59:11
Message-Id: 200901040958.28543.alan.mckinnon@gmail.com
In Reply to: [gentoo-user] chroot complain not able to find file/directory when it's actually there by Zhang Weiwu
1 On Sunday 04 January 2009 06:41:31 Zhang Weiwu wrote:
2 > Hello. Sorry for stupid newbie question:
3 >
4 > # cp /bin/sh /usr/local/bin/sh
5 > # chroot /usr/local /bin/sh
6 > chroot: cannot run command `/bin/sh': No such file or directory
7 >
8 > In theory it should work, right? This is the first time I run chroot not
9 > for rescuing a broken system (which means /dev/ and /proc/ are not
10 > mounted in chroot jail). However I guess /dev/ and /proc/ doesn't have
11 > to be mounted to run chroot.
12 >
13 > I am sure this is not because the executable is dynamically linked to a
14 > file outside of the chroot jail, because I also tried to run executables
15 > compiled with USE=static
16 >
17 > What could be the reason (for complaining an existing file "No such file")?
18 >
19 > Thanks in advance. Using coreutils-6.10-r2 on ibook/ppc
20
21 Do this:
22
23 alan@nazgul ~ $ ls -al /bin/sh
24 lrwxrwxrwx 1 root root 4 Nov 24 09:58 /bin/sh -> bash
25
26 sh is a symlink to bash. You do not have bash inside your chroot, and that is
27 the file that is not being found. You must also run ldd on bash, see all the
28 libs it links to and copy those as well into the chroot
29
30 --
31 alan dot mckinnon at gmail dot com