Wednesday, August 17, 2016

My journey to building Linux From Scratch LFS system

My journey to building Linux From Scratch LFS system


This will be a series of posts since I will start building Linux From Scratch (LFS) system from scratch. I will follow the by-the-book instruction from start to finish until I built my own LFS system. As I go through this journey, I invite/encourage anyone reading or care to read this blog, to follow along with the journey. Together we will create our own Linux system not because we want to "change the world" or something but to feel and see what its like to have our own linux distro. I also encourage you to document everything that we will be doing as what I am doing right now for future references. We are going to build the system because I hope that you like me are curious about how things work. I dont promise anything as we build the system but the satisfaction of fulfilling our curiosity and educating ourselves in the process. So lets go on building our own Linux From Scratch (LFS) system.



Tools:
    LFS live CD - to be created as a bootable USB
 
(note: according to the website the live CD is not anymore supported and  is not compatible with LFS 7.0 or later. from the same website, it contains the LFS book with 6.3 version. So I downloaded the said version of the book so that I can follow along its instructions.)

The reason that I am going to use the live CD is that it will serve as the base system from which my own LFS is built. A base linux system is needed to create your own LFS as stated on the website. By using the live CD, I eliminate the need for using a base system. We are going to follow the instructions by-the-book in building the system. But we are not going to follow it blindly, were going to dissect the whys and the hows of the instructions to fully comprehend what is going on. If we are stuck on some instruction, were going to stop and take some time and continue
only if we truly comprehend what were doing. As I read somewhere, we have only 2 hrs of retention time of  continuous reading so we are not going to risk doing the next instruction without really comprehending the previous one. Thats the reason we are doing this in the first place, to educate ourselves. So come and join me on the ride. Now on to reading the first parts of the book.

According to the book, the prerequisites are knowledge of shell commands and knowledge of installing linux software, and others. The prerequisite section also provide some links for those who have no knowledge of the above since they are needed as a minimum prerequisite. For the host system requirements, it list the softwares and applications needed for the system to have. Since we are going to use the live CD we are not going to have to download all the applications since they are included in the CD as stated by the website. There is a script from the book which asks us to run to check if the above applications are present in the system. Since were going to use the live CD, we are not going to use that script or follow that instruction. But for the purposes of "getting our hands wet" here is the script in uncomplete form.

    $cat > version_check.sh << "EOF"
    #!/bin/bash
   
    bash --version | head -n1 | cut -d" " -f2-4
    .
    .
    .
    EOF

    bash version_check.sh


Explanation of the above command. The first command creates a file named version_check.sh and "EOF" signifies the end of the file if you type it at the last line. The #!/bin/bash indicates that it is a bash script. The command bash --version indicates that it will show the version of the bash command. The | means pipe the output to the command head. The head command means output the first parts of the file, the argument -n1 means output the first one line of that first part. The cut command means to remove sections of the line. The -d is the delimeter argument and -f means to select only these fields. So the command cut -d" " -f2-4 means cut the line starting from the second field up the fourth field(in this case words) with the space delimeter between them. The last command executes the script.



to be continued.....

Go to link download