By default, the C drive on an Azure VM is only 127 GB. Usually after a few programs are installed and perhaps a Sql Database is setup, you’re on your way to filling up the hard drive. After running the machine for a few weeks you’ll also notice Azure logs start to build up on your drive, and pretty soon you’re out of disk space.
So increasing the C drives diskspace should be a piece of cake right? After all, this is why we’re all paying big dollars for Azure’s convenience right? Wrong. Some of Azure’s VMs actually have the System Reserved / Master Boot Record partition at the end of the drive, rather than the beginning. Why would Microsoft create VMs with the MBR at the end? I have no idea, and it makes no sense to me, but below is how to fix it, and a reference to this article for more details.
Upon looking at the C drive in Disk Management, you’ll notice a very small active partition after your C drive. DO NOT delete this partition. We must take the contents of this active boot partition and move it to the C drive, then we can delete it, and make room to extend the C Drive partition.
Make the Windows Recovery Partition Visible
- Open the Run command bar by typing WindowsKey + R, and enter diskmgmt.msc into the text line to open the Disk Manager tool
- Right click the System Reserved partition and choose the Change Drive Letter and Paths… option
- For the sake of this guide we will use the letter X:
- Click the Add button to create a new drive letter
- Choose an available drive letter and select OK
- Open Windows Explorer without closing out the Disk Management window
- Confirm the addition of the new drive letter and close the window
Disable the Recovery Environment:
- Begin an Administrator mode command prompt
- In the search bar, type “CMD” to open command prompt
- Disable the recovery environment within the system reserved partition by typing: reagentc /disable
- You will want to confirm the successful movement of the winre.wim file to the Recovery folder. Use the following directory path to confirm the location: C:\Windows\System32\Recovery
- Alternatively, the location can be confirmed by typing dir /a C:\Windows\System32\Recovery into the command prompt
Copy Boot Files into the C: Drive
- Unload the BDC Registry Hive by typing the following command into the Command Prompt: Reg unload HKLM\BCD00000000
- Copy bootmgr file from the System Reserved partition into the Windows partition by using the following command: robocopy x:\ c:\ bootmgr
- Copy the boot folder form the system reserved partition into the Windows partition with command line: robocopy x:\boot c:\boot /s
- At this point all bootable files should be copied into the Windows partition, confirm this by running command prompt: dir c:\ /ah
- This command will produce a list of files. If bootmgr and the boot folder are included the list, the move was completed successfully.
- In order to boot properly, the boot files must be updated to work within the Windows partition. This is accomplished with a few more command lines:
- Update the BCD file: bcdedit /store c:\boot\bcd /set {bootmgr} device partition=C:
- Update the Memory Diagnostics entry: bcdedit /store c:\boot\bcd /set {memdiag} device partition=C:
Remove the System Reserved Partition
- Now that the files have been successfully copied, we can remove the Drive letter assignment we gave the System Reserved partition earlier
- Bring up the Disk Management window.
- Right click the System Reserved Partition and select Change Drive Letter and Paths…
- Click the Remove option, and then Yes to confirm
- Now that the Drive letter has been removed we will set the Windows partition as the Active (Booting) partition.
- In the Disk Management windows, right click the Windows partition, and select Mark Partition as Active
- Select Yes to confirm the action.
- Restart the server
- Reopen the Command Prompt
- Enable the Windows Recovery Environment buy entering the following command line: reagentc /enable
- Open Disk Management
- Right click the System Reserved partition and select the Delete Volume… option and confirm the action
Add “Unallocated” space to the C: Drive
- In the Disk Management window, right click the C: drive and select the Extend Volume… option
- In the window that pops up, click the number that appears in the Available: box.
- Click Add
- From that number, select the amount you wish to allocate to the C: drive
- Click Next and Finish
- Deploying Composable Resources via Powershell - December 1, 2022
- Composable APIs via Powershell - December 1, 2022
- Enabling Long Paths in Composable - April 6, 2022