On 2/1/2020 8:23 PM, Bruce Dubbs via blfs-support wrote:
On 2/1/20 8:52 PM, Alan Feuerbacher via blfs-support wrote:
I'm trying to get the alias given in the BLFS book (Basic Packages for
Linux® From Scratch - Version 2018-09-21 : Chapter 1. Introduction :
Getting Started After LFS) working, but it fails with the error:
/usr/sbin/chroot: failed to run command '/usr/bin/env': No such file or
directory
The alias is all on one line in .bashrc:
alias lfs='sudo /usr/sbin/chroot /mnt/lfs /usr/bin/env -i HOME=/root
TERM="$TERM" PS1="\u:\w\\\\$ " PATH=/bin:/usr/bin:/sbin:/usr/sbin
/bin/bash --login'
I've tried several variations of the alias, but I don't see what's
going wrong. I believe I've followed the BLFS book, and what Bruce told
me about this, exactly. Here are some results:
[alan@localhost ~]$ su lfs
Password:
bash-5.0$ bash ~/mount-virt.sh
/mnt/lfs/dev already mounted
/mnt/lfs/dev/pts already mounted
/mnt/lfs/proc already mounted
/mnt/lfs/sys already mounted
/mnt/lfs/run already mounted
mkdir: cannot create directory '/mnt/lfs/run/shm': File exists
bash-5.0$ lfs
[sudo] password for lfs:
/usr/sbin/chroot: failed to run command '/usr/bin/env': No such file or
directory
The above was done after executing the mount-virt.sh script without
errors in prior attempts.
To show that that the environment is set up properly (I'm pretty sure):
[alan@localhost ~]$ su lfs
Password:
bash-5.0$ cd
bash-5.0$ whoami
lfs
bash-5.0$ pwd
/home/lfs
bash-5.0$ cat .bashrc
set +h
umask 022
LFS=/mnt/lfs
LC_ALL=POSIX
LFS_TGT=$(uname -m)-lfs-linux-gnu
PATH=/tools/bin:/bin:/usr/bin
export LFS LC_ALL LFS_TGT PATH
alias ll='ls -l'
alias lfs='sudo /usr/sbin/chroot /mnt/lfs /usr/bin/env -i HOME=/root
TERM="$TERM" PS1="\u:\w\\\\$ " PATH=/bin:/usr/bin:/sbin:/usr/sbin
/bin/bash --login'
Any clues what's going south?
The lfs alias is not meant to be run from lfs user. The only time you
need to be user lfs is when building LFS Chapter 5.
Ok. But I thought that, once you're done building LFS, user lfs is just
another random user name.
Can you run
sudo chroot /mnt/lfs /usr/bin/env -i \
HOME=/root TERM="$TERM" \
PS1='(lfs chroot) \u:\w\$ ' \
PATH=/bin:/usr/bin:/sbin:/usr/sbin \
/bin/bash --login
as user alan?
Done. Same result.
I did some extra checking just for grins. The Fedora31 system has
/usr/bin/env and /bin/env. They are identical. But just to be sure I
tested three versions of your script, all with the same result:
[alan@localhost ~]$ bash ~/mount-virt.sh
[sudo] password for alan:
/mnt/lfs/dev mounted
/mnt/lfs/dev/pts mounted
/mnt/lfs/proc mounted
/mnt/lfs/sys mounted
/mnt/lfs/run mounted
[alan@localhost ~]$ sudo chroot /mnt/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
[alan@localhost ~]$ bash ~/mount-virt.sh
[sudo] password for alan:
/mnt/lfs/dev mounted
/mnt/lfs/dev/pts mounted
/mnt/lfs/proc mounted
/mnt/lfs/sys mounted
/mnt/lfs/run mounted
[alan@localhost ~]$ sudo chroot /mnt/lfs /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 ‘/bin/env’: No such file or directory
[alan@localhost ~]$ bash ~/mount-virt.sh
[sudo] password for alan:
/mnt/lfs/dev mounted
/mnt/lfs/dev/pts mounted
/mnt/lfs/proc mounted
/mnt/lfs/sys mounted
/mnt/lfs/run mounted
[alan@localhost ~]$ sudo chroot /mnt/lfs 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 ‘env’: No such file or directory
Based on Ken's response, here are some more results. Of course, this is in the
Fedora 31 system:
[alan@localhost ~]$ ll /usr/bin/env
-rwxr-xr-x. 1 root root 54096 Oct 17 01:37 /usr/bin/env
[alan@localhost ~]$ ll /bin/env
-rwxr-xr-x. 1 root root 54096 Oct 17 01:37 /bin/env
[alan@localhost ~]$ echo $LFS
/mnt/lfs
[alan@localhost ~]$ ls -l $LFS/usr/bin/env
ls: cannot access '/mnt/lfs/usr/bin/env': No such file or directory
[alan@localhost ~]$ ldd /usr/bin/env
linux-vdso.so.1 (0x00007ffe86bfd000)
libc.so.6 => /lib64/libc.so.6 (0x00007fcc3f5f5000)
/lib64/ld-linux-x86-64.so.2 (0x00007fcc3f7e5000)
[alan@localhost ~]$ echo $SHELL
/bin/bash
I'm still at a loss.
Alan
--
http://lists.linuxfromscratch.org/listinfo/blfs-support
FAQ: http://www.linuxfromscratch.org/blfs/faq.html
Unsubscribe: See the above information page