From 2be09187dc5a8f5b52aef06a1077ac450aa9c92b Mon Sep 17 00:00:00 2001 From: mglae Date: Tue, 23 Oct 2018 18:50:57 +0200 Subject: [PATCH] fs-resize: simplify using parted's 3.2 'resizepart' --- packages/sysutils/busybox/scripts/fs-resize | 36 ++++++++------------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/packages/sysutils/busybox/scripts/fs-resize b/packages/sysutils/busybox/scripts/fs-resize index cb72661fdd..6be1d3e6ef 100755 --- a/packages/sysutils/busybox/scripts/fs-resize +++ b/packages/sysutils/busybox/scripts/fs-resize @@ -36,31 +36,23 @@ if [ -e /storage/.please_resize_me ] ; then # just in case if [ ! -z "$DISK" -a ! -z "$PART" ] ; then - # get storage partition start - PART_START=$(parted -s -m $DISK unit b print 2>/dev/null | grep -v ^/dev | grep -v BYT | grep ^2: | cut -f2 -d ":") + umount $PART - # failed to get partition start offset ? - if [ ! -z "$PART_START" ] ; then - umount $PART + echo "PARTITION RESIZING IN PROGRESS" + echo "" + echo "Please do not reboot or turn off your @DISTRONAME@ device!" + echo "" - echo "PARTITION RESIZING IN PROGRESS" - echo "" - echo "Please do not reboot or turn off your @DISTRONAME@ device!" - echo "" - - # identify the partition scheme, and if gpt fix minor issues such as gpt header not at end of disk - SCHEME=$(blkid -s PTTYPE -o value $DISK) - if [ "$SCHEME" = "gpt" ]; then - StartProgress spinner "Checking layout... " "sgdisk -e $DISK &>/dev/null" - fi - - StartProgress spinner "Deleting /storage... " "parted -s -m $DISK rm 2 &>/dev/null" - StartProgress spinner "Creating /storage... " "parted -s -m $DISK unit b mkpart primary $PART_START 100% &>/dev/null" - StartProgress spinner "Checking /storage... " "e2fsck -f -p $PART &>/dev/null" - StartProgress spinner "Resizing /storage... " "resize2fs $PART &>/dev/null" - - StartProgress countdown "Rebooting in 15s... " 15 "NOW" + # identify the partition scheme, and if gpt fix minor issues such as gpt header not at end of disk + SCHEME=$(blkid -s PTTYPE -o value $DISK) + if [ "$SCHEME" = "gpt" ]; then + StartProgress spinner "Checking layout... " "sgdisk -e $DISK &>/dev/null" fi + + StartProgress spinner "Resizing partition... " "parted -s -m $DISK resizepart 2 100% &>/dev/null" + StartProgress spinner "Checking file system... " "e2fsck -f -p $PART &>/dev/null" + StartProgress spinner "Resizing file system... " "resize2fs $PART &>/dev/null" + StartProgress countdown "Rebooting in 15s... " 15 "NOW" fi fi reboot -f &>/dev/null