I installed Windows 8.1 as a KVM guest on OS13.1. I had to select “copy host CPU configuration” which filled in the field with “Nehalem”.
After I got it running on an 8Gig virtual disk, I tried to update the software and ran out of disk space. I know I could simply blow it away and start over, but I would like to be able to “fix” the problem.
Is there a way to expand the existing virtual disk (.raw) without breaking the installation? Is it possible to create a new disk and “clone” the existing system to the new disk, and then grow the system partition? I know this is somewhat of a “Windows” question, but I’m asking about the Linux aspects of the problem.
# virsh list --all
Id Name State
----------------------------------------------------
- win8 shut off
- os13-1-1 shut off
# virsh dumpxml win8 | xpath /domain/devices/disk/source
Found 2 nodes:
-- NODE --
<source file="/var/lib/libvirt/images/win8.img" />-- NODE --
<source file="/home/hattons/Downloads/com/microsoft/9200.16384.WIN8_RTM.120725-1247_X86FRE_ENTERPRISE_EVAL_EN-US-HRM_CENA_X86FREE_EN-US_DV5.ISO" />
# mkdir virt-temp
# cd virt-temp
# truncate -s 40G outdisk
# virt-filesystems --long --parts --blkdevs -h -a /var/lib/libvirt/images/win8.img
Name Type MBR Size Parent
/dev/sda1 partition 07 350M /dev/sda
/dev/sda2 partition 07 7.7G /dev/sda
/dev/sda device - 8.0G -
# virt-resize --expand /dev/sda2 /var/lib/libvirt/images/win8.img outdisk
# virt-resize --expand /dev/sda2 /var/lib/libvirt/images/win8.img-8G outdisk
Examining /var/lib/libvirt/images/win8.img ...
**********
Summary of changes:
/dev/sda1: This partition will be left alone.
/dev/sda2: This partition will be resized from 7.7G to 39.7G. The
filesystem ntfs on /dev/sda2 will be expanded using the
'ntfsresize' method.
**********
Setting up initial partition table on outdisk ...
Copying /dev/sda1 ...
100%
Copying /dev/sda2 ...
100%
Expanding /dev/sda2 using the 'ntfsresize' method ...
Resize operation completed with no errors. Before deleting the old
disk, carefully check that the resized disk boots and works correctly.
# mv /var/lib/libvirt/images/win8.img /var/lib/libvirt/images/win8.img-8G
# mv outdisk /var/lib/libvirt/images/win8.img
# virt-filesystems --long --parts --blkdevs -h -a /var/lib/libvirt/images/win8.img
Name Type MBR Size Parent
/dev/sda1 partition 07 350M /dev/sda
/dev/sda2 partition 07 40G /dev/sda
/dev/sda device - 40G -
My Win8 guest now has enough drive space for the time being.