Some KVM images end up not having enough space on them. In such cases, it is preferable to increase the size of the VM rather than to just delete an image and rebuild it from scratch. The steps outlined below document what was done to increase the size of the Red Hat 5 x86 VM and should be able to be easily adapted to other VMs, should they need the same treatment in the future.
cp -avi vm-rhel5-x86-build.qcow2 vm-rhel5-x86-build-new.qcow2
qemu-img command, resize the image: qemu-img info vm-rhel5-x86-build-new.qcow2 qemu-img resize vm-rhel5-x86-build-new.qcow2 +10G qemu-img info vm-rhel5-x86-build-new.qcow2 rsync -avP vm-rhel5-x86-build-new.qcow2 terrier:/kvm/vms/
Not all versions of qemu-img can resize VMs.
vm=vm-rhel5-x86-build-new.qcow2
kvm -m 2048 -hda /kvm/vms/${vm} -cdrom /kvm/iso/gparted-live-0.14.1-6-i486.iso -boot d -smp 2 -cpu qemu64 -net nic,model=virtio -net user,hostfwd=tcp:127.0.0.1:22666-:22
vncviewer -via <vmhost> localhost
Midway through booting you'll have to reconnect
kvm -m 2048 -hda /kvm/vms/${vm} -boot c -smp 2 -cpu qemu64 -net nic,model=virtio -net user,hostfwd=tcp:127.0.0.1:22666-:22 -nographic
ssh -t -p 22666 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i ~/.ssh/buildbot.id_dsa buildbot@localhost
sudo mount /dev/hda3 /mnt
sudo rsync -avP /home/ /mnt/
sudo vi /etc/fstab
/home to /home-old, create /home dir, mount /homesudo mv -vi /home /home-old;sudo mkdir -v /home;sudo mount /home
/mntsudo umount /mnt
sudo /sbin/shutdown -h now
/home-old -old and the -new VM to what the old VM used to be named sudo mv -vi /kvm/vms/vm-rhel5-x86-build.qcow2 vm-rhel5-x86-build-old.qcow2; sudo mv -vi /kvm/vms/vm-rhel5-x86-build-new.qcow2 /kvm/vms/vm-rhel5-x86-build.qcow2
sudo cp -avi /kvm/vms/vm-rhel5-x86-build.qcow2 /kvm/vms/vm-rhel5-x86-build-old.qcow2 sudo rsync -avP terrier.askmonty.org::kvm/vms/vm-rhel5-x86-build* /kvm/vms/
© 2023 MariaDB
Licensed under the Creative Commons Attribution 3.0 Unported License and the GNU Free Documentation License.
https://mariadb.com/kb/en/resizing-a-virtual-machine-image/