Monday, June 7, 2010

Chapter 6.4 Entering the Chroot **Important commands**

Gulp. I read all that stuff in between about the package installers. I look forward to actually learning who does what.

It is important that all the commands throughout the remainder of this chapter and the following chapters are run from within the chroot environment. If you leave this environment for any reason (rebooting for example), ensure that the virtual kernel filesystems are mounted as explained in Section 6.2.2, “Mounting and Populating /dev” and Section 6.2.3, “Mounting Virtual Kernel File Systems” and enter chroot again before continuing with the installation.

I doubt that I will finish this today, so I must remember this. Here are the mount commands from Section 6.2.2 and 6.2.3.

Keep in mind that my root does not have LFS in it's bash file, so I first explicitly type,   
export LFS=/media/lfs
mount -v -t ext3 /dev/sdb6 $LFS

mount -v --bind /dev $LFS/dev
mount -vt devpts devpts $LFS/dev/pts
mount -vt tmpfs shm $LFS/dev/shm
mount -vt proc proc $LFS/proc
mount -vt sysfs sysfs $LFS/sys

Here's the command to change root.

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

I am curious about this command, chroot. According to the man page:

chroot - run command or interactive shell with special root directory
SYNOPSIS: chroot NEWROOT [COMMAND...]. "The Bash shell is told that $LFS is now the root (/) directory. " The result of this command, other than that it has no name,  is that, when I type, pwd, I get the "/" mark. There are 19 directories, including tools and sources.

This is just a little weird. if I cd /, I get to the top of this partition $LFS and not to my original session. This concept of chroot is totally alien to me. But, I will move on.

I added this after Second Weekend blog entry.

exec /bin/bash --login +h

I am not sure if it is necessary. The assumptions seem to be that this is all done in one sitting, except for the warning with the chroot.  I am assuming that running it again cannot hurt.

No comments:

Post a Comment