Extending OS Volumes for Virtual Machines

Ever tried to extend an OS Volume / system partition for a virtual machine but couldn’t, even though you expanded the VHDX? A likely reason is that the VM’s OS was deployed with a Recovery Partition and the additional space is not accessible to the OS Partition.

What’s causing this?

The ‘Recovery Partition’ is located after the OS partition and so free space on the disk can only be allocated to the recovery partition.

What is the Recovery Partition?

The recovery partition is a special partition on the disk, which helps to restore the factory settings of the OS (operating system) in the event of system issues. It is used by the Windows Recovery Environment (WinRE) and the default partition layout for UEFI-based PCs is to locate the recovery partition after the Windows partition.

(There are other reasons for the layout of the recovery partition that I won’t go into in this post)

What can I do?

You have two main options:

  1. Move the recovery partition with third-party software
  2. Delete the recovery partition

For this article, I am going to focus on option 2 since I needed to extend the OS partition for some virtual servers I have running in my lab.

*Please be careful with production servers and understand the connotations of taking any action on them, and always have decent backups of your data!

Deleting the Recovery Partition

To start we have a VM with an OS VHDX 60GB in size and will inspect its disk, volumes and partitions:

Within the OS we can see the Volume reflects the VHDX size:

Using Diskpart we can see the disk, volume and partition details:

*Note that the Recovery partition is listed after the Primary (OS) partition

Let’s increase the size of the VHDX

The volume is the same size according the the OS:

In Diskpart we can see the volume and partitions are the same size, but the Disk now has a size of 80GB with 20GB free:

Normally, we can simply extend the volume using diskpart:

But, oh no, we are told there’s not enough usable space!

But we expanded the VHDX and can see it’s now 80GB and the C: drive – volume 0 – is only 59GB

Why no extendy?

This is because that ‘Recovery’ partition we mentioned earlier is adjacent to the ‘free’ space as it’s located after the OS partition …

What can we do?

We can delete the recovery partition and then extend the volume like this:

First select the Recovery Partition by selecting the OS volume and then the recovery partition:

Then we delete the partition:

Haha! You didn’t think it would be that easy did you … well actually it is and you just need to add the ‘override‘ parameter and you’ll see it’s now gone from the list of partitions:

Now you can simply extend the volume, after selecting it, and then you can see the disk, volume and OS partitions all get extended into the free space:

I hope you found this useful and remember this is something I use in my lab and you may not want to use it on your servers, especially ones in production!

Leave a Reply

Your email address will not be published. Required fields are marked *