Skip to content

Commit fc55a43

Browse files
authored
Merge pull request #1243 from rancher-sandbox/growpart
Check if growpart is installed before calling it
2 parents fc1c514 + 038037e commit fc55a43

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

pkg/cidata/cidata.TEMPLATE.d/boot/04-persistent-data-volume.sh

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,14 @@ if [ "$(awk '$2 == "/" {print $3}' /proc/mounts)" == "tmpfs" ]; then
1616
if [ -e /dev/disk/by-label/data-volume ]; then
1717
# Find which disk is data volume on
1818
DATA_DISK=$(blkid | grep "data-volume" | awk '{split($0,s,":"); sub(/\d$/, "", s[1]); print s[1]};')
19-
# Automatically expand the data volume filesystem
20-
growpart "$DATA_DISK" 1 || true
21-
# Only resize when filesystem is in a healthy state
22-
if e2fsck -f -p /dev/disk/by-label/data-volume; then
23-
resize2fs /dev/disk/by-label/data-volume
19+
# growpart command may be missing in older VMs
20+
if command -v growpart >/dev/null 2>&1 && command -v resize2fs >/dev/null 2>&1; then
21+
# Automatically expand the data volume filesystem
22+
growpart "$DATA_DISK" 1 || true
23+
# Only resize when filesystem is in a healthy state
24+
if e2fsck -f -p /dev/disk/by-label/data-volume; then
25+
resize2fs /dev/disk/by-label/data-volume || true
26+
fi
2427
fi
2528
# Mount data volume
2629
mount -t ext4 /dev/disk/by-label/data-volume /mnt/data

0 commit comments

Comments
 (0)