1. LFS‎ > ‎

8. Boot LFS

created : 2010-01-31   updated : 2010-02-09
cat > /etc/fstab << "EOF"
# Begin /etc/fstab
# file system mount-point type options dump fsck
# order
/dev/sdb1 / ext3 defaults 1 1
/dev/sda5 swap swap pri=1 0 0
proc /proc proc defaults 0 0
sysfs /sys sysfs defaults 0 0
devpts /dev/pts devpts gid=4,mode=620 0 0
tmpfs /dev/shm tmpfs defaults 0 0
# End /etc/fstab
The Linux package contains the Linux kernel.
Approximate build time: 1.5 - 5.0 SBU
Required disk space: 350 - 500 MB
Additional download :
My kernel config file
cd /sources
wget --no-check-certificate -O linux- \
Unpack source :
cd /sources
rm -rf linux-
tar -jxvf linux-
cd linux-

Build and install :
time {
make mrproper &&
cp ../linux- ./.config
make oldconfig &&
make &&
make modules_install ;
real    158m54.917s
user    84m37.901s
sys     54m32.465s
The path to the kernel image may vary depending on the platform being used. The following command assumes an x86 architecture:
cp -v arch/x86/boot/bzImage /boot/lfskernel-
System.map is a symbol file for the kernel. It maps the function entry points of every function in the kernel API, as well as the addresses of the kernel data structures for the running kernel. Issue the following command to install the map file:
cp -v System.map /boot/System.map-
backup .config :
cp -v .config /boot/config-
Install the documentation for the Linux kernel:
install -d /usr/share/doc/linux-
cp -r Documentation/* /usr/share/doc/linux-
Create a new file /etc/modprobe.conf by running the following:
cat > /etc/modprobe.conf << "EOF"
# Begin /etc/modprobe.conf
install ohci_hcd /sbin/modprobe ehci_hcd ; /sbin/modprobe -i ohci_hcd ; true
install uhci_hcd /sbin/modprobe ehci_hcd ; /sbin/modprobe -i uhci_hcd ; true
# End /etc/modprobe.conf
The GRUB package contains the GRand Unified Bootloader.
Approximate build time: 0.2 SBU
Required disk space: 10.2 MB
Unpack source :
cd /sources
tar -zxvf grub-0.97.tar.gz
cd grub-0.97

Start by applying the following patch to allow for better drive detection, fix some GCC 4.x issues, and provide better SATA support for some disk controllers:
patch -Np1 -i ../grub-0.97-disk_geometry-1.patch
By default, GRUB doesn't support ext2 filesystems with 256-byte inodes. Fix this by applying the following patch:
patch -Np1 -i ../grub-0.97-256byte_inode-1.patch
Build and install :
time {
./configure --prefix=/usr &&
make CFLAGS="-march=i486 -mtune=native -Os" &&
make install ;
real 1m19.692s
user 0m26.998s
sys 0m31.278s

Copy files :
Replace i386-pc with whatever directory is appropriate for the hardware in use.
mkdir -v /boot/grub
cp -v /usr/lib/grub/i386-pc/stage{1,2} /boot/grub

To test the results, issue:
time make check
real    0m0.913s
user    0m0.252s
sys     0m0.360s
Enter the grub shell
GRUB uses its own naming structure for drives and partitions in the form of (hdn,m), where n is the hard drive number and m is the partition number, both starting from zero. For example, partition hda1 is (hd0,0) to GRUB and hdb3 is (hd1,2).
Tell GRUB where to search for its stage{1,2} files. The Tab key can be used everywhere to make GRUB show the alternatives:
root (hd1,0)
Tell GRUB to install itself into the boot sector of the LFS partition (noted, do that on hd1 only, don't do that on hd0)
setup (hd1)
If all went well, GRUB will have reported finding its files in /boot/grub. That's all there is to it. Quit the grub shell:
Create a “menu list” file defining GRUB's boot menu:
cat > /boot/grub/menu.lst << "EOF"
# Begin /boot/grub/menu.lst
# By default boot the first menu entry.
default 0
# Allow 30 seconds before booting the default.
timeout 30
# Use prettier colors.
color green/black light-green/black
# The first entry is for LFS.
title LFS 6.5
root (hd1,0)
kernel /boot/lfskernel- root=/dev/sdb1

The FHS stipulates that GRUB's menu.lst file should be symlinked to /etc/grub/menu.lst. To satisfy this requirement, issue the following command:
mkdir -v /etc/grub
ln -sv /boot/grub/menu.lst /etc/grub
Login root in host (Ubuntu 9.10)
(backup /etc/grub.d/40_custom if necessary)
Add custom boot entry :
cat >> /etc/grub.d/40_custom << "EOF"
echo "Adding LFS" >&2
menuentry "LFS 6.5" {
set root=(hd1,0)
linux /boot/lfskernel- root=/dev/sdb1
Modify device.map
vi /boot/grub/device.map
add a line :
(hd1)   /dev/sdb
Modify default behavior :
vi /etc/default/grub
Comment the following line (add a # in front of it):
Update menu entry
Reboot :
shutdown -r now