In-place VM disk expand

From OpenVZ Virtuozzo Containers Wiki
Jump to: navigation, search

Feature[edit]

prl_disk_tool resize --resize_partition /in-place VM disk expand

Description[edit]

the prl_disk_tool utility now can expand VM disks in-place.

prl_disk_tool resize worked in-place even before prl_disk_tool resize --resize_partition now expands disk, last partition (in case of logical paritition, the extended container as well) and its filesystem.

As before, you will need:

  • libguestfs-winsupport for last ntfs partition
  • libguestfs-xfs for last xfs partition
  • btrfs-progs for last btrfs partition

The approximate algorithm is as following (for GPT):

  1. part-list -> (start, end); blockdev-getsize64 -> diskEnd; store partition attrs
  2. create overlay image of size newSize on top of current
  3. debug sh 'sgdisk -e /dev/sdaN' (working on libguestfs API)
  4. part-del /dev/sda N
  5. part-add /dev/sda attrs.type start (blockdev-getsize64 - (diskEnd - end))
  6. restore partition attrs
  7. stretch filesystem (resize2fs, ntfsresize etc)
  8. prl_disk_tool merge --external overlay (qemu-img commit)

For MBR, we avoid step (3) and repeat (4)-(5) for extended partition before resizing logical (if needed).

If something goes wrong before (8), we just remove overlay and nothing will change to original image. Overlay is lightweight: for 1GB full disk it used only 6.3Mb of space (I think it's affordable).

Products[edit]

Virtuozzo 7

Packages

  • prl-disk-tool >= 7.0.7
  • libguestfs >= 1.31.7
  • btrfs-progs >= 4.2 (optional)
  • libguestfs-winsupport >= 7.2.1 (optional)
  • libguestfs-xfs (in dependencies)
  • qemu-img >= 1.5.3-86

Testing[edit]

Need to test the following cases:

  • resize --resize_partition /works for ext2/ext3/ext4/ntfs/btrfs/xfs/swap last partitions
  • it works for GPT partitions, preserving partition attributes
  • it works for MBR partitions (primary/extended/logical), preserving partition attributes.

Known issues[edit]

  • only listed filesystems are supported
  • LVM is not supported (working on it)
  • GPT disk GUID is not preserved (it may cause specific OSes to fail - need to check which ones)
  • Resizing drops internal snapshots (working on it)

Person responsible for the feature[edit]

Maxim Perevedentsev (mperevedentsev at virtuozzo.com)

Links[edit]