From 061cf8be3c2f777715036b2b822f9f47582e3627 Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Sat, 11 Sep 2021 03:33:13 -0700 Subject: [PATCH] updater: Implement facility to resize data partition In some cases, we do not want to repartition the disk but only resize the data partition to expand into full SD card. This will be useful in cases where SD card based rootfs is used and does not have second media to install from. Implements https://github.com/YoeDistro/yoe-distro/issues/579 Signed-off-by: Khem Raj --- .../updater/files/updater.installer | 26 +++++++++++++++++++ .../recipes-support/updater/updater_1.0.bb | 3 +++ 2 files changed, 29 insertions(+) diff --git a/sources/meta-yoe/recipes-support/updater/files/updater.installer b/sources/meta-yoe/recipes-support/updater/files/updater.installer index 684b71b1c..9c09b4146 100644 --- a/sources/meta-yoe/recipes-support/updater/files/updater.installer +++ b/sources/meta-yoe/recipes-support/updater/files/updater.installer @@ -97,6 +97,24 @@ initialize() { mkdir -p $DATA_MOUNT_POINT } +resize_sd() { + echo "Resizing data partition started ..." || return 1 + if [ -z "$1" ]; then + DEVICE=$SD_DEVICE + else + DEVICE=$1 + fi + sync + umount ${DEVICE}p3 + PART_SIZE=$(cat "/sys/block/${DEVICE}p3/size") + # only continue if partition size is 1MB + if [ $PART_SIZE -gt 2048 ]; then + return 0 + fi + echo "- +" | sfdisk -N 3 ${DEVICE} + resize2fs ${DEVICE}p3 +} + partition_sd() { echo "Partitioning started ..." || return 1 if [ -z "$1" ]; then @@ -178,6 +196,10 @@ partition_emmc() { partition_sd $EMMC_DEVICE } +resize_emmc() { + resize_sd $EMMC_DEVICE +} + format_emmc_boot() { mkfs.${BOOT_FSTYPE} -I -n "BOOT" $EMMC_BOOT_DEV || return 1 } @@ -484,6 +506,10 @@ boot() { umount_usb umount_sd umount_data + if ! resize_${STORAGE}; then + msg_splash "Resizing ${STORAGE} failed, bad media" + sleep 9999d + fi if [ -e $EMMC_BOOT_DEV ]; then msg_splash "Booting from EMMC ..." diff --git a/sources/meta-yoe/recipes-support/updater/updater_1.0.bb b/sources/meta-yoe/recipes-support/updater/updater_1.0.bb index 8ce91e349..b73df802e 100644 --- a/sources/meta-yoe/recipes-support/updater/updater_1.0.bb +++ b/sources/meta-yoe/recipes-support/updater/updater_1.0.bb @@ -19,3 +19,6 @@ do_install() { } FILES:${PN} += "/init /platform /dev ${datadir}" + +RDEPENDS:${PN} += "e2fsprogs-resize2fs util-linux-sfdisk" +