From 038037e3e99d1a63f1c67c96bb5164f2be9ca5c3 Mon Sep 17 00:00:00 2001 From: Jan Dubois Date: Tue, 13 Dec 2022 19:10:47 -0800 Subject: [PATCH] Check if growpart is installed before calling it Both `cloud-utils-growpart` (for `growpart`) and `e2fsprogs-extra` (for `resize2fs`) have only been recently added to alpine-lima. Running an existing VM based on an older Alpine ISO will then fail the boot script calling utilities that have not been installed. Signed-off-by: Jan Dubois --- .../boot/04-persistent-data-volume.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/pkg/cidata/cidata.TEMPLATE.d/boot/04-persistent-data-volume.sh b/pkg/cidata/cidata.TEMPLATE.d/boot/04-persistent-data-volume.sh index b4d479cdd77..8d6586d47aa 100644 --- a/pkg/cidata/cidata.TEMPLATE.d/boot/04-persistent-data-volume.sh +++ b/pkg/cidata/cidata.TEMPLATE.d/boot/04-persistent-data-volume.sh @@ -16,11 +16,14 @@ if [ "$(awk '$2 == "/" {print $3}' /proc/mounts)" == "tmpfs" ]; then if [ -e /dev/disk/by-label/data-volume ]; then # Find which disk is data volume on DATA_DISK=$(blkid | grep "data-volume" | awk '{split($0,s,":"); sub(/\d$/, "", s[1]); print s[1]};') - # Automatically expand the data volume filesystem - growpart "$DATA_DISK" 1 || true - # Only resize when filesystem is in a healthy state - if e2fsck -f -p /dev/disk/by-label/data-volume; then - resize2fs /dev/disk/by-label/data-volume + # growpart command may be missing in older VMs + if command -v growpart >/dev/null 2>&1 && command -v resize2fs >/dev/null 2>&1; then + # Automatically expand the data volume filesystem + growpart "$DATA_DISK" 1 || true + # Only resize when filesystem is in a healthy state + if e2fsck -f -p /dev/disk/by-label/data-volume; then + resize2fs /dev/disk/by-label/data-volume || true + fi fi # Mount data volume mount -t ext4 /dev/disk/by-label/data-volume /mnt/data