aboutsummaryrefslogtreecommitdiff
path: root/files/firstboot/22-expandroot.sh
diff options
context:
space:
mode:
authorJan Wagner <mail@jwagner.eu>2016-04-19 15:10:50 +0200
committerJan Wagner <mail@jwagner.eu>2016-04-19 15:10:50 +0200
commitd0f91512d9ca6d361d8a4a387094c48aab00e111 (patch)
treeb00ed220e2fa04bdb1db43475a8149d01d1be5db /files/firstboot/22-expandroot.sh
parent7878e85af7748d531a64f459723dca76ee37914b (diff)
downloadrpi2-gen-image-d0f91512d9ca6d361d8a4a387094c48aab00e111.tar.gz
rpi2-gen-image-d0f91512d9ca6d361d8a4a387094c48aab00e111.tar.bz2
rpi2-gen-image-d0f91512d9ca6d361d8a4a387094c48aab00e111.zip
fix: ENABLE_CRYPTFS -> UBOOT, SPLITFS, EXPANDROOT - cleanupHEADmaster
Diffstat (limited to 'files/firstboot/22-expandroot.sh')
-rw-r--r--files/firstboot/22-expandroot.sh18
1 files changed, 15 insertions, 3 deletions
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."