VI ‐ Time To Boot - Nimpoo/ft_linux GitHub Wiki
Introduction
If everything is okay, after all these errors and these restarts from the beginning, you should have a bootable LFS system.
It's time.
chroot
Environment and Unmount Partitions
1 - Exit the You can exit the chroot
environment:
logout
And unmount the virtuals partitions and the others you mounted earlier:
# ? Virtual partition
umount -v $LFS/dev/pts
mountpoint -q $LFS/dev/shm && umount -v $LFS/dev/shm
umount -v $LFS/dev
umount -v $LFS/run
umount -v $LFS/proc
umount -v $LFS/sys
# ? Physical partition
umount -v $LFS/boot/efi
umount -v $LFS/boot
/sbin/swapoff -v /dev/sdb4
umount -v $LFS
2 - Compile EDK II
EDK II is the UEFI Development Kit, it provides a set of tools and libraries for developing UEFI applications and drivers. It is used to build UEFI applications, including bootloaders like GRUB2. Without EDK II, GRUB2 cannot be built for UEFI systems.
So you have 2 options:
- Option 1: Check if you already have EDK II installed. To know that, check these paths:
ls /usr/share/OVMF/OVMF_CODE.fd
ls /usr/share/OVMF/OVMF_VARS.fd
And on the QEMU
script, for the flag -drive
you can set directly set the path to the OVMF
files, like this:
-drive if=pflash,format=raw,readonly=on,file=/usr/share/OVMF/OVMF_CODE.fd
And:
-drive if=pflash,format=raw,readonly=on,file=/usr/share/OVMF/OVMF_VARS.fd
- Option 2: You don't have EDK II installed, and you need to compile it. You can find the source code of EDK II on the TianoCore GitHub repository of EDK II
3 - Boot the LFS System on a Virtual Machine
Now, you can boot your LFS system on a virtual machine. I personnally use QEMU
, you can find my script here : launch_lfs_vm.sh
.
You can launch the VM with the following command:
qemu-system-x86_64 \
-enable-kvm \
-m 28G \
-smp cores=16,threads=2,sockets=1 \
-cpu host \
-net nic,model=virtio -net user,hostfwd=tcp::22222-:22 \
-device virtio-balloon \
-vga virtio \
-full-screen \
-daemonize \
-drive if=pflash,format=raw,readonly=on,file=/usr/share/OVMF/OVMF_CODE.fd \
-drive if=pflash,format=raw,file=OVMF_VARS.fd \
-hda lfs.qcow2
Obviously, adapt the number of cores, the memory size, and the path to the
OVMF
files.
YOU'RE DONE 🥳🎉
A last cool thing to do is to get counted. You can register your LFS system on the Linux From Scratch - User Counter.
But it's not finished, now we can customize and add some packages to our LFS system. The Beyond Linux® From Scratch (systemd Edition) - Version r12.3-1144 is here for that. Gerard Beekmans provides a lot of packages and configurations to customize your LFS system, and this is what we will do in the next sections.