From d4994e68408f7a715d7741b25fcf9c8332b09414 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Tue, 26 Jun 2018 13:47:39 -0400 Subject: [PATCH] c-s-s: Support GROWPART=true on NVMe By using sysfs, splitting device/partition is a lot more reliable. This fixes using GROWPART=true on NVMe with Fedora Atomic Host, as occurs in AWS with modern instance types. Closes: https://github.com/openshift/os/issues/133 --- container-storage-setup.sh | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/container-storage-setup.sh b/container-storage-setup.sh index b7c1a54..5ebb45c 100755 --- a/container-storage-setup.sh +++ b/container-storage-setup.sh @@ -727,8 +727,20 @@ grow_root_pvs() { # partitions on all disks, so as long as they match, growing the LV should # also work. for pv in $_ROOT_PVS; do - # Split device & partition. Ick. - growpart $( echo $pv | sed -r 's/([^0-9]*)([0-9]+)/\1 \2/' ) || true + if ! test -b $pv; then + Error "Not a block device: $pv" + fi + local major_hex minor_hex major_minor + local devpath partition parent_path parent_device + major_hex=$(stat -c '%t' $pv) + minor_hex=$(stat -c '%T' $pv) + major_minor=$((0x${major_hex})):$((0x${minor_hex})) + devpath=$(realpath /sys/dev/block/$major_minor) + partition=$(cat $devpath/partition) + parent_path=$(dirname $devpath) + parent_device=/dev/$(basename ${parent_path}) + # TODO: Remove the || true here + growpart ${parent_device} ${partition} || true pvresize $pv done }