diskimage-builder/elements/growroot/static/usr/local/sbin/growroot
Gregory Haynes 858fc3db30 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
2015-12-20 08:23:54 +00:00

20 lines
595 B
Bash
Executable file

#!/bin/bash
# dib-lint: disable=dibdebugtrace
set -exu
set -o pipefail
root_dev=$(df -P / | tail -n 1 | awk '/.*/ { print $1 }')
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
if [ "$?" -le 1 ]; then
# always return true because this might not work if were are non ext4
resize2fs $root_dev || true
fi