12/7/2023 0 Comments Qemu img resize![]() Resize the LVM physical volume % pvdisplay The new table will be used at the next reboot. WARNING: Re-reading the partition table failed with error 16: Device or Last cylinder or +size or +sizeM or +sizeK (14-5874, default 5874):Ĭhanged system type of partition 2 to 8e (Linux LVM)Ĭalling ioctl() to re-read partition table. Run fdisk inside VM and delete & re-create LVM partition % fdisk /dev/vdaĭisk /dev/vda: 48.3 GB, 48318382080 bytesĢ55 heads, 63 sectors/track, 5874 cylinders start the VM (using the newly created new.img).add more space to the guest's "image file" (something like: cat old.img 10G_addon.raw > new.img.Here are the steps that I roughly followed to resize a KVM guest that used LVM internally. This last step basically extends the OS partition so that it can make use of the extra space. Now with the larger mykvm.img file in hand, boot gparted and extend the existing partition into the newly added disk space. The nuts of this method are as follows: # 1. METHOD #1: Partitions are ext2/ext3/ext4 based One thing to be aware of with KVM guests is that the partitions they're using inside can effect which method you can use to increase their disk space. NOTE: This link was useful for METHOD #1, and shows how to accomplish increasing a KVM's disk space (ext3 based), HOWTO: Resize a KVM Virtual Machine Image. I'm asking how to accomplish this while the KVM is offline. The 1st asks the question of how to increase a KVM guest while it's online, while the 2nd is XEN specific using LVM. These serverfault questions are similar but more specific, KVM online disk resize? & Centos Xen resizing DomU partition and volume group. At this point, go ahead and resize your partitions and LVM structure as needed. Running dmesg should report that the virtio disk detected a capacity change. Signal the virtio driver to detect the new size (specify the total new capacity): virsh qemu-monitor-command block_resize drive-virtio-disk0 20G -hmp ![]() Get the name of the virtio device, via the libvirt shell ( drive-virtio-disk0 in this example): virsh qemu-monitor-command info block -hmpĭrive-virtio-disk0: removable=0 io-status=ok file=/var/lib/libvirt/images/.img ro=0 drv=raw encrypted=0ĭrive-ide0-1-0: removable=1 locked=0 tray-open=0 io-status=ok Increase the size of the disk image file itself (specify the amount to increase): qemu-img resize. Perform the following from the KVM hypervisor. To remove that risk, you would need to log into the VM and unmount the target disk first, something that isn't always possible. This can be useful in environments where the disk cannot be unmounted (such as a root partition), the VM must stay on, and the system owner is willing to assume the risk of data corruption. Online Method (using qemu, libvirt, and virtio-block)įor better or worse, the commands below will run even if the target virtual disk is mounted. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |