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.

If you are in any doubt about this, you can try the following commands to see if you can chroot:

/tools/lib/libc.so.6
/tools/lib32/libc.so.6
/tools/lib64/libc.so.6
/tools/bin/gcc -v

If any of these commands fail, you will have to follow the boot method.

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

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