[SOLVED] LFS 11.2 on Ubuntu Server 22.04: chroot: failed to run command ‘/usr/bin/env’: No such file or directory
Linux From ScratchThis Forum is for the discussion of LFS.
LFS is a project that provides you with the steps necessary to build your own custom Linux system.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
LFS 11.2 on Ubuntu Server 22.04: chroot: failed to run command ‘/usr/bin/env’: No such file or directory
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.
Code:
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
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
Code:
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
EDIT 1: Additional checks done
Code:
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
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?
Last edited by necromorph98; 03-02-2023 at 11:05 PM.
Reason: Additional Checks Done
Is $LFS correctly set in this session? It's always worth checking.
Does the directory $LFS/usr/bin contain the env program?
Yeah already double checked it it. Plus reinstalled everything just to be sure. The one thing that's bothering me is the following
Code:
necro-test@necro-server:/mnt/lfs$ ls -la lib64/
total 8
drwxrwxr-x 2 necro-test necro-test 4096 Mar 3 15:31 .
drwxr-xr-x 13 necro-test root 4096 Mar 3 14:32 ..
lrwxrwxrwx 1 necro-test necro-test 27 Mar 3 15:31 ld-linux-x86-64.so.2 -> ../lib/ld-linux-x86-64.so
lrwxrwxrwx 1 necro-test necro-test 27 Mar 3 15:31 ld-lsb-x86-64.so.3 -> ../lib/ld-linux-x86-64.so.2
necro-test@necro-server:/mnt/lfs$ ls -la lib
total 8
drwxrwxr-x 2 necro-test necro-test 4096 Mar 3 14:32 .
drwxr-xr-x 13 necro-test root 4096 Mar 3 14:32 ..
So we are creating a symlink to ld-linux-x86-64.so.2 in $LFS/lib but the directory is empty. I have repeated the whole install about 3-4 times now but i have the same result.
Yeah already double checked it it. Plus reinstalled everything just to be sure. The one thing that's bothering me is the following
Code:
necro-test@necro-server:/mnt/lfs$ ls -la lib64/
total 8
drwxrwxr-x 2 necro-test necro-test 4096 Mar 3 15:31 .
drwxr-xr-x 13 necro-test root 4096 Mar 3 14:32 ..
lrwxrwxrwx 1 necro-test necro-test 27 Mar 3 15:31 ld-linux-x86-64.so.2 -> ../lib/ld-linux-x86-64.so
lrwxrwxrwx 1 necro-test necro-test 27 Mar 3 15:31 ld-lsb-x86-64.so.3 -> ../lib/ld-linux-x86-64.so.2
necro-test@necro-server:/mnt/lfs$ ls -la lib
total 8
drwxrwxr-x 2 necro-test necro-test 4096 Mar 3 14:32 .
drwxr-xr-x 13 necro-test root 4096 Mar 3 14:32 ..
So we are creating a symlink to ld-linux-x86-64.so.2 in $LFS/lib but the directory is empty. I have repeated the whole install about 3-4 times now but i have the same result.
Then you have installed glibc (and probably your other libraries) wrongly. They are supposed to go into $LFS/lib with only symbolic links in $LFS/lib64.
My guess is that you did not have $LFS properly set when you were building glibc. If I were you, I would wipe the LFS partition and start again.
That's not a solution, it's a sticking plaster. If you have installed something in the wrong place, you will keep on getting grief from it, more and more so as you go on. It's like building a wall: each row of bricks rests on the previous one. If a row is badly constructed, all the following rows will be affected, not just the next row up.
LFS is a good learning experience but it does require a certain degree of discipline to make it work. You have to be prepared to scrub everything and start again if something as basic as this is wrong.
That's not a solution, it's a sticking plaster. If you have installed something in the wrong place, you will keep on getting grief from it, more and more so as you go on. It's like building a wall: each row of bricks rests on the previous one. If a row is badly constructed, all the following rows will be affected, not just the next row up.
LFS is a good learning experience but it does require a certain degree of discipline to make it work. You have to be prepared to scrub everything and start again if something as basic as this is wrong.
Hey would it be possible for us to get together over a call and troubleshoot this? I have been stuck on this stage for the past 5-6 days, restarted the whole process 10-11 times but i don't want to do this the wrong way. I'll update the solution after our call.
Last edited by necromorph98; 03-06-2023 at 03:25 AM.
I don't do calls; I have a low-cost internet connection with limited bandwidth. If you are in the UK, we could perhaps talk over the telephone but I doubt if that would do much good as I wouldn't be able to see your system.
I suspect that when you talk about "restarting the whole process", you mean starting the builds again. But what has gone wrong in your case is probably more basic than that, such as a wrongly defined environment for your LFS user. LFS newbies are always tempted to rush over the initial chapters in which the build environment is set up because that's boring and they want to get on and actually build their system. I can understand that, but LFS only works if you follow all the instructions systematically and exactly.
Checking your host software against the approved list is another job that newbies tend to skip over. For example, your host is a Debian derivative, so your system shell will be dash, not bash (bash is the default user shell but it won't be used in build scripts). And your awk program will be mawk and not gawk. Those things make a difference and have to be corrected before you start.
If I were in your position, I would clear the new partition completely except for the source packages. The tools directory goes too. Then start again from the very beginning, reading and following each paragraph in turn and not leaving anything out.
I suspect that when you talk about "restarting the whole process", you mean starting the builds again. But what has gone wrong in your case is probably more basic than that, such as a wrongly defined environment for your LFS user.
This was exactly my suspicion as well. Actually i had been following this guide on youtube and that was my downfall. I skipped the following command in 4.2 which was the real culprit.
Code:
cd "$LFS"
for i in bin lib sbin; do
ln -sv usr/$i $LFS/$i
done
Quote:
LFS newbies are always tempted to rush over the initial chapters in which the build environment is set up because that's boring and they want to get on and actually build their system. I can understand that, but LFS only works if you follow all the instructions systematically and exactly.
Completely agree with this assessment. I kept on going through all the library installations but i left out the inital setup commands assuming that the guide was complete and comprehensive. Learned a valuable lesson today.
Quote:
Checking your host software against the approved list is another job that newbies tend to skip over. For example, your host is a Debian derivative, so your system shell will be dash, not bash (bash is the default user shell but it won't be used in build scripts). And your awk program will be mawk and not gawk. Those things make a difference and have to be corrected before you start.
I already made sure this was fixed. Ran versioncheck.sh.
Now i can mark this issue as truly resolved. Let this post be a lesson to all future LFS newbies. Thanks for all your help hazel
Last edited by necromorph98; 03-06-2023 at 05:27 AM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.