Simplfied the upgrade filesystem resize logic
This commit is contained in:
@@ -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
|
|
||||||
@@ -37,7 +37,6 @@ should_resize_root_partition() {
|
|||||||
|
|
||||||
if [ "$ROOT_PART_END" -gt "$TARGET_END" ]; then
|
if [ "$ROOT_PART_END" -gt "$TARGET_END" ]; then
|
||||||
FAIL_REASON="Root partition runs past the end of device"
|
FAIL_REASON="Root partition runs past the end of device"
|
||||||
echo $FAIL_REASON
|
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -60,18 +59,9 @@ if should_resize_root_partition; then
|
|||||||
# Remove itself from /boot/cmdline.txt
|
# Remove itself from /boot/cmdline.txt
|
||||||
# Reboot the machine
|
# Reboot the machine
|
||||||
sudo mount /boot -o rw,remount
|
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
|
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
|
exit 0
|
||||||
else
|
else
|
||||||
echo "Not resizing root partition: $FAIL_REASON"
|
echo "Not resizing root partition: $FAIL_REASON"
|
||||||
|
|||||||
Reference in New Issue
Block a user