Allow either gpt or dos partitioning of bootimage good-1
authorRalph Ronnquist <ralph.ronnquist@gmail.com>
Mon, 12 Jun 2023 13:20:07 +0000 (23:20 +1000)
committerRalph Ronnquist <ralph.ronnquist@gmail.com>
Mon, 12 Jun 2023 13:20:07 +0000 (23:20 +1000)
mkit.sh

diff --git a/mkit.sh b/mkit.sh
index 3d9d62e947538c97827110681015354cedb4653b..e8dc6574ae53b3e76416d7e799dcb544ed9adda9 100755 (executable)
--- a/mkit.sh
+++ b/mkit.sh
@@ -14,6 +14,7 @@ REPO="deb.devuan.org/merged"
 SUITE="daedalus"
 SECTION="main"
 ARCH="amd64"
+MBR=gpt # or dos
 
 PKGFILE=${REPO//\//_}_${SUITE}_${SECTION}_binary-${ARCH}_Packages
 if [ ! -r $PKGFILE ] ; then
@@ -153,8 +154,10 @@ echo "# Now pack up that initrd as initrd.gz"
 rm -f bootimage.raw
 dd if=/dev/zero of=bootimage.raw bs=32M count=1
 
-# Prepare a dos partition table with a first partition marked as EFI
+# Prepare a gpt/dos partition table with a first partition marked as EFI
 sfdisk bootimage.raw <<EOF
+label: $MBR
+
 2048 32767 U *
 - - L
 EOF
@@ -165,7 +168,7 @@ IMG="-i bootimage.raw@@$((2048*512))"
 
 # Add an ext2 filesystem at offset 61440*512
 # Copy initrd.gz and kernel into the fat filesystem root
-mke2fs -t ext4 -E offset=$((34816*512)) -F bootimage.raw
+mke2fs -t ext4 -E offset=$((34816*512)) -F bootimage.raw 15M
 
 mcopy $IMG initrd.gz ::
 mcopy $IMG kernel/boot/vm* ::/vmlinuz
@@ -200,8 +203,19 @@ mcopy $IMG \
       kernel/usr/lib/syslinux/modules/efi64/* ::/EFI/BOOT
 mcopy $IMG syslinux-uefi.cfg ::/EFI/BOOT/syslx64.cfg
 
+
 syslinux --install --offset=${IMG#*@@} bootimage.raw
+
+case "$MBR" in
+    dos) MBRBIN=mbr.bin ;;
+    gpt)
+       MBRBIN=gptmbr.bin
+       sfdisk --relocate gpt-bak-std bootimage.raw
+       sfdisk -f --part-attrs bootimage.raw 1 LegacyBIOSBootable
+       ;;
+    *) exit 1 ;;
+esac
 dd conv=notrunc of=bootimage.raw bs=440 count=1 \
-   if=kernel/usr/lib/syslinux/mbr/mbr.bin
+   if=kernel/usr/lib/syslinux/mbr/$MBRBIN
 
 exit