From d0f91512d9ca6d361d8a4a387094c48aab00e111 Mon Sep 17 00:00:00 2001 From: Jan Wagner Date: Tue, 19 Apr 2016 15:10:50 +0200 Subject: fix: ENABLE_CRYPTFS -> UBOOT, SPLITFS, EXPANDROOT - cleanup --- files/firstboot/22-expandroot.sh | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'files/firstboot/22-expandroot.sh') diff --git a/files/firstboot/22-expandroot.sh b/files/firstboot/22-expandroot.sh index 03ec50d..235c411 100644 --- a/files/firstboot/22-expandroot.sh +++ b/files/firstboot/22-expandroot.sh @@ -1,10 +1,20 @@ -logger -t "rc.firstboot" "Expanding root" +logger -t "rc.firstboot" "Expanding root partition" + +# Detect root partition device ROOT_PART=$(mount | sed -n 's|^/dev/\(.*\) on / .*|\1|p') -PART_NUM=$(echo ${ROOT_PART} | grep -o '[1-9][0-9]*$') +if [ -z "$ROOT_PART" ] ; then + log_warning_msg "unable to detect root partition device" + return 1 +fi + +# Extract root device name case "${ROOT_PART}" in mmcblk0*) ROOT_DEV=mmcblk0 ;; sda*) ROOT_DEV=sda ;; esac + +# Check detected root partition name +PART_NUM=$(echo ${ROOT_PART} | grep -o '[1-9][0-9]*$') if [ "$PART_NUM" = "$ROOT_PART" ] ; then logger -t "rc.firstboot" "$ROOT_PART is not an SD card. Don't know how to expand" return 0 @@ -16,6 +26,8 @@ if [ "$PART_NUM" -gt 2 ] ; then logger -t "rc.firstboot" "Your partition layout is not currently supported by this tool." return 0 fi + +# Check if last partition number LAST_PART_NUM=$(parted /dev/${ROOT_DEV} -ms unit s p | tail -n 1 | cut -f 1 -d:) if [ $LAST_PART_NUM -ne $PART_NUM ]; then logger -t "rc.firstboot" "$ROOT_PART is not the last partition. Don't know how to expand" @@ -53,4 +65,4 @@ EOF2 # Reload the partition table, resize root filesystem then remove resizing code from this file partprobe && resize2fs /dev/${ROOT_PART} && - logger -t "rc.firstboot" "Root partition successfuly resized." + logger -t "rc.firstboot" "Root partition successfully resized." -- cgit v1.2.3