Page MenuHomeSoftware Heritage

size down moma VM, now that it no longer hosts rabbitmq
Closed, MigratedEdits Locked

Event Timeline

olasd claimed this task.
olasd added a subscriber: olasd.

moma has now been shrunk to 20GiB.

Steps:

  • Shut down the VM
  • Add partitions mappings for the moma disk on beaubourg : kpartx -a -p -part /dev/mapper/drbdvg-vm--103--disk--2
  • Shrink the ext4 partition to its minimum size
e2fsck -f /dev/mapper/drbdvg-vm--103--disk--2-part1
resize2fs -M /dev/mapper/drbdvg-vm--103--disk--2-part1

resize2fs tells you the new size of the partition (in that case, 1488401 4k blocks = 5815 MiB)

  • Remove partition mappings : kpartx -d -p -part /dev/mapper/drbdvg-vm--103--disk--2
  • Shrink the disk partition with fdisk : remove the partition, create a new partition with the same start offset and a size between the resize2fs size and the target disk size (in that case, I chose +15G)
  • Shrink the LVM volume to the target size : lvresize -L 20G drbdvg/vm-103-disk-2
  • Increase the disk partition size with fdisk to match the disk : remove and create again, using defaults
  • Recreate the partition mappings with kpartx
  • Increase the ext4 partition size with fsck + resize2fs
  • Remove the partition mappings
  • Update the VM configuration in /etc/pve with the new disk size
  • Reboot the VM.