From 858fc3db3097e15c96dccbf3a740de02ae3e1f99 Mon Sep 17 00:00:00 2001 From: Gregory Haynes Date: Sun, 20 Dec 2015 08:23:54 +0000 Subject: [PATCH] Fix growroot device detection We are incorrectly detecting major/minor device numbers for the growroot rootfs. This can also be simplified by querying udev for partition information. Change-Id: I68059bf11f2563872f6b4d0e23fa09a15de980a8 --- elements/growroot/static/usr/local/sbin/growroot | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/elements/growroot/static/usr/local/sbin/growroot b/elements/growroot/static/usr/local/sbin/growroot index dfd85f54..7600a9db 100755 --- a/elements/growroot/static/usr/local/sbin/growroot +++ b/elements/growroot/static/usr/local/sbin/growroot @@ -5,18 +5,12 @@ set -exu set -o pipefail root_dev=$(df -P / | tail -n 1 | awk '/.*/ { print $1 }') -minor_dev_no=$(stat --printf="%T" $root_dev) -major_dev_no=$(stat --printf="%t" $root_dev) -# The last digit of our minor number should, on a partitioned block device, -# be the partition number of the device (starting at 1). We need to convert -# this value to decimal from hex for use in growpart. -part_no=$(echo $minor_dev_no | tail -c 2) -part_no=$((16#$part_no)) - -disk=$(find /sys/dev/block -name "$((16#$major_dev_no)):${minor_dev_no::-1}0") +disk=$(find /sys/dev/block -name $(udevadm info --query=all --name $root_dev | grep ID_PART_ENTRY_DISK | cut -d= -f2)) disk="/dev/$(source ${disk}/uevent; echo $DEVNAME)" +part_no=$(udevadm info --query=all --name $root_dev | grep ID_PART_ENTRY_NUMBER | cut -d= -f2) + set +e growpart $disk $part_no # Error code 1 means no change