Building a whole Linux system completely from the ground up is something I wanted to do for some time and finally I had all I needed to take the plunge. In this post I’m sharing the highlights of this journey. Also, this is something I’m doing in my spare time, hence the time gaps between milestones.
1st Jan 2022 - Started reading the guide
I decided to go for the LFS-11.0-systemd released in September 2021, the latest stable at the time and I'm comfortable enough with systemd.
Before even starting with LFS I needed a host system, I gave it a try to the latest Arch iso at the time, which was archlinux-2022.01.01-x86_64.iso. Also, as my first attempt in such a venture, I went for a virtual machine using KVM/QEMU with its own challenges which are not fully covered in the guide.
25 Jan 2022 - Created VM with vanilla Arch as host system
Some initial decisions about my target system:
- Virtual machine KVM/QEMU
- 4 CPU (compiling can be CPU intensive)
- 2 GB RAM (aim for a small system)
- 60 GB Disk storage (that was too optimistic)
- UEFI boot (mimic modern systems)
- Network - bridged (ease of connection via SSH)
- 1 partition for everything (simplicity)
- No swap partition, swap file when needed
I learned that a plain vanilla Arch Linux base system is good enough for building a full LFS with no extra packages. Every requirement was met out of the box, that’s a good start !
Once I had my VM up and running with all the base configuration, including my SSH key in place so I can connect to it via SSH so it makes my life easier by enabling me to copy and paste, I made a clone of it just in case I had to go back and start again.
The first few days required a lot of patience and will power, since you’re only compiling and compiling and not seeing much in use. I had the impression sometimes that some of the commands to follow were somehow hacking my way to just get it compiled despite the environment conditions.
It’s only once you enter the chroot that it starts to feel like you’re getting somewhere.
10 Feb 2022 - chroot getting ready
Working inside the chroot can give you some frustration since it’s such a minimal system, the LFS developers made good effort to provide enough tooling to get the job done, but anything outside that, you’ll be faced with the dreaded "-bash: xxxx: command not found"
This was the first time I installed neofetch in the pseudo new system, mostly since I was intrigued by which logo it would display and how it’d find system information when there is barely any system at all.
Because I used UEFI in my target system, I had to jump ahead to BLFS for boot loader installation and configuration, that break in the flow can be a little disrupting and confusing, but nothing major.
14 Feb 2022 - First successful boot
There is always a moment that makes or breaks the installation, in this case is when configuring the Linux kernel. As almost expected after such a long build up preparing and configuring all the packages, I was greeted by a big kernel panic when I booted the system for the first time outside of the chroot.
It couldn’t find /dev/vda3 from the kernel command line argument root=/dev/vda3 which happens to be the root partition in the virtual hard drive. Some symbols were not selected (or indicated in the guide, since it’s specific to my setup using a VM) such as CONFIG_VIRTIO_BLK, more information on that can be found at linux-kvm website.
After adding the missing symbols and rebuilding the kernel a couple of times, following the classical trial and error method, I could see a normal boot screen all the way to the login prompt, which I have to say was lightning fast !
At this point, the system had been built but this was not the end of the journey, there was some extra networking configuration required, again, due to use of a VM which required virtio network as well as 9p so I had a mechanism to share files between the host and the guest LFS.
One more thing before calling it a milestone complete, I got counted and this is my information:
You have successfully registered! ID: 29352 Name: Abel Perez Martinez First LFS Version: 11.0-systemd
Date: 14 Feb 2022
My key takeaways from this process:
- Arch Linux is minimal but powerful
- Be patient, compiling takes time
- Compiling software takes a lot of disk space
- Use -j4 whenever possible
- Make a backup of your VM after a significant milestone
- This is only the beginning, it’s a minimal system
No comments:
Post a Comment