Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check if growpart is installed before calling it #1243

Merged
merged 1 commit into from
Dec 14, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not new in this PR, but the final exit code of the script should be set to non-zero when growpart fails

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(This can be another PR in the future)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does it make a difference; won't the failure of growpart (or resize2fs) show up in the cloud-init log anyways?

Please file an issue if you think this is really necessary; I won't have time for it until after the holidays, and will probably forget by then...

# 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