From: Paul Hänsch Date: Mon, 15 Jul 2019 03:49:44 +0000 (+0200) Subject: partition alignment, efi boot, improved clean target X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;h=aa5ee6a381346209a761ca84be7373483ab53d09;p=blast partition alignment, efi boot, improved clean target --- diff --git a/Makefile b/Makefile index d2493c5..e8c38c4 100644 --- a/Makefile +++ b/Makefile @@ -1,14 +1,16 @@ DEFAULT: _target -.PHONY: clean _target _qemu _partition _format _mount _bootstrap _install _sparse _copy _config _syslinux _umount _partcopy _squash _mbr +.PHONY: clean .FORCE +.PHONY: _qemu _bootstrap _install _copy _config _syslinux _squash +.PHONY: _target _partition _format _mount _sparse _umount _partcopy _mbr ARCH := amd64 KEYRING := keys/debian-archive-stretch-stable.gpg BOOTSTRAP := http://cdn.debian.net/debian -# Partition Table + Boot Partition + Root Partition = 2048M +# Partition Table (2M) + Boot Partition (126M)+ Root Partition + Slack Space (1M) = 2048M BOOT_MB := 126 -ROOT_MB := 1920 +ROOT_MB := 1919 define SOURCES = deb http://cdn.debian.net/debian stretch main @@ -182,27 +184,27 @@ ${SQUASH}: ${CFGROOT} _squash: ${SQUASH} -${VOLUME}: +${VOLUME}: .FORCE ! printf '%s\n' "$${VOLUME}" |grep -q '^/dev/' # abort if volume should be real device - dd bs=1M count=0 seek=$$((2 + ${BOOT_MB} + ${ROOT_MB})) of="$${VOLUME}" + dd bs=1M count=0 seek=$$((3 + ${BOOT_MB} + ${ROOT_MB})) of="$${VOLUME}" -${PBOOT}: +${PBOOT}: .FORCE ! printf '%s\n' "$${PBOOT}" |grep -q '^/dev/' # abort if volume should be real device dd bs=1M count=0 seek=${BOOT_MB} of="$${PBOOT}" -${PROOT}: +${PROOT}: .FORCE ! printf '%s\n' "$${PROOT}" |grep -q '^/dev/' # abort if volume should be real device dd bs=1M count=0 seek=${ROOT_MB} of="$${PROOT}" _partition: ${VOLUME} - printf 'label: gpt\n\n: start=2MiB, size=%iMiB, type=1, attrs="LegacyBIOSBootable"\n: type=20\n' \ - ${BOOT_MB} | sfdisk "$${VOLUME}" + printf 'label: gpt\n\n: start=2MiB, size=%iMiB, type=1, attrs="LegacyBIOSBootable"\n: size=%iMiB, type=20\n' \ + ${BOOT_MB} ${ROOT_MB} | sfdisk "$${VOLUME}" _sparse: ${PBOOT} ${PROOT} _format: ${PBOOT} ${PROOT} -umount "$${CFGROOT}/boot" "$${CFGROOT}" - mkfs.fat -F 32 -n boot "$${PBOOT}" + mkfs.fat -F 32 -n BOOT "$${PBOOT}" mkfs.ext4 -F -L FSROOT "$${PROOT}" .PHONY: _syslinux_efi32 _syslinux_efi64 _syslinux_bios @@ -211,12 +213,15 @@ _syslinux_efi32: ${CFGROOT} 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 _syslinux_efi64: ${CFGROOT} mkdir -p "$${CFGROOT}/boot/EFI/BOOT" cp /usr/lib/SYSLINUX.EFI/efi64/syslinux.efi "$${CFGROOT}/boot/EFI/BOOT/BOOTX64.EFI" mkdir -p "$${CFGROOT}/boot/efi64" - cp $(addprefix /usr/lib/syslinux/modules/efi64/, ldlinux.e64 menu.c32 libutil.c32) "$${CFGROOT}"/boot/efi32/ + 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 + _syslinux_bios: ${CFGROOT} mkdir -p "$${CFGROOT}/boot/bios" @@ -225,14 +230,15 @@ _syslinux_bios: ${CFGROOT} _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 _mbr: ${VOLUME} syslinux -t 2097152 -i "$${VOLUME}" dd conv=notrunc if=/usr/lib/syslinux/mbr/gptmbr.bin of="$${VOLUME}" _partcopy: ${VOLUME} ${PROOT} ${PBOOT} - dd bs=1M seek=2 if="$${PBOOT}" of="$${VOLUME}" - dd bs=1M seek=$$((2 + ${BOOT_MB})) if="$${PROOT}" of="$${VOLUME}" + 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}" _mount: ${PBOOT} ${PROOT} ${CFG_ROOT} mount -t ext4 "$${PROOT}" "$${CFGROOT}" @@ -254,11 +260,12 @@ clean: -umount hdd_mount/boot -umount hdd_mount -rmdir hdd_mount - if [ -d "sys_root/" ] && ! mount |grep -qwFe "sys_root/"; then \ - btrfs sub del "sys_root/" || echo rm -r "sys_root/"; \ - fi - if [ -d "cfg_root/" ] && ! mount |grep -qwFe "cfg_root/"; then \ - btrfs sub del "cfg_root/" || echo rm -r "cfg_root/"; \ - fi - -rm "$${SQUASH}" + if [ -d "sys_root/" ]; then btrfs sub del "sys_root/" || echo rm -r "sys_root/"; fi + if [ -d "cfg_root/" ]; then btrfs sub del "cfg_root/" || echo rm -r "cfg_root/"; fi + if [ -d "rpi_root/" ]; then btrfs sub del "rpi_root/" || echo rm -r "rpi_root/"; fi + -rm part_boot.img + -rm part_root.img + -rm rpi_boot.img + -rm rpi_root.img + -[ -f "$${SQUASH}" ] && rm "$${SQUASH}" -[ -f "$${VOLUME}" ] && rm "$${VOLUME}"