Skip to content

Commit

Permalink
updater: Implement facility to resize data partition
Browse files Browse the repository at this point in the history
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 #579

Signed-off-by: Khem Raj <[email protected]>
  • Loading branch information
kraj committed Sep 11, 2021
1 parent 1c56171 commit 061cf8b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
26 changes: 26 additions & 0 deletions sources/meta-yoe/recipes-support/updater/files/updater.installer
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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 ..."
Expand Down
3 changes: 3 additions & 0 deletions sources/meta-yoe/recipes-support/updater/updater_1.0.bb
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ do_install() {
}

FILES:${PN} += "/init /platform /dev ${datadir}"

RDEPENDS:${PN} += "e2fsprogs-resize2fs util-linux-sfdisk"

0 comments on commit 061cf8b

Please sign in to comment.