Add Veritas VxVM and VCS storage expansion toolkit
This commit is contained in:
+81
@@ -0,0 +1,81 @@
|
||||
#!/usr/bin/env bash
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
# shellcheck source=00_env.sh
|
||||
source "$SCRIPT_DIR/00_env.sh"
|
||||
|
||||
parse_common_args "$@"
|
||||
require_inputs dg vol mount size
|
||||
|
||||
missing=0
|
||||
for cmd in vxdg vxprint vxassist df findmnt; do
|
||||
require_cmd "$cmd" || missing=1
|
||||
done
|
||||
|
||||
if (( missing != 0 )); then
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if [[ ! "$SIZE" =~ ^\+[0-9]+[KkMmGgTtPp]?$ ]]; then
|
||||
critical "invalid --size '$SIZE'; use a grow-by value such as +10G"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
status=0
|
||||
vxdg list "$DISKGROUP" >/dev/null 2>&1 || { critical "diskgroup not found: $DISKGROUP"; status=1; }
|
||||
vxprint -g "$DISKGROUP" "$VOLUME" >/dev/null 2>&1 || { critical "volume not found: $VOLUME"; status=1; }
|
||||
findmnt --target "$MOUNTPOINT" >/dev/null 2>&1 || { critical "mountpoint is not mounted: $MOUNTPOINT"; status=1; }
|
||||
|
||||
if (( status != 0 )); then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
fs_type="$(findmnt --noheadings --output FSTYPE --target "$MOUNTPOINT" | awk 'NR == 1 {print $1}')"
|
||||
device="$(findmnt --noheadings --output SOURCE --target "$MOUNTPOINT" | awk 'NR == 1 {print $1}')"
|
||||
ok "filesystem type: ${fs_type:-unknown}"
|
||||
ok "mounted device: ${device:-unknown}"
|
||||
|
||||
capture_cmd "Filesystem usage before expansion" df -h "$MOUNTPOINT"
|
||||
capture_cmd "VxVM layout before volume expansion" vxprint -g "$DISKGROUP" -ht
|
||||
|
||||
confirm_execute "This will grow VxVM volume '$VOLUME' in diskgroup '$DISKGROUP' by '$SIZE'."
|
||||
run_cmd "Grow VxVM volume by requested size" vxassist -g "$DISKGROUP" growby "$VOLUME" "$SIZE"
|
||||
|
||||
case "$fs_type" in
|
||||
vxfs)
|
||||
warning "VxFS fsadm syntax can vary by Veritas release and site standard"
|
||||
warning "manual filesystem resize recommended after volume growth; review a command such as: fsadm -F vxfs -b <new_size_or_supported_option> $MOUNTPOINT"
|
||||
;;
|
||||
xfs)
|
||||
if has_cmd xfs_growfs; then
|
||||
run_cmd "Resize XFS filesystem online" xfs_growfs "$MOUNTPOINT"
|
||||
else
|
||||
critical "xfs_growfs not found; cannot resize XFS safely"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
ext3|ext4)
|
||||
if has_cmd resize2fs; then
|
||||
if [[ -n "$device" ]]; then
|
||||
run_cmd "Resize ext filesystem" resize2fs "$device"
|
||||
else
|
||||
critical "unable to detect mounted device for resize2fs"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
critical "resize2fs not found; cannot resize ext filesystem safely"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
warning "unsupported or unknown filesystem type '$fs_type'; volume growth command was handled according to dry-run/execute mode"
|
||||
warning "manual filesystem resize required after confirming platform-specific procedure"
|
||||
;;
|
||||
esac
|
||||
|
||||
capture_cmd "Filesystem usage after expansion attempt" df -h "$MOUNTPOINT"
|
||||
capture_cmd "VxVM layout after volume expansion attempt" vxprint -g "$DISKGROUP" -ht
|
||||
ok "volume and filesystem expansion step completed"
|
||||
Reference in New Issue
Block a user