Red Hat Bugzilla – Bug 574687
Enhance libguestfs with partition+filesystem resize option
Last modified: 2010-03-25 10:30:18 EDT
Description of problem:
When resizing a guest image/lv, it's difficult to enlarge the contained partitions and filesystems from the hypervisor environment in an easy, scriptable fashion.
It would be great if libguestfs/guestfish was able to assist here. Because guestfish can use native tools it is in an excellent position to facilitate this.
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1.Enlarge a guest image (using lvresize for example)
2.Try to enlarge the contained partitions and filesystems
3.Observe that this is quite difficult to do :)
1.Enlarge a guest image
2.Run a magic guestfish command to automatically enlarge the partition/filesystem to maximum size
This will probably only work if the guest image has only one partition. Or otherwise you can only enlarge the last partition.
The magic command should detect the filesystem type of the partition (or provide an option to set it) and call the correct command to resize it. Or otherwise fail if the filesystem type is not supported.
- If the partition contains a ext(2|3|4) partition, use resize2fs
- If the partition contains a lvm pv, use pvresize.
Support for ntfs and ufs2 would be a nice additional feature.
Thanks for looking into this. This would greatly enhance the usability of guestfish (at least for us)!
Upstream discussion / proposed virt-resize tool:
Note that moving partitions in-place is significantly hard
and error-prone, and so the proposed tool creates a new
disk image each time. The proposed workflow (with LVs)
would look something like this:
virsh shutdown Guest
lvrename /dev/VG/Guest /dev/VG/Guest_orig
lvcreate -L 10G -n Guest VG
virt-resize --expand /some/fs /dev/VG/Guest_orig /dev/VG/Guest
virsh start Guest # started with resized disk image
# test the guest still boots and works before ...
You need to provision the host with enough free disk space to
store at least one extra guest's disk image.
Tool is ready for testing, see:
This is upstream now:
and available in Rawhide.
Thanks for suggestions and testing.