III ‐ Building the LFS System - Nimpoo/ft_linux GitHub Wiki
Introduction
Link to of where I am in the process - IV. Building the LFS System
Okay this part is really repetitive and time-consuming, you have over 100 packages to build, and you have to do it in a specific order. Here to, it's really impotant that all packages are built and installed correctly, otherwise you will run into issues later on.
1 - Packages Management
You're not built a packet manager, all packages are built and installed manually, and Gerard Beekmans is clear about this in the book. Read this section to see how you can manage the packages manually : Linux From Scratch - Version r12.3-95-systemd Chapter 8. Installing Basic System Software.
2 - Packages Building
If you're not in the chroot
environment, you need to enter it first, and you need to mount virtual filesystems, AND the "physical" partition where you will build the packages, which is /mnt/lfs
in our case. You can run my script here : mount_partitions_lfs.sh
. Or you can do this with the following commands:
# ? Physical partition
mount -v -t ext4 /dev/sdb3 $LFS/
mount -v -t ext4 /dev/sdb2 $LFS/boot
mount -v -t vfat /dev/sdb1 -o codepage=437,iocharset=iso8859-1 $LFS/boot/efi
/sbin/swapon -v /dev/sdb4
# ? Virtual partition for debugging or something else
mount -v --bind /dev $LFS/dev
mount -vt devpts devpts -o gid=5,mode=0620 $LFS/dev/pts
mount -vt proc proc $LFS/proc
mount -vt sysfs sysfs $LFS/sys
mount -vt tmpfs tmpfs $LFS/run
if [ -h $LFS/dev/shm ]; then
install -v -d -m 1777 $LFS$(realpath /dev/shm)
else
mount -vt tmpfs -o nosuid,nodev tmpfs $LFS/dev/shm
fi
And enter the chroot
environment:
chroot "$LFS" /usr/bin/env -i \
HOME=/root \
TERM="$TERM" \
PS1='(lfs chroot) \u:\w\$ ' \
PATH=/usr/bin:/usr/sbin \
MAKEFLAGS="-j$(nproc)" \
TESTSUITEFLAGS="-j$(nproc)" \
/bin/bash --login
Be sure to build all the packages in the chroot environment.
Let's go on, I have a script here too, but I dicourage you from using it, you need to confirm after each package that it was built and installed correctly, and you need to check the logs. It's REALLY long, and not really automated:
-
Option 1: my script :
basic_system_soft.sh
. But you can't run it with acurl
call in thechroot
environment. -
Option 2: Begin here, with the package
man-pages
: Linux From Scratch - Version r12.3-95-systemd Chapter 8. Installing Basic System Software.
And here we go, take care of all of your commands, check logs and run all the tests.
Talking about tests, sometimes you will run make test
or make check
to verify that the packages are functioning as expected. But sometimes, some packages can fail some tests, and if it happend check in the LFS book if the failure is expected or not. If it is, you can ignore it, otherwise you need to fix it (if you can, but good luck). And some tests are REALLY LONG, gcc
for example takes (for me) around 30 minutes to run all the tests, so be patient. Or rush into the pile and skip the tests.
3 - Cleaning up
Wow fiou, that was long... If you want to strip
the binaries, you can for free some space. I redirect you to the LFS book for this : Linux From Scratch - Version r12.3-95-systemd Chapter 8. Installing Basic System Software.
Clean up some extra files:
rm -rf /tmp/{*,.*}
For the same reasons as here, delete the .la
files:
find /usr/lib /usr/libexec -name \*.la -delete
The compiler built previously is still partially installed and not needed anymore. Remove it with:
find /usr -depth -name $(uname -m)-lfs-linux-gnu\* | xargs rm -rf
And you can delete the user tester
created in the previous section:
userdel -r tester
Almost done ! We need to configure some system files, compile GRUB and the Linux kernel and we'r done.