6.31. To Boot or to Chroot?

There are two different ways you can proceed from this point to build the final system. You can build a kernel, a bootloader, and a few other utilities, boot into the temporary system, and build the rest there. Alternatively, you can mount a few virtual filesystems and chroot into the temporary system.

The chroot (change root) program is used to enter a virtual environment and start a new shell whose root directory will be set to the CLFS partition. This is very similar to rebooting and instructing the kernel to mount the CLFS partition as the root partition. The major advantage is that “chrooting” allows the builder to continue using the host while CLFS is being built. While waiting for package compilation to complete, a user can switch to a different virtual console (VC) or X desktop and continue using the computer as normal.

The main downside to chrooting is that you are more limited in when you can use it - booting will always work for any CLFS build, but the chroot method can only be used when you are building on the same architecture. For example, if you are building on, and for, an x86 system, you can simply chroot. Booting is required when you are compiling for a different architecture, such as building a PowerPC system from an x86. The rule of thumb here is that if the architectures match and you are running the same series kernel (specifically, a 2.6.32 or newer Linux kernel) you can just chroot. If you aren't running the same series kernel, or are wanting to run a different ABI, you will need to use the boot option.

Powerpc64 is slightly different from some of the other architectures, because a 64-bit kernel running 32-bit userspace can successfully chroot and execute 64-bit programs. However, if the kernel personality has been set to 32-bit by a utility such as linux32, it will eventually fail when Glibc thinks it is building on a 32-bit system and tries to include incompatible assembler code in the 64-bit glibc.

To see if you can successfully chroot to build the final powerpc64 system, enter the following command which tests if you are running a 64-bit Linux 2.6 kernel (with a 64-bit personality):

uname -a | grep '^Linux.*2\.6\..*ppc64' && \
    echo "ok to chroot" || echo "you must boot"

For the boot method, follow If You Are Going to Boot.

For the chroot method, follow If You Are Going to Chroot.