[Solution] How to extend windows storage in KVM?

Saifudheen SidheeqKVM, Linux, VirtualizationLeave a Comment

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.

How we can get around this issue?

[Solution] Windows VM storage full in KVM

All we have to do is increase the storage on the windows VM in the KVM.

In this blog let’s go ahead and extend the storage for windows 10 VM in KVM. Though we are doing it for windows 10 the steps are pretty much the same for other versions of windows as well.

Step1. 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

libvirt windows vm extend c drive

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$ 

Step2. 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, 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 copy the image back from the win-backup directory and start the windows.

Step3. Increase the disc size of windows 10 in KVM

  • 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.
[[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.

Step4. 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
Increase the harddisk size of windows 10 in the disk manager kvm
  • The windows computer management window now open, click on Disk management.
libvirt windows vm extend c drive
  • 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.
extending the volume for windows in kvm
  • 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.
expanding the system storage on windows
  • Click Finish on the Extend Volume wizard.

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

Step5. Windows Storage Verification in KVM

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

extend the windows 10 drive in kvm

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

verifying windows 10 storage in kvm after extending.

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

extending the storage on windows 10 in KVM