Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
unable to chroot into gentoo root
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Installing Gentoo
View previous topic :: View next topic  
Author Message
Adel Ahmed
Veteran
Veteran


Joined: 21 Sep 2012
Posts: 1158

PostPosted: Sun Dec 11, 2016 5:56 am    Post subject: unable to chroot into gentoo root Reply with quote

I'm working on a new gentoo installation that aims to be as minimal as possible, up to this point I have emerged bash and baselayout into the new root
when I chroot into the directory I get the following:
g50-80 build-tiny # chroot .
chroot: failed to run command ���/bin/bash���: No such file or directory

wierd that strace gives an ENOENT for /bin/bash:
execve("/bin/bash", ["/bin/bash", "-i"], [/* 36 vars */]) = -1 ENOENT (No such file or directory)

g50-80 build-tiny # ls -lh bin/bash
-rwxr-xr-x 1 root root 693K Dec 11 07:54 bin/bash

3
open("/usr/lib64/charset.alias", O_RDONLY|O_NOFOLLOW) = -1 ENOENT (No such file or directory)
write(2, "chroot: ", 8chroot: ) = 8
write(2, "failed to run command \342\200\230/bin/ba"..., 37failed to run command ���/bin/bash���) = 37
open("/usr/share/locale/locale.alias", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en_US.utf8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en_US/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en.utf8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
write(2, ": No such file or directory", 27: No such file or directory) = 27
Back to top
View user's profile Send private message
Adel Ahmed
Veteran
Veteran


Joined: 21 Sep 2012
Posts: 1158

PostPosted: Tue Dec 13, 2016 2:57 am    Post subject: Reply with quote

bump
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 43198
Location: 56N 3W

PostPosted: Tue Dec 13, 2016 2:11 pm    Post subject: Reply with quote

Adel Ahmed,

What does lddtree say about bash?

Code:
 $ lddtree /bin/bash
/bin/bash (interpreter => /lib64/ld-linux-x86-64.so.2)
    libreadline.so.7 => /lib64/libreadline.so.7
        libncurses.so.6 => /lib64/libncurses.so.6
            libdl.so.2 => /lib64/libdl.so.2
    libc.so.6 => /lib64/libc.so.6

If your chroot bash is dynamically linked, it needs all those things too. I'm /no-multilib/ here. You may get a different answer.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
Adel Ahmed
Veteran
Veteran


Joined: 21 Sep 2012
Posts: 1158

PostPosted: Tue Dec 13, 2016 7:05 pm    Post subject: Reply with quote

g50-80 extracted # lddtree /bin/bash
bash => /bin/bash (interpreter => /lib64/ld-linux-x86-64.so.2)
libreadline.so.6 => /lib64/libreadline.so.6
libncurses.so.5 => /lib64/libncurses.so.5
libc.so.6 => /lib64/libc.so.6
ld-linux-x86-64.so.2 => /lib64/ld-linux-x86-64.so.2
Back to top
View user's profile Send private message
krinn
Watchman
Watchman


Joined: 02 May 2003
Posts: 7071

PostPosted: Tue Dec 13, 2016 7:06 pm    Post subject: Reply with quote

the first argument is the new root, the 2nd one is the program to run relative to that new root path.
so if you chroot . /bin/bash and there is no /bin/bash in . you'll fail.

are you sure ./bin/bash exist and that you don't mistake it should chroot to "." while using your /bin/bash from outside your chroot?

edit: from your answer i think you mistake it like i said
else the correct answer would have been : # lddtree g50-80 extracted/bin/bash and not lddtree /bin/bash like you did
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 13848

PostPosted: Wed Dec 14, 2016 2:16 am    Post subject: Reply with quote

OP: please use [code] tags when posting formatted output, such as lddtree. It makes it easier for others to read.
Back to top
View user's profile Send private message
Adel Ahmed
Veteran
Veteran


Joined: 21 Sep 2012
Posts: 1158

PostPosted: Wed Dec 14, 2016 4:07 pm    Post subject: Reply with quote

my bad, here's lddtree on the correct binary:
g50-80 build-tiny # lddtree bin/bash
Code:
bash => bin/bash (interpreter => /lib64/ld-linux-x86-64.so.2)
    libreadline.so.6 => /lib64/libreadline.so.6
    libncurses.so.5 => /lib64/libncurses.so.5
    libc.so.6 => /lib64/libc.so.6
        ld-linux-x86-64.so.2 => /lib64/ld-linux-x86-64.so.2
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 43198
Location: 56N 3W

PostPosted: Wed Dec 14, 2016 4:42 pm    Post subject: Reply with quote

Adel Ahmed,

Do you have all the dependencies that bash needs installed in the chroot?
The chroot is performed before bash is started, so /lib64/ and its contents are with respect to your chroot.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
Adel Ahmed
Veteran
Veteran


Joined: 21 Sep 2012
Posts: 1158

PostPosted: Thu Dec 15, 2016 3:43 pm    Post subject: Reply with quote

I would guess that's my problem, how can I tell which dependencies are missing, all the files listed by ldd are present inside the chroot!!
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 43198
Location: 56N 3W

PostPosted: Thu Dec 15, 2016 10:52 pm    Post subject: Reply with quote

Adel Ahmed,

Check all the file modes, ownership and group.

Te run bash, you only need the things that lddtree shows.
There is a small gotcha. Some of those things are symbolic links.
Code:
bash => bin/bash (interpreter => /lib64/ld-linux-x86-64.so.2)


So ..
Code:
 ls -l /lib64/ld-linux-x86-64.so.2
lrwxrwxrwx 1 root root 10 Apr  9  2016 /lib64/ld-linux-x86-64.so.2 -> ld-2.22.so

you need the symbolic link(s) and its target.

All the symbolic links must resolve correctly inside the chroot.
Be very careful of symbolic links that start with a /.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
Adel Ahmed
Veteran
Veteran


Joined: 21 Sep 2012
Posts: 1158

PostPosted: Wed Dec 21, 2016 10:28 am    Post subject: Reply with quote

all the symlinks are pointing to the correct file, the only missing file is:
linux-vdso.so.1

and I do not know which package provides that file
Back to top
View user's profile Send private message
fedeliallalinea
Bodhisattva
Bodhisattva


Joined: 08 Mar 2003
Posts: 21782
Location: here

PostPosted: Wed Dec 21, 2016 10:41 am    Post subject: Reply with quote

Adel Ahmed wrote:
all the symlinks are pointing to the correct file, the only missing file is:
linux-vdso.so.1

and I do not know which package provides that file

It's not missing, read here and here
_________________
Questions are guaranteed in life; Answers aren't.
Back to top
View user's profile Send private message
Adel Ahmed
Veteran
Veteran


Joined: 21 Sep 2012
Posts: 1158

PostPosted: Fri Dec 23, 2016 12:16 pm    Post subject: Reply with quote

that is good to know, thanks
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Installing Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum