From a8bad54efc72012534c32476884a2e6405493dc3 Mon Sep 17 00:00:00 2001 From: Aman Gupta Karmani Date: Fri, 30 Oct 2020 13:52:24 -0700 Subject: [PATCH] automatically fsck to repair issues after an unclean shutdown (#938) * automatically fsck to repair partitions * add fsck.fat so rpi boot partition can be repaired * Use Wants= instead of Requires= Co-authored-by: Pascal Vizeli * add dosfstools to all images * run hassos-data and hassos-expand after fsck Co-authored-by: Pascal Vizeli --- buildroot-external/configs/intel_nuc_defconfig | 2 ++ buildroot-external/configs/odroid_c2_defconfig | 2 ++ buildroot-external/configs/odroid_n2_defconfig | 2 ++ buildroot-external/configs/odroid_xu4_defconfig | 2 ++ buildroot-external/configs/ova_defconfig | 2 ++ buildroot-external/configs/rpi0_w_defconfig | 2 ++ buildroot-external/configs/rpi2_defconfig | 2 ++ buildroot-external/configs/rpi3_64_defconfig | 2 ++ buildroot-external/configs/rpi3_defconfig | 2 ++ buildroot-external/configs/rpi4_64_defconfig | 2 ++ buildroot-external/configs/rpi4_defconfig | 2 ++ buildroot-external/configs/rpi_defconfig | 2 ++ buildroot-external/configs/tinker_defconfig | 2 ++ .../rootfs-overlay/usr/lib/systemd/system/hassos-data.service | 2 +- .../rootfs-overlay/usr/lib/systemd/system/hassos-expand.service | 2 +- .../rootfs-overlay/usr/lib/systemd/system/mnt-boot.mount | 2 ++ .../rootfs-overlay/usr/lib/systemd/system/mnt-data.mount | 2 ++ .../rootfs-overlay/usr/lib/systemd/system/mnt-overlay.mount | 2 ++ 18 files changed, 34 insertions(+), 2 deletions(-) diff --git a/buildroot-external/configs/intel_nuc_defconfig b/buildroot-external/configs/intel_nuc_defconfig index 9438c9fad..f530d68a3 100644 --- a/buildroot-external/configs/intel_nuc_defconfig +++ b/buildroot-external/configs/intel_nuc_defconfig @@ -106,3 +106,5 @@ BR2_PACKAGE_HASSIO=y BR2_PACKAGE_HASSIO_ARCH="amd64" BR2_PACKAGE_APPARMOR=y BR2_PACKAGE_INTEL_E1000E=y +BR2_PACKAGE_DOSFSTOOLS=y +BR2_PACKAGE_DOSFSTOOLS_FSCK_FAT=y diff --git a/buildroot-external/configs/odroid_c2_defconfig b/buildroot-external/configs/odroid_c2_defconfig index 54f15a685..352c182cf 100644 --- a/buildroot-external/configs/odroid_c2_defconfig +++ b/buildroot-external/configs/odroid_c2_defconfig @@ -100,3 +100,5 @@ BR2_PACKAGE_HASSIO_ARCH="aarch64" BR2_PACKAGE_APPARMOR=y BR2_PACKAGE_HARDKERNEL_BOOT=y BR2_PACKAGE_HARDKERNEL_BOOT_ODROID_C2=y +BR2_PACKAGE_DOSFSTOOLS=y +BR2_PACKAGE_DOSFSTOOLS_FSCK_FAT=y diff --git a/buildroot-external/configs/odroid_n2_defconfig b/buildroot-external/configs/odroid_n2_defconfig index bf50b00dd..b878aa70d 100644 --- a/buildroot-external/configs/odroid_n2_defconfig +++ b/buildroot-external/configs/odroid_n2_defconfig @@ -100,3 +100,5 @@ BR2_PACKAGE_HASSIO_ARCH="aarch64" BR2_PACKAGE_APPARMOR=y BR2_PACKAGE_HARDKERNEL_BOOT=y BR2_PACKAGE_HARDKERNEL_BOOT_ODROID_N2=y +BR2_PACKAGE_DOSFSTOOLS=y +BR2_PACKAGE_DOSFSTOOLS_FSCK_FAT=y diff --git a/buildroot-external/configs/odroid_xu4_defconfig b/buildroot-external/configs/odroid_xu4_defconfig index 1a3e27d6b..a7684197e 100644 --- a/buildroot-external/configs/odroid_xu4_defconfig +++ b/buildroot-external/configs/odroid_xu4_defconfig @@ -104,3 +104,5 @@ BR2_PACKAGE_HASSIO_ARCH="armv7" BR2_PACKAGE_APPARMOR=y BR2_PACKAGE_HARDKERNEL_BOOT=y BR2_PACKAGE_HARDKERNEL_BOOT_ODROID_XU4=y +BR2_PACKAGE_DOSFSTOOLS=y +BR2_PACKAGE_DOSFSTOOLS_FSCK_FAT=y diff --git a/buildroot-external/configs/ova_defconfig b/buildroot-external/configs/ova_defconfig index 9352d9082..429953d6e 100644 --- a/buildroot-external/configs/ova_defconfig +++ b/buildroot-external/configs/ova_defconfig @@ -96,3 +96,5 @@ BR2_PACKAGE_HOST_RAUC=y BR2_PACKAGE_HASSIO=y BR2_PACKAGE_HASSIO_ARCH="amd64" BR2_PACKAGE_APPARMOR=y +BR2_PACKAGE_DOSFSTOOLS=y +BR2_PACKAGE_DOSFSTOOLS_FSCK_FAT=y diff --git a/buildroot-external/configs/rpi0_w_defconfig b/buildroot-external/configs/rpi0_w_defconfig index 1d16878c4..bd3550b86 100644 --- a/buildroot-external/configs/rpi0_w_defconfig +++ b/buildroot-external/configs/rpi0_w_defconfig @@ -102,3 +102,5 @@ BR2_PACKAGE_HASSIO=y BR2_PACKAGE_HASSIO_ARCH="armhf" BR2_PACKAGE_APPARMOR=y BR2_PACKAGE_BLUETOOTH_BCM43XX=y +BR2_PACKAGE_DOSFSTOOLS=y +BR2_PACKAGE_DOSFSTOOLS_FSCK_FAT=y diff --git a/buildroot-external/configs/rpi2_defconfig b/buildroot-external/configs/rpi2_defconfig index c3cc91216..c9121e3ac 100644 --- a/buildroot-external/configs/rpi2_defconfig +++ b/buildroot-external/configs/rpi2_defconfig @@ -100,3 +100,5 @@ BR2_PACKAGE_HOST_RAUC=y BR2_PACKAGE_HASSIO=y BR2_PACKAGE_HASSIO_ARCH="armv7" BR2_PACKAGE_APPARMOR=y +BR2_PACKAGE_DOSFSTOOLS=y +BR2_PACKAGE_DOSFSTOOLS_FSCK_FAT=y diff --git a/buildroot-external/configs/rpi3_64_defconfig b/buildroot-external/configs/rpi3_64_defconfig index 8f3c71945..8fa1b1aea 100644 --- a/buildroot-external/configs/rpi3_64_defconfig +++ b/buildroot-external/configs/rpi3_64_defconfig @@ -102,3 +102,5 @@ BR2_PACKAGE_HASSIO=y BR2_PACKAGE_HASSIO_ARCH="aarch64" BR2_PACKAGE_APPARMOR=y BR2_PACKAGE_BLUETOOTH_BCM43XX=y +BR2_PACKAGE_DOSFSTOOLS=y +BR2_PACKAGE_DOSFSTOOLS_FSCK_FAT=y diff --git a/buildroot-external/configs/rpi3_defconfig b/buildroot-external/configs/rpi3_defconfig index ac522f5bb..5c6d69218 100644 --- a/buildroot-external/configs/rpi3_defconfig +++ b/buildroot-external/configs/rpi3_defconfig @@ -102,3 +102,5 @@ BR2_PACKAGE_HASSIO=y BR2_PACKAGE_HASSIO_ARCH="armv7" BR2_PACKAGE_APPARMOR=y BR2_PACKAGE_BLUETOOTH_BCM43XX=y +BR2_PACKAGE_DOSFSTOOLS=y +BR2_PACKAGE_DOSFSTOOLS_FSCK_FAT=y diff --git a/buildroot-external/configs/rpi4_64_defconfig b/buildroot-external/configs/rpi4_64_defconfig index a3f45cf27..bccc0af12 100644 --- a/buildroot-external/configs/rpi4_64_defconfig +++ b/buildroot-external/configs/rpi4_64_defconfig @@ -103,3 +103,5 @@ BR2_PACKAGE_HASSIO=y BR2_PACKAGE_HASSIO_ARCH="aarch64" BR2_PACKAGE_APPARMOR=y BR2_PACKAGE_BLUETOOTH_BCM43XX=y +BR2_PACKAGE_DOSFSTOOLS=y +BR2_PACKAGE_DOSFSTOOLS_FSCK_FAT=y diff --git a/buildroot-external/configs/rpi4_defconfig b/buildroot-external/configs/rpi4_defconfig index 35845f48d..ce15052b5 100644 --- a/buildroot-external/configs/rpi4_defconfig +++ b/buildroot-external/configs/rpi4_defconfig @@ -103,3 +103,5 @@ BR2_PACKAGE_HASSIO=y BR2_PACKAGE_HASSIO_ARCH="armv7" BR2_PACKAGE_APPARMOR=y BR2_PACKAGE_BLUETOOTH_BCM43XX=y +BR2_PACKAGE_DOSFSTOOLS=y +BR2_PACKAGE_DOSFSTOOLS_FSCK_FAT=y diff --git a/buildroot-external/configs/rpi_defconfig b/buildroot-external/configs/rpi_defconfig index 099b0a154..e38bb9bc3 100644 --- a/buildroot-external/configs/rpi_defconfig +++ b/buildroot-external/configs/rpi_defconfig @@ -100,3 +100,5 @@ BR2_PACKAGE_HOST_RAUC=y BR2_PACKAGE_HASSIO=y BR2_PACKAGE_HASSIO_ARCH="armhf" BR2_PACKAGE_APPARMOR=y +BR2_PACKAGE_DOSFSTOOLS=y +BR2_PACKAGE_DOSFSTOOLS_FSCK_FAT=y diff --git a/buildroot-external/configs/tinker_defconfig b/buildroot-external/configs/tinker_defconfig index beafc5e41..1be2cf91a 100644 --- a/buildroot-external/configs/tinker_defconfig +++ b/buildroot-external/configs/tinker_defconfig @@ -108,3 +108,5 @@ BR2_PACKAGE_HASSIO=y BR2_PACKAGE_HASSIO_ARCH="armv7" BR2_PACKAGE_APPARMOR=y BR2_PACKAGE_BLUETOOTH_RTL8723=y +BR2_PACKAGE_DOSFSTOOLS=y +BR2_PACKAGE_DOSFSTOOLS_FSCK_FAT=y diff --git a/buildroot-external/rootfs-overlay/usr/lib/systemd/system/hassos-data.service b/buildroot-external/rootfs-overlay/usr/lib/systemd/system/hassos-data.service index 2b1978ddf..847ffe9c5 100644 --- a/buildroot-external/rootfs-overlay/usr/lib/systemd/system/hassos-data.service +++ b/buildroot-external/rootfs-overlay/usr/lib/systemd/system/hassos-data.service @@ -5,7 +5,7 @@ RefuseManualStart=true RefuseManualStop=true Requires=mnt-overlay.mount dev-disk-by\x2dlabel-hassos\x2ddata.device Wants=hassos-expand.service -After=mnt-overlay.mount dev-disk-by\x2dlabel-hassos\x2ddata.device +After=mnt-overlay.mount dev-disk-by\x2dlabel-hassos\x2ddata.device systemd-fsck@dev-disk-by\x2dlabel-hassos\x2ddata.service Before=hassos-expand.service ConditionPathExists=/mnt/overlay/data.opt diff --git a/buildroot-external/rootfs-overlay/usr/lib/systemd/system/hassos-expand.service b/buildroot-external/rootfs-overlay/usr/lib/systemd/system/hassos-expand.service index a847f9f9a..1680930df 100644 --- a/buildroot-external/rootfs-overlay/usr/lib/systemd/system/hassos-expand.service +++ b/buildroot-external/rootfs-overlay/usr/lib/systemd/system/hassos-expand.service @@ -5,7 +5,7 @@ Before=mnt-data.mount RefuseManualStart=true RefuseManualStop=true Requires=dev-disk-by\x2dlabel-hassos\x2ddata.device -After=dev-disk-by\x2dlabel-hassos\x2ddata.device +After=dev-disk-by\x2dlabel-hassos\x2ddata.device systemd-fsck@dev-disk-by\x2dlabel-hassos\x2ddata.service [Service] Type=oneshot diff --git a/buildroot-external/rootfs-overlay/usr/lib/systemd/system/mnt-boot.mount b/buildroot-external/rootfs-overlay/usr/lib/systemd/system/mnt-boot.mount index 18cfdd584..c2008cd5d 100644 --- a/buildroot-external/rootfs-overlay/usr/lib/systemd/system/mnt-boot.mount +++ b/buildroot-external/rootfs-overlay/usr/lib/systemd/system/mnt-boot.mount @@ -3,6 +3,8 @@ Description=HassOS boot partition DefaultDependencies=no Before=umount.target local-fs.target Conflicts=umount.target +After=systemd-fsck@dev-disk-by\x2dlabel-hassos\x2dboot.service +Wants=systemd-fsck@dev-disk-by\x2dlabel-hassos\x2dboot.service [Mount] What=/dev/disk/by-label/hassos-boot diff --git a/buildroot-external/rootfs-overlay/usr/lib/systemd/system/mnt-data.mount b/buildroot-external/rootfs-overlay/usr/lib/systemd/system/mnt-data.mount index 4c71e12e3..cb38aff6e 100644 --- a/buildroot-external/rootfs-overlay/usr/lib/systemd/system/mnt-data.mount +++ b/buildroot-external/rootfs-overlay/usr/lib/systemd/system/mnt-data.mount @@ -5,6 +5,8 @@ DefaultDependencies=no After=hassos-expand.service Before=umount.target local-fs.target Conflicts=umount.target +After=systemd-fsck@dev-disk-by\x2dlabel-hassos\x2ddata.service +Wants=systemd-fsck@dev-disk-by\x2dlabel-hassos\x2ddata.service [Mount] What=/dev/disk/by-label/hassos-data diff --git a/buildroot-external/rootfs-overlay/usr/lib/systemd/system/mnt-overlay.mount b/buildroot-external/rootfs-overlay/usr/lib/systemd/system/mnt-overlay.mount index 21c633faa..76e555ae8 100644 --- a/buildroot-external/rootfs-overlay/usr/lib/systemd/system/mnt-overlay.mount +++ b/buildroot-external/rootfs-overlay/usr/lib/systemd/system/mnt-overlay.mount @@ -3,6 +3,8 @@ Description=HassOS overlay partition DefaultDependencies=no Before=umount.target local-fs.target Conflicts=umount.target +After=systemd-fsck@dev-disk-by\x2dlabel-hassos\x2doverlay.service +Wants=systemd-fsck@dev-disk-by\x2dlabel-hassos\x2doverlay.service [Mount] What=/dev/disk/by-label/hassos-overlay