How To Extend Windows Storage in KVM ?

Saifudheen SidheeqKVM, Linux, Virtualization2 Comments

extend windows storage in kvm

I have one windows machine that I use as an alternate operating system in my Linux KVM. Recently I noticed that the C drive in my windows got filled up and there is not enough space left to store any more data.

If you have a physical box then it is a little difficult, as you have to expand your physical hard disk storage. Since we are using windows as a VM, then we are in luck and it is way too easier.

So how do I get around this issue ?

kvm increase windows disk size

Well, all we have to do is increase the storage on the windows VM in the KVM by increasing the size of KVM qcow2 storage.

How do I increase the size of my KVM guest disk space (qcow2 disk)?

In this Windows KVM disk partitioning guide let’s go ahead and extend the storage for windows 10 VM guests in KVM. Though we are doing it for windows 10 the steps are pretty much the same for other versions of windows as well, such as windows 7, server, and so on.

Step 1. Locate the Windows 10 disk image.

Using GUI

Shutdown the windows machine in KVM and locate the Windows 10 disk image.
In Virt manager click on properties of the windows 10 VM and click on VirtIO Disk 1, Here you can see the storage location of windows 10

kvm extend hdd boot windows 10

In the same window, you could also see the windows 10 storage size is at 40GB

Using CLI

You may type the command virsh domblklist win10, you should be able to see the virtual harddisk storage here.

[email protected]:~$ virsh domblklist win10
 Target   Source
 vda      /var/lib/libvirt/images/win10.qcow2
 sdb      -

[email protected]:~$ 

Now goto the image location and type ls -l

[email protected]:$ cd /var/lib/libvirt/images/
[email protected]:/var/lib/libvirt/images$ sudo ls -l -h
total 40G
-rw------- 1 libvirt-qemu kvm 40G Aug 30 12:31 win10.qcow2
[email protected]:/var/lib/libvirt/images$ 

Step 2. Backup the storage

Before we make changes it is better to have a backup, just in case if anything goes wrong.

To take a backup, you can either take a snapshot or copy the same disk image to a new folder. I am creating a new folder called win-backup.

[[email protected] images]# mkdir win-backup
  • Copy the win10 image to the new directory.
[[email protected] images]# cp win10.qcow2 win-backup/
  • Verify disk image has copied.
[[email protected] images]# ls -l win-backup/ -h
total 40G
-rw-------. 1 root root 42G Jan 16 21:40 win10.qcow2
[[email protected] images]#

once you have the backup ready you can go ahead with the next steps.

Note: in case of any issue you can remove the existing image and edit the windows XML file with the command virsh edit win10 and replace the image with the backup image and start the windows.

Step 3. KVM increase windows disk size

To increase the KVM disk size qcow2 for windows, follow the below.

  • Goto the image location /var/lib/libvirt/images
cd /var/lib/libvirt/images
  • I had given 40GB of storage during the VM installation, now I am going to expand to 60GB, to do that enter the command below.
    So 40GB+60GB=100GB in total.
[[email protected] images]# qemu-img resize win10.qcow2 +60G
Image resized.
[[email protected] images]#

Once you enter the command you could see that the image size got increased.

Step 4. Increase the harddisk size of windows 10 in the disk manager.

Once the size of the VM disk image of windows 10 is done in the KVM, it’s pretty easy to expand the storage under windows, we are basically going to use windows Disk manager utility for this purpose.

  • start the windows machine and click on the Start menu and type ‘This PC’
  • And right-click on This PC and click on manage
windows kvm disk partitioning resize using disk manager
  • The windows computer management window now open, click on Disk management.
windows kvm disk partitioning on windows 10
  • As you can see the increased storage is added as Unallocated storage in windows disk management.

You can either extend the drive or add a new drive. If you are planning to create a new drive then you can right-click on the Unallocated space and create new simple volume. I am going to extend the drive.

  • To extend the drive right-click on the ‘C drive’ and click on Extend Volume.
windows kvm disk partitioning expand
  • Click on Next on the Extend Volume Wizard
extend windows volume in kvm
  • I am going to add the whole 60GB to C drive, hence leave the default value and click on Next.
windows kvm disk partitioning
  • Click Finish on the Extend Volume wizard.
kvm windows disk partition resize

You have now expanded the C drive from 40gig to 100gig.

Step 5. Windows Storage Verification in KVM

You can see the whole partition as C drive in windows disk manager.

kvm windows disk partition increase

You can also verify the same from the file explorer as well.

kvm windows disk partition hard drive

Even on the KVM properties shows that the storage has been extended.

