Increase disk size for Windows virtual machine

Latest response

I need to increase the disk size for a Wiindows 10 virtual machine running on RHEL 7.
I have a volume with 1000 Gb space I set aside for virtual guests.
/dev/sda5 1024522480 190770428 833752052 19% /virt1
On this volume, I have installed 4 virtual machines
ll /virt1
-rw-------. 1 root root 107390828544 Aug 29 07:20 vm1.img
-rw-r--r-- 1 qemu qemu 105530851328 Feb 21 11:26 win10x64-sda
-rw-r--r-- 1 qemu qemu 31798001664 Aug 29 07:16 win70-sda
-rw-r--r-- 1 root root 37760466944 Aug 29 07:15 win7a-sda
A lot of space is unused.
How can I increase the disk size for virtual machine win10x64-sda
from 105 Gb to 300 gb?
The man pages for virt-filesystems and virt-resize are not clear to me.

Responses

Hi Alois,

Assuming your virtual disks reside in the directory /var/lib/libvirt/images and the virtual disk is in qcow2 format, execute :

sudo qemu-img resize /var/lib/libvirt/images/<virtual-disk-name>.qcow2 +195G

If the disk resides in another directory and/or it is in format img, adjust the path accordingly, and replace qcow2 with img.

Perform this operation while the VM is being shutdown and increase the file system later from within Windows as usual. :)

Regards,
Christian

Thank you. How can I know where the virtual disks reside?

In /var/lib/libvirt/images I have:

-rw-------. 1 root root 21478375424 Sep 7 2018 win10.qcow2

but as I have 4 virtual machines, as shown in my first posting I am not sure that that this is the right one. Where else could the disk images reside? Physically, they are in /virt1 which is a 1000 GB partition /dev/sda5

The file /var/lib/libvirt/images/win10.qcow2 may not correspond to virtual machine win10x64-sda The file size is shown as 21 Gb, which in now way corresponds to the VM.

du -m says it occupies only 5 Mb in reality, it is mainly a sparse file.

5 /var/lib/libvirt/images/win10.qcow2

I fear I do not know much about VMs. This is why I am hesitant to issue commands, as I do not want to destroy the disk images by some stupid manipulation.

I am not much familiar with Windows, I am only responsible for our Linux servers. I run the VM for other users on our system.

What does it mean: increase the file system later from within Windows as usual. ? What is this 'usual' procedure?

Hi Alois,

If you didn't change the storage location, they are in /var/lib/libvirt/images as you showed in your post above.
But when you create a VM and use another location for the disk, then of course it resides there - only you can
know where disks reside - right ? :) From within Windows means that once the VM is running, open the built-in
Disk Management application and extend the file system like it has to be done in Windows (as usual). Doing it
is self-explaining, for IT sysadmins at least. If you're unsure ask a Windows expert, but I'm sure you will get this
done yourself. As a little hint : You say the disks are in /virt1, which means most probably the right disk is there.
In this case the command would be sudo qemu-img resize /virt1/<virtual-disk-name>.qcow2 +195G.

Regards,
Christian

Hi Alois,

What I forgot to mention : virtual disks grow dynamically, that's why the file size you currently see is 21 GB. :)
The disk has a capacity of 105 GB - this size you see if you would store about 84 GB more stuff in Windows.

Regards,
Christian

I am afraid this last statement cannot be true - or it is not the right disk we are talking about. The reason why I need to increase the disk size is because Windows 10 complains again and again that it is nearly out of disk space. At least 95 Gb are taken, and only 7 Gb remain free.

Hi Alois,

I was referring to your statement "The file size is shown as 21 Gb, which in no way corresponds to the VM." Again,
only you can define which disk is the right disk, obviously it is impossible for me to tell you which one to select. :)

Regards,
Christian

Now I understand a bit more:

/var/lib/libvirt/images/win10.qcow2 is not the disk for the virtual machine I need to increase:

qemu-img info win10.qcow2
image: win10.qcow2
file format: qcow2
virtual size: 20G (21474836480 bytes)
disk size: 4.1M

The file /virt1/win10x64-sda is the right one:
qemu-img info win10x64-sda
image: win10x64-sda
file format: qcow2
virtual size: 100G (107374182400 bytes)
disk size: 98G
cluster_size: 65536

and I need to operate on that one.

Hi Alois,

Great ! :)

First add the file extension : sudo mv /virt1/win10x64-sda /virt1/win10x64-sda.qcow2
Now you can resize the disk : sudo qemu-img resize /virt1/win10x64-sda.qcow2 +195G

Regards,
Christian

I now followed the instructions, used qemu-img to add 195 Gb, and then used Disk Manager in Windows to increase the size. In Windows, the disk size now shows as 293 Gb.

But on Virtual Machine manager in RHEL 7, it still appears: Storage size 100 GiB.

After I restarted the Virtual machine manager, the disk size 295 GiB appeared.

Hi Alois,

I'm glad that we could get it done ! :)

Regards,
Christian

Thank you for your help! I did not do any name change on the file, qemu-img recognizes the type qcow2 also as it it.

You're welcome, Alois ! :)