LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   chroot: failed to run command '/tools/bin/env': Too many levels of symbolic links (https://www.linuxquestions.org/questions/linux-newbie-8/chroot-failed-to-run-command-tools-bin-env-too-many-levels-of-symbolic-links-4175607593/)

sks150693 06-09-2017 02:04 AM

chroot: failed to run command '/tools/bin/env': Too many levels of symbolic links
 
I am trying to build OS with the help of LFS-8.0,i Have completed till chapter-5 but in 6 i am getting error from 48hr. i tried my best solve it.even still i doing to fix it.But i want to take your experience and guidance.

Error:
root@administrator-Lenovo-U410:/mnt/lfs# chroot "$LFS" /tools/bin/env -i HOME=/root TERM="$TERM" PS1='\u:\w\$ ' PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin /tools/bin/bash --login +h
chroot: failed to run command '/tools/bin/env': Too many levels of symbolic links




while my configuration is :
root@administrator-Lenovo-U410:/mnt/lfs# /tools/bin/env
XDG_VTNR=7
XDG_SESSION_ID=c2
SHELL=/bin/bash
TERM=xterm
LC_ALL=POSIX
USER=root
SUDO_USER=sumitkumars
SUDO_UID=1001
LFS=/mnt/lfs
USERNAME=root
PATH=/tools/bin:/bin:/usr/bin
MAIL=/var/mail/root
PWD=/mnt/lfs
LANG=en_IN
LFS_TGT=x86_64-root-linux-gnu
SHLVL=1
XDG_SEAT=seat0
SUDO_COMMAND=/bin/su
HOME=/root
LANGUAGE=en_IN:en
LOGNAME=root
SUDO_GID=1001
COLORTERM=gnome-terminal
_=/tools/bin/env
OLDPWD=/mnt/lfs/tools


i have check with different test answer which is present in forum.:
root@administrator-Lenovo-U410:/mnt/lfs# ldd /tools/bin/env
linux-vdso.so.1 (0x00007fffb7142000)
libc.so.6 => /tools/lib/libc.so.6 (0x00007faf4ec0c000)
/tools/lib64/ld-linux-x86-64.so.2 (0x00007faf4efaa000)
root@administrator-Lenovo-U410:/mnt/lfs# ldd /tools/bin/bash
linux-vdso.so.1 (0x00007ffd18cc9000)
libdl.so.2 => /tools/lib/libdl.so.2 (0x00007f498046a000)
libc.so.6 => /tools/lib/libc.so.6 (0x00007f49800cc000)
/tools/lib64/ld-linux-x86-64.so.2 (0x00007f498066e000)
root@administrator-Lenovo-U410:/mnt/lfs# readelf -l /tools/bin/bash | grep interpreter
[Requesting program interpreter: /tools/lib64/ld-linux-x86-64.so.2]
root@administrator-Lenovo-U410:/mnt/lfs# readelf -l /tools/bin/env | grep interpreter
[Requesting program interpreter: /tools/lib64/ld-linux-x86-64.so.2]
root@administrator-Lenovo-U410:/mnt/lfs# find -L /tools -name bash 2>/dev/null
/tools/bin/bash
/tools/include/bash
/tools/lib64/bash
/tools/lib/bash
/tools/share/doc/bash
root@administrator-Lenovo-U410:/mnt/lfs# find -L /tools -name env 2>/dev/null
/tools/bin/env
root@administrator-Lenovo-U410:/mnt/lfs# ls -l /tools
total 60
drwxr-xr-x 2 root root 12288 Jun 8 10:41 bin
drwxr-xr-x 2 root root 4096 Jun 7 13:26 etc
drwxr-xr-x 41 root root 4096 Jun 8 09:33 include
drwxr-xr-x 12 root root 12288 Jun 8 09:33 lib
lrwxrwxrwx 1 root root 3 Jun 6 04:08 lib64 -> lib
drwxr-xr-x 6 1002 1002 4096 Jun 8 09:25 libexec
drwxr-xr-x 5 root root 4096 Jun 8 06:08 man
drwxr-xr-x 2 root root 4096 Jun 8 09:31 sbin
drwxr-xr-x 17 root root 4096 Jun 8 09:31 share
drwxr-xr-x 3 root root 4096 Jun 7 13:26 var
drwxr-xr-x 4 root root 4096 Jun 6 04:08 x86_64-pc-linux-gnu
drwxr-xr-x 4 root root 4096 Jun 7 12:27 x86_64-root-linux-gnu
root@administrator-Lenovo-U410:/mnt/lfs# ls -l /tools/bin/bash
-rwxr-xr-x 1 root root 4331888 Jun 8 06:41 /tools/bin/bash
root@administrator-Lenovo-U410:/mnt/lfs# ls -l /tools/bin/env
-rwxr-xr-x 1 root root 148448 Jun 8 07:32 /tools/bin/env
root@administrator-Lenovo-U410:/mnt/lfs#

MensaWater 06-09-2017 07:59 AM

The message seems fairly straight forward about the env command itself.

What do you see if you run "ls -l /tools/bin/env"? "ls -ld /tools/bin"? "ls -ld /tools".

If /tools/bin is a link to /usr/local/tools/bin which and /usr/local is a link to /usr/share and /usr/share is a link to /share etc... it might explain this error. (Of course the links might be anywhere - I'm just illustrating possibilities.) If "env" exists in /bin (as it does on RHEL) and is not a link there then adding /bin to the front of your PATH (before calling env command itself) would likely solve the issue.

hazel 06-09-2017 12:01 PM

Quote:

Originally Posted by MensaWater (Post 5720949)
The message seems fairly straight forward about the env command itself.

What do you see if you run "ls -l /tools/bin/env"? "ls -ld /tools/bin"? "ls -ld /tools".

If /tools/bin is a link to /usr/local/tools/bin which and /usr/local is a link to /usr/share and /usr/share is a link to /share etc... it might explain this error. (Of course the links might be anywhere - I'm just illustrating possibilities.) If "env" exists in /bin (as it does on RHEL) and is not a link there then adding /bin to the front of your PATH (before calling env command itself) would likely solve the issue.

When you are building LFS, /tools on the host system is a link to $LFS/tools. $LFS/tools is not a link to anything and nor is $LFS/tools/bin; they are simple directories. At this stage in an LFS build, programs on the host are no longer used; everything is done with the new LFS tools in /tools/bin.

As far as I can see, the chroot instruction given by the OP is correct, so I'm not sure what is going wrong here. In addition to your suggestions, it would be worth doing "readlink /tools" in the host system.


All times are GMT -5. The time now is 11:32 PM.