From 9fd67c85227b727824340a7552eec17fd460bb51 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Paul=20H=C3=A4nsch?= Date: Mon, 15 Jul 2019 20:43:22 +0200 Subject: [PATCH] bootloader configuration: boot efi32 and efi64, using grub, and bios using syslinux --- Makefile | 63 ++++++++++++++++++++++++++-------- cfg_syslinux/boot/bootmenu.cfg | 16 --------- cfg_syslinux/boot/syslia32.cfg | 3 -- cfg_syslinux/boot/syslinux.cfg | 3 -- cfg_syslinux/boot/syslx64.cfg | 3 -- 5 files changed, 48 insertions(+), 40 deletions(-) delete mode 100644 cfg_syslinux/boot/bootmenu.cfg delete mode 100644 cfg_syslinux/boot/syslia32.cfg delete mode 100644 cfg_syslinux/boot/syslinux.cfg delete mode 100644 cfg_syslinux/boot/syslx64.cfg diff --git a/Makefile b/Makefile index e8c38c4..03a66ae 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ DEFAULT: _target .PHONY: clean .FORCE -.PHONY: _qemu _bootstrap _install _copy _config _syslinux _squash +.PHONY: _qemu _bootstrap _install _copy _config _bootloader _squash .PHONY: _target _partition _format _mount _sparse _umount _partcopy _mbr ARCH := amd64 @@ -9,8 +9,8 @@ KEYRING := keys/debian-archive-stretch-stable.gpg BOOTSTRAP := http://cdn.debian.net/debian # Partition Table (2M) + Boot Partition (126M)+ Root Partition + Slack Space (1M) = 2048M -BOOT_MB := 126 -ROOT_MB := 1919 +BOOT_MB := 62 +ROOT_MB := 959 define SOURCES = deb http://cdn.debian.net/debian stretch main @@ -33,9 +33,9 @@ _mount: _format _bootstrap: _mount _install: _bootstrap _mount _config: _install _mount -_syslinux: _mount -_umount: _mount _config _syslinux -_mbr: _umount _syslinux +_bootloader: _mount +_umount: _mount _config _bootloader +_mbr: _umount _bootloader else ifdef image VOLUME := ${image} @@ -53,11 +53,11 @@ _format: _sparse _mount: _format _copy: _install _mount _config: _copy _mount -_syslinux: _mount -_umount: _mount _config _syslinux +_bootloader: _mount +_umount: _mount _config _bootloader _partition: _partcopy: _partition _umount -_mbr: _partcopy _syslinux +_mbr: _partcopy _bootloader else ifdef squash SQUASH := ${squash} @@ -186,14 +186,17 @@ _squash: ${SQUASH} ${VOLUME}: .FORCE ! printf '%s\n' "$${VOLUME}" |grep -q '^/dev/' # abort if volume should be real device + dd count=0 of="$${VOLUME}" # truncate dd bs=1M count=0 seek=$$((3 + ${BOOT_MB} + ${ROOT_MB})) of="$${VOLUME}" ${PBOOT}: .FORCE ! printf '%s\n' "$${PBOOT}" |grep -q '^/dev/' # abort if volume should be real device + dd count=0 of="$${PBOOT}" # truncate dd bs=1M count=0 seek=${BOOT_MB} of="$${PBOOT}" ${PROOT}: .FORCE ! printf '%s\n' "$${PROOT}" |grep -q '^/dev/' # abort if volume should be real device + dd count=0 of="$${PROOT}" # truncate dd bs=1M count=0 seek=${ROOT_MB} of="$${PROOT}" _partition: ${VOLUME} @@ -208,12 +211,15 @@ _format: ${PBOOT} ${PROOT} mkfs.ext4 -F -L FSROOT "$${PROOT}" .PHONY: _syslinux_efi32 _syslinux_efi64 _syslinux_bios +.PHONY: _grub_efi32 _grub_efi64 + _syslinux_efi32: ${CFGROOT} mkdir -p "$${CFGROOT}/boot/EFI/BOOT" cp /usr/lib/SYSLINUX.EFI/efi32/syslinux.efi "$${CFGROOT}/boot/EFI/BOOT/BOOTIA32.EFI" mkdir -p "$${CFGROOT}/boot/efi32" cp $(addprefix /usr/lib/syslinux/modules/efi32/, ldlinux.e32 menu.c32 libutil.c32) "$${CFGROOT}"/boot/efi32/ cp /usr/lib/syslinux/modules/efi32/ldlinux.e32 "$${CFGROOT}/boot/EFI/BOOT/" # workaround + printf 'PATH /efi32\nINCLUDE /bootmenu.cfg\nMENU TITLE Syslinux EFI-32\n' >"$${CFGROOT}/boot/syslia32.cfg" _syslinux_efi64: ${CFGROOT} mkdir -p "$${CFGROOT}/boot/EFI/BOOT" @@ -221,21 +227,48 @@ _syslinux_efi64: ${CFGROOT} mkdir -p "$${CFGROOT}/boot/efi64" cp $(addprefix /usr/lib/syslinux/modules/efi64/, ldlinux.e64 menu.c32 libutil.c32) "$${CFGROOT}"/boot/efi64/ cp /usr/lib/syslinux/modules/efi64/ldlinux.e64 "$${CFGROOT}/boot/EFI/BOOT/" # workaround - + printf 'PATH /efi64\nINCLUDE /bootmenu.cfg\nMENU TITLE Syslinux EFI-64\n' >"$${CFGROOT}/boot/syslx64.cfg" _syslinux_bios: ${CFGROOT} mkdir -p "$${CFGROOT}/boot/bios" cp $(addprefix /usr/lib/syslinux/modules/bios/, menu.c32 libutil.c32) "$${CFGROOT}"/boot/bios/ + printf 'PATH bios\nINCLUDE bootmenu.cfg\nMENU TITLE Syslinux BIOS\n' >"$${CFGROOT}/boot/syslinux.cfg" -_syslinux: ${CFGROOT} _syslinux_efi32 _syslinux_efi64 _syslinux_bios - cp -L "$${CFGROOT}/vmlinuz" "$${CFGROOT}/initrd.img" "$${CFGROOT}/boot/" - cp -ru cfg_syslinux/. "$${CFGROOT}/" - # cp "$${CFGROOT}/boot/syslx64.cfg" "$${CFGROOT}/boot/EFI/BOOT/syslinux.cfg" # workaround +_grub_efi32: ${CFGROOT} + mkdir -p "$${CFGROOT}/boot/EFI/BOOT" + grub-mkimage -p / -O i386-efi fat part_gpt normal linux all_video >"$${CFGROOT}/boot/EFI/BOOT/BOOTIA32.EFI" -_mbr: ${VOLUME} +_grub_efi64: ${CFGROOT} + mkdir -p "$${CFGROOT}/boot/EFI/BOOT" + grub-mkimage -p / -O x86_64-efi fat part_gpt normal linux all_video >"$${CFGROOT}/boot/EFI/BOOT/BOOTX64.EFI" + +_bootloader: ${CFGROOT} _grub_efi32 _grub_efi64 _syslinux_bios #_syslinux_efi32 _syslinux_efi64 + # cp -L "$${CFGROOT}/vmlinuz" "$${CFGROOT}/initrd.img" "$${CFGROOT}/boot/" + # cp -r cfg_syslinux/. "$${CFGROOT}/" + printf 'UI menu.c32\nDEFAULT stretch\nTIMEOUT 30\n' >"$${CFGROOT}/boot/bootmenu.cfg" + printf 'set timeout=3\ndefault=stretch\n\n' >"$${CFGROOT}/boot/grub.cfg" + k="$$(printf ' %s' "$${CFGROOT}/boot/"vmlinuz-*)"; k="$${k##*/}"; \ + i="$$(printf ' %s' "$${CFGROOT}/boot/"initrd.img-*)"; i="$${i##*/}"; \ + printf '\nLABEL stretch\n MENU LABEL Debian Stretch\n KERNEL /%s\n INITRD /%s\n APPEND root=LABEL=FSROOT\n' \ + "$$k" "$$i" >>"$${CFGROOT}/boot/bootmenu.cfg"; \ + printf '\nLABEL rescue\n MENU LABEL Rescue\n KERNEL /%s\n INITRD /%s\n APPEND root=LABEL=FSROOT init=/bin/sh\n' \ + "$$k" "$$i" >>"$${CFGROOT}/boot/bootmenu.cfg"; \ + printf "menuentry 'Debian Stretch' --id 'stretch' {\n linux '/%s' root=LABEL=FSROOT\n initrd '/%s'\n}\n" \ + "$$k" "$$i" >>"$${CFGROOT}/boot/grub.cfg"; \ + printf "menuentry 'Rescue' --id 'rescue' {\n linux '/%s' root=LABEL=FSROOT init=/bin/sh\n initrd '/%s'\n}\n" \ + "$$k" "$$i" >>"$${CFGROOT}/boot/grub.cfg" + +.PHONY: _syslinux_mbr _grub_mbr + +_syslinux_mbr: ${VOLUME} syslinux -t 2097152 -i "$${VOLUME}" dd conv=notrunc if=/usr/lib/syslinux/mbr/gptmbr.bin of="$${VOLUME}" +_grub_mbr: ${VOLUME} + # grub-mkimage -p / -O i386-pc fat part_gpt normal linux all_video |dd conv=notrunc of="$${VOLUME}" + +_mbr: _syslinux_mbr # _grub_mbr + _partcopy: ${VOLUME} ${PROOT} ${PBOOT} dd conv=notrunc,sparse bs=1M seek=2 if="$${PBOOT}" of="$${VOLUME}" dd conv=notrunc,sparse bs=1M seek=$$((2 + ${BOOT_MB})) if="$${PROOT}" of="$${VOLUME}" diff --git a/cfg_syslinux/boot/bootmenu.cfg b/cfg_syslinux/boot/bootmenu.cfg deleted file mode 100644 index dbebfeb..0000000 --- a/cfg_syslinux/boot/bootmenu.cfg +++ /dev/null @@ -1,16 +0,0 @@ -UI menu.c32 - -DEFAULT stretch -TIMEOUT 30 - -LABEL stretch - MENU LABEL Debian Stretch - KERNEL /vmlinuz - INITRD /initrd.img - APPEND root=LABEL=FSROOT - -LABEL stretch_rescue - MENU LABEL Debian Stretch Rescue - KERNEL /vmlinuz - INITRD /initrd.img - APPEND root=LABEL=FSROOT init=/bin/sh diff --git a/cfg_syslinux/boot/syslia32.cfg b/cfg_syslinux/boot/syslia32.cfg deleted file mode 100644 index 84e692e..0000000 --- a/cfg_syslinux/boot/syslia32.cfg +++ /dev/null @@ -1,3 +0,0 @@ -PATH /efi32 -INCLUDE /bootmenu.cfg -MENU TITLE Syslinux EFI-32 diff --git a/cfg_syslinux/boot/syslinux.cfg b/cfg_syslinux/boot/syslinux.cfg deleted file mode 100644 index b6397a5..0000000 --- a/cfg_syslinux/boot/syslinux.cfg +++ /dev/null @@ -1,3 +0,0 @@ -PATH bios -INCLUDE bootmenu.cfg -MENU TITLE Syslinux BIOS diff --git a/cfg_syslinux/boot/syslx64.cfg b/cfg_syslinux/boot/syslx64.cfg deleted file mode 100644 index 88f0ad3..0000000 --- a/cfg_syslinux/boot/syslx64.cfg +++ /dev/null @@ -1,3 +0,0 @@ -PATH /efi64 -INCLUDE /bootmenu.cfg -MENU TITLE Syslinux EFI-64 -- 2.39.2