Linux From Scratch (LFS)¶
What is LFS?¶
Linux From Scratch (LFS) is a project that provides instructions for building your own custom Linux operating system directly from source code.
It is designed for Linux users who want to gain a deeper understanding of the inner workings of the operating system.
These notes will document building my own Linux operating system by using LFS as a base. The OS will use common enterprise technologies (e.g., systemd) rather than more obscure tools. I made this choice to gain a deeper understanding of the OS components used in enterprise environments.
Starting Out¶
LFS follows Linux standards as closely as possible.
The standards followed:
- POSIX.1-2008
- The POSIX specification.
- Filesystem Hierarchy Standard (FHS) Version 3.0
- The filesystem structure.
- Linux Standard Base (LSB) Version 5.0 (2015)
- The LSB consists of several separate specifications:
- Core
- Desktop
- Runtime Languages
- Imaging
- The LSB consists of several separate specifications:
The core packages that are included in a system built to the LFS standard are listed here along with explanations on why they were included.
Setting up the Build Environment¶
The LFS project is built within a pre-existing Linux system.
A disk partition is made for the LFS filesyste and that's where the new OS is
going to be built.
The list of dependencies for builting an LFS system can be found here.
They provide a shell script on that page that checks for the dependencies on the host system and ensures they're on the correct versions.
For chapters 1-4:
-
Anything done as the root user after Section 2.4 must have the
LFSenvironment variable set FOR THE ROOT USER. -
The
LFSvariable must be set at all times, and theumaskneeds to be set to0022.
For chapters 5-6:
-
The partition should be at
/mnt/lfsand always be mounted. -
Chapters 5 and 6 must be done as the
lfsuser system account.- Create the
lfsuser and group. - Use
su - lfsfor each task in these chapters.
- Create the
For chapters 7-10:
/mnt/lfsshould be mounted.