From 00b422d4c5fcdadd82c30a174357f7df38197768 Mon Sep 17 00:00:00 2001 From: David Carley Date: Thu, 8 Sep 2022 02:28:44 +0000 Subject: [PATCH] Simplfied the upgrade filesystem resize logic --- installer/scripts/resize2fs_once | 25 ------------------------- installer/scripts/resize_root_fs.sh | 12 +----------- 2 files changed, 1 insertion(+), 36 deletions(-) delete mode 100644 installer/scripts/resize2fs_once diff --git a/installer/scripts/resize2fs_once b/installer/scripts/resize2fs_once deleted file mode 100644 index 38a4d47..0000000 --- a/installer/scripts/resize2fs_once +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh -### BEGIN INIT INFO -# Provides: resize2fs_once -# Required-Start: -# Required-Stop: -# Default-Start: 3 -# Default-Stop: -# Short-Description: Resize the root filesystem to fill partition -# Description: -### END INIT INFO -. /lib/lsb/init-functions -case "$1" in - start) - log_daemon_msg "Starting resize2fs_once" - ROOT_DEV=$(findmnt / -o source -n) && - resize2fs $ROOT_DEV && - update-rc.d resize2fs_once remove && - rm /etc/init.d/resize2fs_once && - log_end_msg $? - ;; - *) - echo "Usage: $0 start" >&2 - exit 3 - ;; -esac diff --git a/installer/scripts/resize_root_fs.sh b/installer/scripts/resize_root_fs.sh index 7d60b58..51fe535 100755 --- a/installer/scripts/resize_root_fs.sh +++ b/installer/scripts/resize_root_fs.sh @@ -37,7 +37,6 @@ should_resize_root_partition() { if [ "$ROOT_PART_END" -gt "$TARGET_END" ]; then FAIL_REASON="Root partition runs past the end of device" - echo $FAIL_REASON return 1 fi @@ -60,18 +59,9 @@ if should_resize_root_partition; then # Remove itself from /boot/cmdline.txt # Reboot the machine sudo mount /boot -o rw,remount - sed -i 's/\(.*\)/\1 init=\/usr\/lib\/raspi-config\/init_resize.sh/' /boot/cmdline.txt + sed -i -E 's|(.*)|\1 init=/usr/lib/raspi-config/init_resize.sh|' /boot/cmdline.txt fi - # On the first boot after init_resize, resize2fs_once will: - # Resize the root fs to fill its partition - # Remove itself from the registered systemd services - # Delete itself from the filesystem - # Therefore, never run again - cp ./installer/scripts/resize2fs_once /etc/init.d/resize2fs_once - chmod +x /etc/init.d/resize2fs_once - systemctl enable resize2fs_once - exit 0 else echo "Not resizing root partition: $FAIL_REASON"