[lfs-support] chroot script

Baho Utot baho-utot at columbus.rr.com
Thu Oct 4 13:04:08 PDT 2012

On 10/04/2012 03:05 PM, Garrett Gaston wrote:
> I've written the script below for starting the exiting the chroot 
> environment for starting and stopping the LFS project. I'M concerned 
> about the logout and umount commands. I need the script to do all the 
> unmounts upon exiting or logging out. I'M afraid what I've written 
> here will simply chroot and then immediately logout via the "logout" 
> line in the script rather than doing the umounts when I personally 
> logout myself. Have I written this right or what changes do I need to 
> make?
> export LFS=/mnt/lfs                  &&
> mount -v --bind /dev $LFS/dev        &&
> mount -vt devpts devpts $LFS/dev/pts &&
> mount -vt proc proc $LFS/proc        &&
> mount -vt sysfs sysfs $LFS/sys       &&
> 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
> logout
> umount -v $LFS/dev/pts
> umount -v $LFS/dev/shm
> umount -v $LFS/dev
> umount -v $LFS/proc
> umount -v $LFS/sys
> umount -v $LFS
> umount -v $LFS/usr
> umount -v $LFS/home
> umount -v $LFS

I do something very similar top this,

When you chroot it you should stay logged into chroot until you do an 
exit of [control]D in the chroot.
After which your script will then logout, so you should remove the 
logout command as it is not needed.
After removal your script should mount the virtual filesystem, chroot ( 
exit chroot manually) then unmount the virtual file system.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linuxfromscratch.org/pipermail/lfs-support/attachments/20121004/e855b7d3/attachment.html>

More information about the lfs-support mailing list