Gentoo Archives: gentoo-amd64

From: "Boyd Stephen Smith Jr." <bss03@××××××××××.net>
To: gentoo-amd64@l.g.o
Subject: Re: [gentoo-amd64] chroot can't find /bin/bash
Date: Wed, 07 Feb 2007 10:18:23
Message-Id: 200702070415.01420.bss03@volumehost.net
In Reply to: [gentoo-amd64] chroot can't find /bin/bash by Daiajo Tibdixious
1 On Tuesday 06 February 2007 21:03, Daiajo Tibdixious wrote:
2 > transcode is giving me a segmentation fault, which I reported as a bug.
3 > They now want a backtrace & I've roughly followed
4 > http://www.gentoo.org/proj/en/qa/backtraces.xml
5 > I used ebuild directly, ending at the install phase, as I don't want
6 > to overwrite the live transcode.
7 >
8 > I then built a /mnt/debug chroot using roughly
9 > http://www.gentoo.org/proj/en/base/amd64/howtos/index.xml?part=1&chap=2
10 > (32bit chroot guild for AMD64) with the following binds:
11 > mount -o bind /bin /mnt/debug/bin
12 > mount -o bind /etc /mnt/debug/etc
13 > mount -o bind /dev /mnt/debug/dev
14 > mount -o bind /proc /mnt/debug/proc
15 > mount -o bind /sys /mnt/debug/sys
16 > mount -o bind /tmp /mnt/debug/tmp
17 > mount -o bind /home/daiajo /mnt/debug/home/daiajo
18 > and moved the /var/tmp/portage/transcode-*/image dirs into /mnt/debug
19 > (just usr in this case)
20 > The problem comes when trying to chroot into it:
21 > # ls /bin/bash
22 > /bin/bash
23 > # ls /mnt/debug/bin/bash
24 > /mnt/debug/bin/bash
25 > # chroot /mnt/debug /bin/bash
26 > chroot: cannot run command `/bin/bash': No such file or directory
27
28 Okay, this error message is just misleading. I've seen it before when
29 chrooting, and it can also happen after your screw up your glibc/libstdc++
30 install. (Done both a number of times.)
31
32 The problem is that one of the libraries that /bin/bash dynamically links
33 to
34 cannot be found inside the chroot. I suggest that you add /lib, and
35 possibly /usr/lib to your list of bind mounts. That, or copy the libraries
36 into the chroot.
37
38 The reason you get such a lame error message probably best described as a
39 historical oddity, but others might describe it as anything from the
40 inherent
41 suck of C and UNIX to a poor example of excellent design under resource
42 constraints that no longer exist. A fairly detailed, but hopefully
43 understandable, description of what is happening follows:
44
45 The chroot binary uses the chroot and exec C-library functions to do it's
46 job.
47 As library functions, they don't write out error messages and exit the
48 program directly. (The program calling them might write the messages
49 somewhere other than stderr or discard them entirely. Also, it may be able
50 to recover.) Instead they either return an error *code* directly, or place
51 it in a well-known location that the caller should check. These error
52 codes
53 can be mapped to generic messages, but may not completely specify the
54 error;
55 in this case, exec (actually, probably even deeper in the bowels of glibc)
56 tried to open a library and couldn't find it [probably looked in 1/2 dozen
57 places for it, too :(] and returned the generic "File Not Found" error
58 code.
59 The chroot binary knows how it was called ("chroot"), what it was trying to
60 do (execute "/bin/bash"), and the error code. It crams these bits of
61 information together to try and give a human-readable error, but computers
62 are stupid and it comes up with the misleading, "chroot: cannot run command
63 `/bin/bash': No such file or directory", despite the fact that clearly
64 exists
65 in the chroot.
66
67 > Is there a better way to run a debug transcode without messing with
68 > the live system?
69
70 Not really, although the splitdebug FEATURE can give you a lot of the
71 advantages of a full debug build without the runtime memory overhead.
72
73 --
74 Boyd Stephen Smith Jr. ,= ,-_-. =.
75 bss03@××××××××××.net ((_/)o o(\_))
76 ICQ: 514984 YM/AIM: DaTwinkDaddy `-'(. .)`-'
77 http://iguanasuicide.org/ \_/
78 New GPG Key! Old key expires 2007-03-25. Upgrade NOW!

Replies

Subject Author
Re: [gentoo-amd64] chroot can't find /bin/bash Naga <nagatoro@×××××.com>
Re: [gentoo-amd64] chroot can't find /bin/bash Daiajo Tibdixious <daiajo@×××××.com>
Re: [gentoo-amd64] chroot can't find /bin/bash "Marek Wróbel" <smbmarek@×××××××××××.pl>