If you run out of disk space on a Hyper-V virtual machine, thank your lucky stars that the processing of increasing the disks capacity is less complicated and less risky than repartitioning a physical disk. In the example below, we are going to increase the disk capacity of a virtual machine running on a Hyper-V host server.
To begin, make sure you have a recent working backup of the VM. As with any changes, there are risks, albeit very low risk but nonetheless it’s best practice to back up before making any types of changes on production systems.
As you can see below, the VM is running out of disk space.
Log in to the Hyper-V host and gracefully shut down the VM
Once the VM if off, edit the VM settings.
Locate the hard drive that needs to be expanded and edit the VHDX file.
When prompted, choose expand to increase the size of the virtual disk.
Select a larger capacity disk size and enter it into the new size field.
Click finish then start the VM. Once the VM has started, log in to the VM’s desktop UI. Open a command prompt with administrative rights and run the command diskmgmt.msc to open the disk management console. In the dism manager, you will notice two partitions. The first is the current disk capacity and the second is the additional capacity we created in the previous step.
Right click on the original partition (1) and select extend volume.
The select disks dialog box should show the additional partition already showing in the selected partition window.
Click next, then finish and you should now see a single partition of increased capacity.
Your operating system should immediately detect and update the disk size, if it does not, restart your VM.