1

I have been following the LFS 11.2 guide and it has gone smoothly up until the chroot part. Although the symlinks have created properly i.e. relative to the LFS directory, the error is still persistent.

necro-test@necro-server:/mnt/lfs$ ls -la lib64/
total 8
drwxrwxr-x  2 root       root 4096 Mar  1 10:39 .
drwxr-xr-x 17 necro-test root 4096 Mar  1 12:03 ..
lrwxrwxrwx  1 root       root   27 Mar  1 10:39 ld-linux-x86-64.so.2 -> ../lib/ld-linux-x86-64.so.2
lrwxrwxrwx  1 root       root   27 Mar  1 10:39 ld-lsb-x86-64.so.3 -> ../lib/ld-linux-x86-64.so.2

My mounts

necro-test@necro-server:/mnt/lfs$ findmnt | grep /mnt
└─/mnt/lfs                                    /dev/sdb2                         ext2        rw,relatime
  ├─/mnt/lfs/dev                              udev                              devtmpfs    rw,nosuid,relatime,size=16241452k,nr_inodes=4060363,mode=755,inode64
  │ └─/mnt/lfs/dev/pts                        devpts                            devpts      rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000
  ├─/mnt/lfs/proc                             proc                              proc        rw,relatime
  ├─/mnt/lfs/sys                              sysfs                             sysfs       rw,relatime
  └─/mnt/lfs/run                              tmpfs                             tmpfs       rw,relatime,inode64

My PATH and ENV

necro-test@necro-server:/mnt/lfs$ echo $PATH && echo $LFS
/mnt/lfs/tools/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
/mnt/lfs

Previous posts had the problem of symlinks being to absolute paths like here. All my compilations were successful and all the directories have been setup properly. This is the command where it's failing

root@necro-server:/home/necro-test/partitioning# chroot "$LFS" /usr/bin/env -i \
    HOME=/root \
    TERM="$TERM" \
    PS1="(lfs chroot) \u:\w\$" \
    PATH="/bin:/usr/bin:/sbin:/usr/sbin" \
    /bin/bash --login
chroot: failed to run command ‘/usr/bin/env’: No such file or directory

I have already gone through previous posts having this problem but there nothing regarding this for the 11.2 revision so none of the solutions have helped me. What am i missing?

EDIT 1: Adding additional sanity checks

root@necro-server:/mnt/lfs# chroot $LFS /lib64/ld-linux-x86-64.so.2 --help
chroot: failed to run command ‘/lib64/ld-linux-x86-64.so.2’: No such file or directory

root@necro-server:/mnt/lfs# $LFS/usr/bin/env
SHELL=/bin/bash
SUDO_GID=1000
SUDO_COMMAND=/usr/bin/su
SUDO_USER=necro-test
PWD=/mnt/lfs
LOGNAME=root
HOME=/root
LANG=en_US.UTF-8
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.webp=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:
LESSCLOSE=/usr/bin/lesspipe %s %s
TERM=xterm-256color
LESSOPEN=| /usr/bin/lesspipe %s
USER=root
SHLVL=1
LFS_TGT=x86_64-lfs-linux-gnu
LFS=/mnt/lfs
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
SUDO_UID=1000
MAIL=/var/mail/root
LFS_DISK=/dev/sdb
_=/mnt/lfs/usr/bin/env

root@necro-server:/mnt/lfs# file $LFS/usr/bin/env
/mnt/lfs/usr/bin/env: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, with debug_info, not stripped

root@necro-server:/mnt/lfs# ls -la
total 48
drwxr-xr-x  16 necro-test root       4096 Mar  2 13:27 .
drwxr-xr-x   3 root       root       4096 Mar  2 08:10 ..
drwxrwxr-x   2 root       root       4096 Mar  2 12:24 bin
drwxrwxr-x   2 necro-test necro-test 4096 Mar  2 11:31 boot
drwxr-xr-x  21 root       root       4600 Mar  2 07:35 dev
drwxrwxr-x   2 root       root       4096 Mar  2 12:19 etc
drwxrwxr-x   2 root       root       4096 Mar  2 11:31 lib
drwxrwxr-x   2 root       root       4096 Mar  2 12:03 lib64
dr-xr-xr-x 534 root       root          0 Mar  2 13:29 proc
drwxrwxrwt   2 root       root         40 Mar  2 13:29 run
drwxrwxr-x   2 root       root       4096 Mar  2 11:31 sbin
drwxrwxr-x  25 necro-test necro-test 4096 Mar  2 13:22 sources
dr-xr-xr-x  13 root       root          0 Mar  2 07:35 sys
drwxrwxr-x   8 root       root       4096 Mar  2 12:03 tools
drwxrwxr-x   9 root       root       4096 Mar  2 12:40 usr
drwxrwxr-x   3 root       root       4096 Mar  2 12:19 var
4
  • Can you successfully run ld.so directly, i.e. chroot $LFS /lib64/ld-linux-x86-64.so.2 --help? Does $LFS/usr/bin/env actually exist, too? Does file $LFS/usr/bin/env report the correct "interpreter" path embedded? Commented Mar 2, 2023 at 6:24
  • @user1686 for chroot $LFS /lib64/ld-linux-x86-64.so.2 --help i get chroot: failed to run command ‘/lib64/ld-linux-x86-64.so.2’: No such file or directory but $LFS/usr/bin/env exists and file $LFS/usr/bin/env gives /mnt/lfs/usr/bin/env: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, with debug_info, not stripped. I have added these sanity checks in the questions. Commented Mar 2, 2023 at 13:33
  • Then, are you sure that your symlinks are pointing to files that exist? Commented Mar 2, 2023 at 13:53
  • @user1686 The one thing that's bothering me is that $LFS/lib folder is empty but there are symlinks from ld-linux-x86-64.so.2 in $LFS/lib64 to ../lib/ld-linux-x86-64.so.2 . Am i correct to assume this is where i am wrong? root@necro-server:/mnt/lfs# ls lib comes up empty Commented Mar 2, 2023 at 14:00

2 Answers 2

0

If your /mnt/lfs/lib is empty, that's the problem. I just created link ./lib/ld-linux-x86-64.so.2 pointing to ../usr/lib/ld-linux-x86-64.so.2 and that solved the problem for me

But i think there should be better fix

0

I ended up in the same place as you with LFS 11.3. I don't know what I did wrong, but my problem was that the folders $LFS/lib, $LFS/bin and $LFS/sbin contained links to $LFS/usr/lib etc. instead of being links to them.

To solve this, I removed the folders

rm -rf $LFS/{lib,bin,sbin}

then I created the links correctly

for i in bin lib sbin; do ln -sv usr/$i $LFS/$i; done

and then I recreated a link that was removed by the rm above

ln -sv bash $LFS/bin/sh

Now

ls $LFS/bin

prints a lot of files as it should, and the chroot command works!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .