[blfs-support] Chroot Problem

Bruce Dubbs bruce.dubbs at gmail.com
Tue Nov 13 14:12:58 PST 2012

Fernando de Oliveira wrote:
> Since I latest read about the time a Linux system can run without needing
> boot again, I had this in mind to write. I sent here instead of lfs,
> because now I am going to install a windows manager and then FF and
> dependencies. But if preferred so, I can send to lfs (support).
> I have to boot every time I chroot in LFS7.2 and logout back to LFS7.1,
> because then I cannot open anymore a terminal (tested with ROXTerm or
> Terminator, the former opens a normal window, but with an error message,
> and closes, the latter is worse, as it also kills X).
> Is this normal, or am I doing something wrong?
> I am using the following (run from a script):
> mount -v --bind \
>    /media/Dados1T/My_Download_Files/Sistema/Linux/lfs/sources6.8/ \
>    /media/LFS72/home/fernando/sshfs/ &&
> mount -v --bind /dev /media/LFS72/dev &&
> mount -vt devpts devpts /media/LFS72/dev/pts &&
> mount -vt proc proc /media/LFS72/proc &&
> mount -vt sysfs sysfs /media/LFS72/sys &&
> if [ -h /dev/shm ]; then
>     rm -f -v /media/LFS72/dev/shm &&
>     mkdir -v /media/LFS72/dev/shm
> fi &&
> mount -vt tmpfs shm /media/LFS72/dev/shm
> (Before, I used a variable for LFS, but trying to understand, I changed to explicit directory everywhere.)
> Then, I issue by hand:
> chroot "$LFS" /usr/bin/env -i      \
> HOME=/root                         \
> TERM="$TERM"                       \
> PS1='\u:\w\$ '                     \
> PATH=/bin:/usr/bin:/sbin:/usr/sbin \
> /bin/bash --login +h

I'm not sure why you need to reboot.  I'm not using lfs-7.1 any more, 
but I frequently go from LFS-7.2-rc1 to the current svn version.

First, the mounts are not always required.  It depends on what you are 
doing.  Some packages need /dev.  It's a rare package that needs /sys or 
/proc beyond the lfs core packages.

What I do is have an alias for bash:

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'

If I need to mount /dev or other partition, I go to another window and 
mount it.  Note that the mount can be done after the chroot as required.

Exiting the chroot environment and re-entering is not a problem.

Generally, I ssh to the development system and can do that from multiple 
windows.  I can even enter chroot from multiple instances.

For example, my host is named blfs and my local system is named lfs6:

bdubbs at lfs6 [ ~ ]$ ssh blfs
Last login: Tue Nov 13 22:10:17 2012 from lfs6.gdc.com
bdubbs at blfs [ ~ ]$ lfs
root:/$ exit
bdubbs at blfs [ ~ ]$ exit
Connection to blfs closed.
bdubbs at lfs6 [ ~ ]$

   -- Bruce

More information about the blfs-support mailing list