if you are one of those who love core technology, especially in the open source world, you might have had experience with Linux such as CentOS, Debian Ubuntu and others famous distributions in the market. But have you ever wondered how the Linux is built or how the Linux works inside, if you have so like I have once, this article is just right for you. To scratch this itch, I have found the incredible open source project which is called Linux From Scratch Linux From Scratch(LFS); a project that provides step-by-step instructions to build Linux system entirely from source code. The purposes of this project serve my curiosity so well and I thought it would be good to record what I have done with this project to remain me when I’d like to go digging down the Linux again, and It might be good for someone who would like to get along with the LFS. So Let’s get started now.
To get stared with the LFS, I am using VMWare Workstation version 8 running on Windows 7, the advantage to use it, is I can snapshot my current stat machine before going to do some serious instructions because if it goes wrong I can recovery the machine right away. The following is the list you must prepare:
- Virtual Machine – create a virtual machine with Linux as a guest operating system.
- Host Operating System – this system is used to compile and build the LFS, you can get more details for the host system requirements at the LFS-Book. In my case I use host system as a live-cd that I built from the SUSE Studio according to the host system requirements. But maybe you can just search “LFS” in there because someone might has done the live-cd for building the LFS already, if so you just download it.
Preparing partition for the build
if you read through part one that talk about the overview how to build the LFS. The first thing to do before going to part two is to prepare the partitions.
- Boot the virtual machine with the live-cd, log-in as normal user.
- In the virtual machine, it should have sda as a hard-disk, use fdisk command to to partition the disk as following:
- sda1 – 20 GB and be set bootable flag, this partition will be root partition.
- sda2 – 2 GB, this partition will be swap.
- Now you can go throught part two to prepare to build the LFS.
Building the LFS System
If you have done part two, you can go on to part three, but there is something you to do carefully in the chapter 8, section 8.3 Building the kernel. In my case I am not a Linux expert to configure the kernel configuration and if the configuration is wrong, the system will give you the kernel-panic problems when booting. I figured it out to avoid these problems as following:
- At the host system, copy the .config file from the host system to the LFS environment by:
cp /boot/config-3.x.x-default /mnt/lfs/sources/linux-3.x.x/.config
- At dit the .config file to set the flags as following:
- Run make menuconfig
- After running make menuconfig, you should select SCSI driver to your kernel.
- you would better take a snapshot here before going the next instructions.
- Go through the rest of the instructions.
Problems after booting
- VFS unable to mount root fs on unknows-block(0,0) – to fix this you have to go back at the configuring kernel section by using snapshot and select the SCSI disk driver.
- VFS unable to mount root fs on unknows-block(8,1) grub cannot find disk – to fix this problem you have to notice that what the disk name that the LFS system see, in my case the system detect the disk as sdb instead of sda which I don’t know why, then change the grub configuration to boot with sdb.
This is just the rough experience that I have had when I did the LFS system, so good luck with your own.