Skip to content

Commit

Permalink
Check if growpart is installed before calling it
Browse files Browse the repository at this point in the history
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 <jan.dubois@suse.com>
  • Loading branch information
jandubois committed Dec 14, 2022
1 parent fc1c514 commit 038037e
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions pkg/cidata/cidata.TEMPLATE.d/boot/04-persistent-data-volume.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 038037e

Please sign in to comment.