diskimage-builder/diskimage_builder/elements/growvols/post-install.d/80-growvols
Steve Baker a6e0bf83db Add a growvols utility for growing LVM volumes
There is currently no automated way of growing LVM volumes on boot
like single partition images do with their growroot mechanism. This
lack likely contributes to LVM not being widely used on VM and
baremetal workloads, since growing to the full disk requires workload
knowledge to determine which volumes to grow and by what amount.

The growvols element contributes a growvols python script which can be
run on firstboot (via systemd or cloud-init) or manually via
automation such as ansible. It is also an interactive script which
displays the full list of modifying commands before prompting for
confirmation to run them all.

By default the script will grow the root volume, but arguments allow
any volume to grow by a specified amount, or a percentage of the
available disk space.

Blueprint: whole-disk-default
Change-Id: Idcf774384e56cce03e56c0e19c7d08a768606399
2021-07-01 11:16:31 +12:00

29 lines
686 B
Bash
Executable file

#!/bin/bash
if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then
set -x
fi
set -eu
set -o pipefail
case ${DIB_GROWVOLS_TRIGGER} in
manual) echo "growvols triggered manually after boot"; exit ;;
systemd) echo "growvols triggered by systemd" ;;
*) echo "Unsupported DIB_GROWVOLS_TRIGGER: ${DIB_GROWVOLS_TRIGGER}"; exit 1 ;;
esac
cat << EOF | sudo tee /etc/sysconfig/growvols > /dev/null
GROWVOLS_ARGS="${DIB_GROWVOLS_ARGS}"
GROWVOLS_GROUP="${DIB_GROWVOLS_GROUP}"
GROWVOLS_DEVICE="${DIB_GROWVOLS_DEVICE}"
EOF
case "$DIB_INIT_SYSTEM" in
systemd)
systemctl enable growvols.service
;;
*)
echo "Unsupported init system"
exit 1
;;
esac