From 96a5ba0ed33e3a4407f25a421048678d6c0bb26f Mon Sep 17 00:00:00 2001 From: Bananymous Date: Thu, 21 Nov 2024 17:59:38 +0200 Subject: [PATCH] BuildSystem: Make root partition UUID fixed This allows specifying root as UUID which makes booting nicer experience on real hardware --- script/config.sh | 2 ++ script/image-create.sh | 9 +++++++++ script/install-bootloader.sh | 4 ++-- toolchain/grub-legacy-boot.cfg | 12 ++++++------ toolchain/grub-uefi.cfg | 12 ++++++------ 5 files changed, 25 insertions(+), 14 deletions(-) diff --git a/script/config.sh b/script/config.sh index 7502c722..27050644 100644 --- a/script/config.sh +++ b/script/config.sh @@ -33,3 +33,5 @@ if [[ -z $BANAN_BOOTLOADER ]]; then fi export BANAN_CMAKE=$BANAN_TOOLCHAIN_PREFIX/bin/cmake + +export BANAN_ROOT_PART_UUID='9C87D2AF-566A-4517-971A-57BA86EEA88D' diff --git a/script/image-create.sh b/script/image-create.sh index 5e9f1915..3cd2d764 100755 --- a/script/image-create.sh +++ b/script/image-create.sh @@ -46,6 +46,15 @@ else mkpart root ext2 2M 100% fi +fdisk "$BANAN_DISK_IMAGE_PATH" >/dev/null << EOF +x +u +2 +$BANAN_ROOT_PART_UUID +r +w +EOF + # create loop device LOOP_DEV=$(sudo losetup --show -fP "$BANAN_DISK_IMAGE_PATH" || exit 1 ) PARTITION1=${LOOP_DEV}p1 diff --git a/script/install-bootloader.sh b/script/install-bootloader.sh index df291476..51fd6c0b 100755 --- a/script/install-bootloader.sh +++ b/script/install-bootloader.sh @@ -44,7 +44,7 @@ install_grub_legacy() { --boot-directory="$MOUNT_DIR/boot" \ $LOOP_DEV sudo mkdir -p "$MOUNT_DIR/boot/grub" - sudo cp "$BANAN_TOOLCHAIN_DIR/grub-legacy-boot.cfg" "$MOUNT_DIR/boot/grub/grub.cfg" + sed "s//UUID=$BANAN_ROOT_PART_UUID/" "$BANAN_TOOLCHAIN_DIR/grub-legacy-boot.cfg" | sudo tee "$MOUNT_DIR/boot/grub/grub.cfg" >/dev/null sudo umount "$MOUNT_DIR" } @@ -57,7 +57,7 @@ install_grub_uefi() { sudo mount $PARTITION2 "$MOUNT_DIR" sudo mkdir -p "$MOUNT_DIR/boot/grub" - sudo cp "$BANAN_TOOLCHAIN_DIR/grub-uefi.cfg" "$MOUNT_DIR/boot/grub/grub.cfg" + sed "s//UUID=$BANAN_ROOT_PART_UUID/" "$BANAN_TOOLCHAIN_DIR/grub-uefi.cfg" | sudo tee "$MOUNT_DIR/boot/grub/grub.cfg" >/dev/null sudo umount "$MOUNT_DIR" } diff --git a/toolchain/grub-legacy-boot.cfg b/toolchain/grub-legacy-boot.cfg index 4a40c130..95b13636 100644 --- a/toolchain/grub-legacy-boot.cfg +++ b/toolchain/grub-legacy-boot.cfg @@ -1,23 +1,23 @@ menuentry "banan-os" { - multiboot2 /boot/banan-os.kernel root=/dev/sda2 + multiboot2 /boot/banan-os.kernel root= } menuentry "banan-os (no serial)" { - multiboot2 /boot/banan-os.kernel root=/dev/sda2 noserial + multiboot2 /boot/banan-os.kernel root= noserial } menuentry "banan-os (only serial)" { - multiboot2 /boot/banan-os.kernel root=/dev/sda2 console=ttyS0 + multiboot2 /boot/banan-os.kernel root= console=ttyS0 } menuentry "banan-os (no apic)" { - multiboot2 /boot/banan-os.kernel root=/dev/sda2 noapic + multiboot2 /boot/banan-os.kernel root= noapic } menuentry "banan-os (no apic, no serial)" { - multiboot2 /boot/banan-os.kernel root=/dev/sda2 noapic noserial + multiboot2 /boot/banan-os.kernel root= noapic noserial } menuentry "banan-os (no apic, only serial)" { - multiboot2 /boot/banan-os.kernel root=/dev/sda2 noapic console=ttyS0 + multiboot2 /boot/banan-os.kernel root= noapic console=ttyS0 } diff --git a/toolchain/grub-uefi.cfg b/toolchain/grub-uefi.cfg index 6fac427f..e8b80e74 100644 --- a/toolchain/grub-uefi.cfg +++ b/toolchain/grub-uefi.cfg @@ -4,25 +4,25 @@ set root=(hd0,gpt2) insmod all_video menuentry "banan-os" { - multiboot2 /boot/banan-os.kernel root=/dev/sda2 + multiboot2 /boot/banan-os.kernel root= } menuentry "banan-os (no serial)" { - multiboot2 /boot/banan-os.kernel root=/dev/sda2 noserial + multiboot2 /boot/banan-os.kernel root= noserial } menuentry "banan-os (only serial)" { - multiboot2 /boot/banan-os.kernel root=/dev/sda2 console=ttyS0 + multiboot2 /boot/banan-os.kernel root= console=ttyS0 } menuentry "banan-os (no apic)" { - multiboot2 /boot/banan-os.kernel root=/dev/sda2 noapic + multiboot2 /boot/banan-os.kernel root= noapic } menuentry "banan-os (no apic, no serial)" { - multiboot2 /boot/banan-os.kernel root=/dev/sda2 noapic noserial + multiboot2 /boot/banan-os.kernel root= noapic noserial } menuentry "banan-os (no apic, only serial)" { - multiboot2 /boot/banan-os.kernel root=/dev/sda2 noapic console=ttyS0 + multiboot2 /boot/banan-os.kernel root= noapic console=ttyS0 }