From 9075c19f2f7cc9951d4f521ec37c5c934c215a56 Mon Sep 17 00:00:00 2001 From: cyril constantin Date: Wed, 27 May 2026 10:29:54 +0200 Subject: [PATCH] Trap error of util-linux and update grub config --- README.md | 67 +++++++++++++++++++++++++++++++++++++++ build.sh | 34 ++++++++++++++++++++ build/88210_util-linux.sh | 24 ++++++++++++-- 3 files changed, 123 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index aacd4e5..37bd72c 100644 --- a/README.md +++ b/README.md @@ -100,3 +100,70 @@ Execute as *lfs* user. ```bash make ``` + +## Grub config + +Grub is initiated with the following menu : + +```bash +$ cat /mnt/lfs/boot/grub/grub.cfg +# Begin /boot/grub/grub.cfg +set default=0 +set timeout=5 +insmod part_gpt +insmod ext2 +search --set=root --fs-uuid=8c137b8d-3612-4715-94c2-8203e273318f +set gfxpayload=1024x768x32 +menuentry "GNU/Linux, Linux 6.18.10-lfs-13.0-systemd with blockdevice" { + linux /boot/vmlinuz-6.18.10-lfs-13.0-systemd root=/dev/vdb1 ro +} +menuentry "GNU/Linux, Linux 6.18.10-lfs-13.0-systemd with partuuid" { + linux /boot/vmlinuz-6.18.10-lfs-13.0-systemd root=PARTUUID=001cdfe1-01 ro +} +``` + +The *partuuid* section is not required, but can be helpful if you add another disk or change boot order in bios. partuuid is *more* immutable then *vdx*. + +Devices are extracted from the following command : + +```bash +$ lsblk -o UUID,PARTUUID,PATH,MOUNTPOINT +UUID PARTUUID PATH MOUNTPOINT + /dev/sr0 + /dev/vda +e46c1c50-d494-44f2-a826-41afc1b76eae 9ffe027f-01 /dev/vda1 / + 9ffe027f-02 /dev/vda2 +cae0487a-2eca-44c7-aa5f-060ea258f30c 9ffe027f-05 /dev/vda5 [SWAP] + /dev/vdb +8c137b8d-3612-4715-94c2-8203e273318f 001cdfe1-01 /dev/vdb1 /mnt/lfs +``` + +In this configuration extracted from a libvirt host (*/dev/vdxn*) with a second disk dedicated to LFS, /mnt/lfs device entry is filtered. +The grub config is made with it. + +*cclfs* doesn't install the bootloader. It use the bootloader of the host. +You can install it if you want before or after the first boot. +See instruction in *LFS* book and *BLFS* book. There is only one bootloader *by default* at boot nonetheless. +On Debian Trixie (13) (at least), OS_PROBER is disabled. +Just uncomment the line in /etc/default/grub or customize a config file in /etc/grub.d/ . +And reinstall the bootloader. + +```bash +$ su - +$ grep PROBER /etc/default/grub +GRUB_DISABLE_OS_PROBER=false +# vim /etc/default/grub +# update-grub +``` + +In default configuration, libvirt doesn't activate a second disk, so it won't boot. +Activate the second disk in the boot options. + +You can find devices seen by *bios* with the grub console : type *c* at grub general menu + +```bash +ls +(hd0,msdos1) (hd0,msdos5) (hd1,msdos1) +``` + +If you don't see your *LFS* partition, it won't boot. diff --git a/build.sh b/build.sh index 955e090..3b39cef 100755 --- a/build.sh +++ b/build.sh @@ -2388,6 +2388,40 @@ set gfxpayload=1024x768x32 menuentry "GNU/Linux, Linux ${linuxversion}-lfs-13.0-systemd with blockdevice" { linux /boot/vmlinuz-${linuxversion}-lfs-13.0-systemd root=${blockdevice} ro } +menuentry "GNU/Linux, Linux ${linuxversion}-lfs-13.0-systemd with partuuid" { + linux /boot/vmlinuz-${linuxversion}-lfs-13.0-systemd root=PARTUUID=${uuidpartition} ro +} +EOF +EOSF + if lfs_chroot "${sudofile}" + then + echo "104000" > "${SLFSB}" + else + echo "grub config error" + exit 1 + fi + fi + + ask_for_exit 110100 + + echo "11.1. The End" + if [[ $(cat "${SLFSB}") -lt 110100 ]] + then + sudofile=/tmp/lfs_110100.sh + cat > ${sudofile} << EOSF +echo 13.0-systemd > /etc/lfs-release +cat > /etc/lsb-release << "EOF" +DISTRIB_ID="Linux From Scratch" +DISTRIB_RELEASE="13.0-systemd" +DISTRIB_CODENAME="" +DISTRIB_DESCRIPTION="Linux From Scratch" +EOF +cat > /etc/os-release << "EOF" +NAME="Linux From Scratch" +VERSION="13.0-systemd" +ID=lfs +PRETTY_NAME="Linux From Scratch 13.0-systemd" +VERSION_CODENAME="" EOF EOSF if lfs_chroot "${sudofile}" diff --git a/build/88210_util-linux.sh b/build/88210_util-linux.sh index ab90b25..78efbe7 100644 --- a/build/88210_util-linux.sh +++ b/build/88210_util-linux.sh @@ -23,6 +23,26 @@ make touch /etc/fstab chown -R tester . -su tester -c "make -k check" -make install +# su tester -c "make -k check" +[ -e /tmp/util-linux_make_check.log ] && rm /tmp/util-linux_make_check.log +if ! su tester -c "make -k check" | tee /tmp/util-linux_make_check.log +then + grep "^ FAILED" /tmp/util-linux_make_check.log |sed -e "s/[()]//g" |cut --delimiter=' ' --fields=3 | while IFS= read -r failure + do + echo "--- Check ${failure}" + case ${failure} in + # script/options-size + script/options-size) + echo "test script/options-size is known to fail" + continue + ;; + *) + echo "Failed on ${failure}" + exit 1 + ;; + esac + done +fi + +make install