From 3e76c50ac86d1546c8e063c5511ad0e87db1593a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Paul=20H=C3=A4nsch?= Date: Sat, 7 Dec 2019 03:27:12 +0100 Subject: [PATCH] allow nilfs2 for rootfs --- Makefile | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 326d2b8..8da2961 100644 --- a/Makefile +++ b/Makefile @@ -43,6 +43,8 @@ deb http://cdn.debian.net/debian ${release} main endef endif +fstype := ext4 + ifdef disk VOLUME := ${disk} PBOOT := ${disk}1 @@ -139,7 +141,8 @@ else ifdef raspi deb http://archive.raspberrypi.org/debian ${release} main endef - PACKAGES += firmware-brcm80211 libraspberrypi-bin libraspberrypi0 pi-bluetooth raspberrypi-bootloader raspberrypi-kernel + PACKAGES += firmware-brcm80211 libraspberrypi-bin libraspberrypi0 pi-bluetooth raspberrypi-bootloader raspberrypi-kernel initramfs-tools nilfs-tools + fstype := nilfs2 _target: _umount _config @@ -251,7 +254,7 @@ _copy: ${SYSROOT} ${CFGROOT} _config: ${CFGROOT} ln -sf /dev/null "$${CFGROOT}/etc/systemd/network/99-default.link" printf '\nsession optional pam_mkhomedir.so umask=0027\n' >>"$${CFGROOT}/etc/pam.d/common-session" - printf 'LABEL=FSROOT / ext4 auto,nofail,rw 0 0\nLABEL=BOOT /boot vfat auto,nofail,ro 0 0\n' \ + printf 'LABEL=FSROOT / ${fstype} auto,nofail,rw 0 0\nLABEL=BOOT /boot vfat auto,nofail,ro 0 0\n' \ >"$${CFGROOT}/etc/fstab" chroot "$${CFGROOT}" update-initramfs -u @@ -296,9 +299,15 @@ _partition_gpt: ${VOLUME} _sparse: ${PBOOT} ${PROOT} +ifdef raspi +_format_root: ${PROOT} + -umount "$${CFGROOT}/boot" "$${CFGROOT}" "${PROOT}" + mkfs.nilfs2 -f -L FSROOT "$${PROOT}" +else _format_root: ${PROOT} -umount "$${CFGROOT}/boot" "$${CFGROOT}" "${PROOT}" mkfs.ext4 -F -L FSROOT "$${PROOT}" +endif _format_boot: ${PBOOT} -umount "$${CFGROOT}/boot" "${PBOOT}" @@ -342,7 +351,7 @@ _grub_efi64: ${CFGROOT} grub-mkimage -p / -O x86_64-efi fat part_gpt normal linux all_video >"$${CFGROOT}/boot/EFI/BOOT/BOOTX64.EFI" ${CFGROOT}/boot/cmdline.txt: ${CFGROOT} - printf 'root=/dev/mmcblk0p2 rootfstype=ext4 fsck.repair=yes rootwait' >"$@" + printf 'root=/dev/mmcblk0p2 rootfstype=${fstype} fsck.repair=yes rootwait' >"$@" _bootloader_raspi: ${CFGROOT} ${CFGROOT}/boot/cmdline.txt @@ -396,12 +405,14 @@ _partcopy: ${VOLUME} ${PROOT} ${PBOOT} dd conv=notrunc,sparse bs=1M seek=$$((2 + ${BOOT_MB})) if="$${PROOT}" of="$${VOLUME}" _mount_root: ${PROOT} ${CFGROOT} - mount -t ext4 "$${PROOT}" "$${CFGROOT}" + mountpoint "$${CFGROOT}" \ + || mount -t ${fstype} "$${PROOT}" "$${CFGROOT}" chmod 755 "$${CFGROOT}" _mount_boot: ${PBOOT} mkdir -p -m 755 "$${CFGROOT}/boot" - mount -t vfat "$${PBOOT}" "$${CFGROOT}/boot" + mountpoint "$${CFGROOT}/boot" \ + || mount -t vfat "$${PBOOT}" "$${CFGROOT}/boot" ifdef disk _mount_boot: _mount_root @@ -410,12 +421,14 @@ endif _mount: _mount_root _mount_boot _img_mount: ${CFGROOT} - mount -o loop,offset="$$((${BOOT_MB} + 2))"M,sizelimit=${ROOT_MB}M \ - -t ext4 "$${VOLUME}" "$${CFGROOT}" + mountpoint "$${CFGROOT}" \ + || mount -o loop,offset="$$((${BOOT_MB} + 2))"M,sizelimit=${ROOT_MB}M \ + -t ${fstype} "$${VOLUME}" "$${CFGROOT}" chmod 755 "$${CFGROOT}" mkdir -p -m 755 "$${CFGROOT}/boot" - mount -o loop,offset=2M,sizelimit=${BOOT_MB}M \ - -t vfat "$${VOLUME}" "$${CFGROOT}/boot" + mountpoint "$${CFGROOT}/boot" \ + || mount -o loop,offset=2M,sizelimit=${BOOT_MB}M \ + -t vfat "$${VOLUME}" "$${CFGROOT}/boot" _umount_boot: ${CFGROOT} -umount "$${CFGROOT}/boot" -- 2.39.2