extending the storage on windows 10 in KVM

What if you are stuck with another small partition in the middle and the C drive Extend Volume is greyed out?

Even if you try to delete the partition in the middle, the windows default disk manager will not let you. It would just show you a help option.

And it is advisable not to delete the Recovery Partition.

So what do we do?

You got two choices, either

you can go ahead and create another drive from the unallocated space


Extend the C drive using a partition manager.

1.Create a new drive with unallocated space

Let’s look at the first option of creating the new drive

If you wanted to extend the C drive still, you may skip this option and go to the second option.

  1. Right-click on the unallocated space and click on New Simple Volume..

In the new simple volume screen, leave the default value to select the whole disk or choose your Value, then click on Next.

Select the drive letter and click on Next.

It will now prompt you for the file system and the format option, I am choosing the default value and then click on OK.

You would get a summary of the changes you will perform on your machine, validate them, and then click on Finish.

That’s it. You just got a new hard disk drive created as D drive.

Confirm the same by going to the windows explorer, as you can see the new D drive added.

2. Extend the C drive without deleting the recovery partition.

You decided to extend the C drive because it was fully utilized, right?

And so it doesn’t make sense to create a separate Drive, so how do we still go ahead and extend the C drive when there is a recovery partition on the right?

So let’s go ahead and take a look.

What does the recovery partition do?

The Windows operating system creates the extra Recovery Partition during the windows installation. That holds the windows recovery environment. So in the event of any windows system-related issues, and you wanted to restore the windows machine to its original state, you can use the recovery option.

Is it safe to delete recovery partition in Windows 10?

For an average user, I don’t recommend deleting the recovery partition on your windows machine. Otherwise, you will have to carry around the windows bootable image either on a CD or USB any time you want to do the restore option. But for VM’s, we already have a backup in place, so we are good.

I am using a different VM now, for the next troubleshooting, where I have given only 20GB of virtual hard disk during the installation. Now I am struggling as I don’t have enough storage.

You can see my C drive is almost full, and I already extended the windows image following step 3, qemu image resize. And I have given an extra 20GB.

qemu-img resize win10.qcow2 +20G

You cannot delete, modify, or move the recovery drive with the default windows device manager.

So we will use a software called EaseUS partition manager for this purpose. As the name suggests, it is effortless to use, and you can get your partition expanded in a couple of seconds.

Let’s see how we can extend the partition when there are other partitions in between.

Download the partition manager here. Though the trial version will help you save the operation, you need to have a license to execute the operations.

This partition manager will help you move that extra partition (recovery partition) and extend the C drive as well.

Step 1. Once you have the software downloaded and installed, you may go ahead and open it.

You should be able to see the list of partitions in your windows machine.

Step 2. We will now move the recovery partition, which sits in between the C drive and the unallocated space, to the end of the hard disk.

Select the recovery partition, which is around 500MB, and click on Resize/Move. The third one in my case.

Move the recovery partition to all the way to the right.

You can see the unallocated size of 20GB moved to the left, as in when we moved the recovery partition to the right. Click on OK here.

You should now see the recovery partition moved from the third to the fourth, which is good.

And the task has now been added to the operation.

Step 3. Now let’s go ahead and expand the C drive.

Click on the C drive. As you can see, the size is almost full.

On the right, you should be able to see an option which says Resize/Move. Click on that.

You will get another prompt, which will help you to extend the hard disk easily.

On the expand the screen, resize the C drive to the size that you prefer.

Just drag the dot to the right; it depends on how much space you need, then clicks on OK.

I prefer to use the whole 20 GB of unallocated space for my C drive, so I selected the entire disk and clicked on OK.

As soon as you clicked on OK, you can see the C drive is expanded in the software, and this task has also gone to the operations queue.

And you should be able to see two operations in the queue first for moving the recovery partition to the end, and the second is for expanding the C drive.

Step 4. Both the operations are not completed yet; we are going to do that now. To do that, click on Execute 2 operations option.

A new window will pop up, which shows you the changes you will make. Click on Apply.

As soon as you click on Apply, it should start its work in the backend.

Alright, both the operations are now completed. Click on Finish.

We have successfully moved the recovery partition to the end of the harddisk now and also expanded the C drive to 40GB as well, which we weren’t able to do it using windows disk manager before.

To confirm the changes, open your windows file manager, and you can see the C drive is expanded successfully.

You can also see the recovery partition under the disk manager as well.

Though you don’t need to reboot the machine after the change, it is recommended to reboot the windows host as well, so please go ahead and reboot the machine and continue to use the system with more storage 😊