Skip to content

add migrant resize subcommand for growing the VM disk#11

Open
brett wants to merge 1 commit into
pigmonkey:masterfrom
brett:resize-disk
Open

add migrant resize subcommand for growing the VM disk#11
brett wants to merge 1 commit into
pigmonkey:masterfrom
brett:resize-disk

Conversation

@brett

@brett brett commented Jun 23, 2026

Copy link
Copy Markdown
Contributor
  • Grows the VM's disk to match DISK_GB, then grows the in-guest partition and filesystem live over SSH — no reboot.
  • Requires the VM to be running: the playbooks disable cloud-init after first boot (/etc/cloud/cloud-init.disabled), so cloud-init's growpart can't run on a reboot to do this for us.
  • Picks the filesystem grow tool from the live FSTYPE (btrfs / xfs / ext2-4), so it isn't tied to one layout. Missing growpart is reported with an install hint.
  • Stays unprivileged: the disk grows via virsh blockresize and the current size is read via virsh domblkinfo, both through libvirtd, so the command never opens the root/libvirt-qemu-owned image file directly.
  • Won't shrink — that needs an in-guest filesystem shrink first, so destroy && up is the supported path.
  • Re-running on a disk that was already grown but never expanded in-guest repairs it (doubles as a recovery path).

Reads DISK_GB from the Migrantfile and grows the VM's disk to match. The
VM must be running: the disk is grown live with `virsh blockresize`, then
the in-guest partition and filesystem are grown over SSH.

Doing it in-guest is necessary because the Ansible playbooks disable
cloud-init after first boot (/etc/cloud/cloud-init.disabled), so
cloud-init's growpart cannot extend the partition on a later reboot. The
remote script derives the root device, partition number, and filesystem
type from the live system, so it handles btrfs/xfs/ext rather than
assuming a layout. growpart's absence is reported with an install hint.

Refuses to shrink, since that needs in-guest fs+partition shrinks first.
If the disk image is already at DISK_GB but the guest never caught up, it
still grows the in-guest filesystem, doubling as a recovery path.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant