My Linux From Scratch system | |
2025-03-29 | |
Last edit: 2025-03-29 | |
--------------------- | |
> In this blog post, I will refer to | |
Linux From Scratch | |
by writing "LFS". | |
I heard about LFS by stumbling across a | |
podcast | |
by Brodie Robertson. I've been curious and made me want to build my own Linux … | |
## What is LFS? | |
It's a book that explains how to build your own Linux system from scratch using… | |
## My objectives | |
In reading LFS, I have some very specific goals. I'd like my system to be able … | |
DDNet | |
and Quake I. To do this, I'll need a kernel that can communicate with my hardw… | |
I'd also like to have a simple, lightweight desktop environment based on the gr… | |
Xorg | |
. | |
And most important of all, I'd like to be able to boot into my system directly … | |
## Building LFS | |
So I started reading the book and setting up my system. More precisely, I chose | |
version 12.2 with systemd (French version) | |
as init daemon and with Linux version 6.10.5. In this section, I'm not going t… | |
### Disk partitioning | |
I chose to make a single 40GiB ext4 partition on my laptop's hard disk. I decla… | |
NixOS](https://nixos.org) configuration, with partitioning handled by the [NixO… | |
module. | |
```nix | |
lfs = { | |
name = "LFS"; | |
size = "40G"; | |
content = { | |
Happy helping ☃ here: You tried to output a spurious TAB character. This will… | |
Happy helping ☃ here: You tried to output a spurious TAB character. This will… | |
Happy helping ☃ here: You tried to output a spurious TAB character. This will… | |
}; | |
}; | |
``` | |
### Compiling the compiler compiling a compiler | |
An important part of LFS is cross-compiling. The aim is to build the tools of t… | |
Here's a diagram representing the cross-compilation steps, where each rectangle… | |
### Basic softwares and configuration | |
After entering my new system (chroot), I was able to establish a base. | |
I installed all the basic tools you'd want on a Linux system and wrote configur… | |
### Linux | |
I built Linux by passing the right values to its parameters, so as to be as com… | |
I activated the right drivers to communicate with my network card and audio har… | |
Once built and installed on my LFS system, all that's left to do is load Linux. | |
### Boot | |
To be able to boot on my LFS system, I added an entry for the GRUB managed by m… | |
NixOS](https://nixos.org) system. To do this, I rebuilt my [NixOS | |
system using os-pober, as shown below. | |
```nix | |
loader.grub = { | |
useOSProber = true; | |
}; | |
``` | |
## Beyond LFS | |
Now that I have a basic system that I can boot, the goal is to have a desktop e… | |
I had to build the entire graphics system | |
X](https://fr.wikipedia.org/wiki/X_Window_System) and its dependencies, before … | |
. | |
I'm obviously skipping all the sub-dependencies, network configuration (DHCP cl… | |
Below is an overview of my main desktop envinronnement. | |
So I end up on | |
Xfce](https://www.xfce.org), download the latest version of [DDNet | |
, patch the source code as I didn't want to use the `libnotify` library, compil… | |
The application is functional, I can join a game via the Internet and the game … | |
The same for Quake I through | |
VkQuake | |
, a preview below. | |
## Little hack | |
To avoid having to manage all the packages by hand, I decided to install a pack… | |
Nix | |
. It will allow me to have fully functional immutable packages. | |
I installed it with the | |
DeterminateSystems | |
installer. | |
It allowed me to build very complicated packages such as | |
Firefox | |
, here's a preview. | |
## Is it worth it? | |
Reading and putting LFS into practice takes a long time, but it's definitely wo… | |
I recommend the experience to all curious people who want to have their own Lin… | |
## Conclusion | |
I loved reading the book and setting up everything myself, and I intend to keep… | |