Delete Windows Recovery Partition
Purpose: Sometimes you are running a virtual machine and are running out of space, and want to expand the operating system disk. However, there is a recovery partition to-the-right of the operating system partition. When this happens, you have to delete that partition in order to expand the storage space for the operating system.
These commands can be run in a headless environment using just powershell.
Use Correct Drive & Partition Numbers
In my example codeblock, I assume the OS drive is 0
and the recovery partition is 4
. Please validate your own drive and partition numbers with the supplied list disk
and list partition
commands. Failure to identify the correct drive and/or partition could result in the unintended destruction of data.
From within the VM > Open a powershell window and run the following commands:
diskpart # (1)
list disk # (2)
select disk 0 # (3)
list partition # (4)
select partition 4 # (5)
delete partition override # (6)
select partition 3 # (7)
extend # (8)
exit # (9)
- This opens the disk management CLI tool.
- This displays all disks attached to the device.
- Ensure this disk number corresponds to the operating system disk. Open the Disk Management GUI if you are not 100% certain.
- List all partitions on the previously-selected disk.
- This partition number is for the partition of type "Recovery". If you see a different partition with a type of "Recovery" use that partition number instead.
- This instructs the computer to delete the partition and ignore the fact that it was a recovery partition.
- You want to select the operating system partition now, so we can expand it. This partition will generally be of a type "Primary" and be the largest size partition on the disk.
- This will expand the operating system partition into the unallocated space that is now available to it.
- Gracefully close the disk management CLI utility.
Free Space Validation¶
From this point, you might want to verify the free space has been accounted for, so you can run the following command to check for free space: