Finalizing the Core OS [July 16, 2012, 11:17 a.m.]
For this task, I've copied a couple of sections in from the CLFS book, and have provided some links to the CBLFS book and other parts of the internet. Your goal here is to get your system to the state where you can boot into it.
File System
You can create a standard directory tree with the following commands:
mkdir -pv ${CLFS}/{bin,boot,dev,{etc/,}opt,home,lib,mnt}
mkdir -pv ${CLFS}/{proc,media/{floppy,cdrom},run,sbin,srv,sys}
mkdir -pv ${CLFS}/var/{lock,log,mail,spool}
mkdir -pv ${CLFS}/var/{opt,cache,lib/{misc,locate},local}
install -dv -m 0750 ${CLFS}/root
install -dv -m 1777 ${CLFS}{/var,}/tmp
mkdir -pv ${CLFS}/usr/{,local/}{bin,include,lib,sbin,src}
mkdir -pv ${CLFS}/usr/{,local/}share/{doc,info,locale,man}
mkdir -pv ${CLFS}/usr/{,local/}share/{misc,terminfo,zoneinfo}
mkdir -pv ${CLFS}/usr/{,local/}share/man/man{1,2,3,4,5,6,7,8}
for dir in ${CLFS}/usr{,/local}; do
ln -sv share/{man,doc,info} $dir
done
The directory tree above is based on a standard called the "File Heirarchy Standard". You can learn more about the FHS here,
but for now it's enough to know that it's a standard layout for Unix systems.
If you came here from chapters 6 and 7, branching from the "To Boot or Chroot?" section, you'll need the following symlinks as well:
ln -sv /tools/bin/{bash,cat,echo,grep,login,pwd,sleep,stty} ${CLFS}/bin
ln -sv /tools/sbin/{agetty,blkid} ${CLFS}/sbin
ln -sv /tools/bin/file ${CLFS}/usr/bin
ln -sv /tools/lib/libgcc_s.so{,.1} ${CLFS}/usr/lib
ln -sv /tools/lib/libstd*so* ${CLFS}/usr/lib
ln -sv bash ${CLFS}/bin/sh
ln -sv /run /var/run
Making your system bootable
Here I'll give you the short version as far as installing a boot loader. When you first turn on your computer, it will run a program that is placed at the very beginning of a disk; that program is called a "boot loader" because it, in turn, runs the other programs which boot up your operating system. Here, we'll install the grub boot loader.
In chapter 10.63, it recommends installing the following script at /etc/default/grub :
# Begin /etc/default/grub
GRUB_DEFAULT=0
#GRUB_SAVEDEFAULT=true
GRUB_HIDDEN_TIMEOUT=
GRUB_HIDDEN_TIMEOUT_QUIET=false
GRUB_TIMEOUT=10
GRUB_DISTRIBUTOR=Cross-LFS
GRUB_CMDLINE_LINUX=""
GRUB_CMDLINE_LINUX_DEFAULT=""
#GRUB_TERMINAL=console
#GRUB_GFXMODE=640x480
#GRUB_GFXPAYLOAD_LINUX=keep
#GRUB_DISABLE_LINUX_UUID=true
#GRUB_DISABLE_LINUX_RECOVERY=true
#GRUB_INIT_TUNE="480 440 1"
#GRUB_DISABLE_OS_PROBER=true
# End /etc/default/grub
Once we've done that, we can install the bootloader and its config file. The config file can be created with the command
# grub-mkconfig -o /boot/grub/grub.cfg
Warning (from page 248)
The following command will overwrite the current boot loader. Do not run the command if this is not desired, for example, if using a third party boot manager to manage the Master Boot Record (MBR). In this scenario, it would make more sense to install GRUB into the “boot sector” of the CLFS partition. In this case, this next command would become grub-install /dev/sda2.
The preceeding warning can be safely ignored if you built CLFS onto a USB stick with no other operating system. Please see the Windows task, however, for more warnings if you are going this route, even on other operating systems.
To install grub into the boot sector of the disk sda, the command is:
# grub-install /dev/sda
Windows Users
Because Grub configuration can be complicated with windows (you use a technique called "chain loading"), a technique I use that is compatible with Windows up to Windows 7 is to grab a Slackware installation CD, and use it to install the LILO boot loader to my MBR. This will take care of all configuration, and set Windows as the default operating system, automatically.
LILO and Grub are very similar, and each has advantages and disadvantages. Grub is probably my favorite choice overall because it is easy to configure from user space, but LILO is very easy to configure automatically. In fact, when you are building new drivers for your computer or upgrading to a new kernel, LILO can be updated automatically; in Grub you'd have to reconfigure your system manually.
Setting up your Sys V Init System
bla bla bla
Getting Online
bla bla bla