Home » Cloud » Azure » Increase the size of the OS disk and data disk in an Azure VM

Increase the size of the OS disk and data disk in an Azure VM

Eexpand the existing OS disk and the data disk. how can we do it with the PowerShell script.

In this requirement, need to increase the C drive to 256 GB and H drive to 128 GB managed disk. As you can see below the disks are almost full.

login to your Azure Subscription.

the following PowerShell commands to store the VM and resource-related information in the variable and later stop the VM.

In this step, you need to store the OS disk details in a variable called $disk and assign the size to 256 GB and update the configuration with the Update-AzureRmDisk command as you can see below

Same steps we need to repeat for the data disk as well where we stored the disk related information in a variable called $disk1, please note DataDisk[0] means the disk which is attached to LUN no. 0

Once it’s done you can start the Azure VM

You can find that the disk size increase is reflecting in the portal.

Now you can log in to windows and go run and type compmgmt.msc, from there go to disk management and click on C drive and click on extend the volume in the drop-down menu.

Once you click on that the extend volume wizard will open and it will extend the volume, the below screenshot is showing this step for the data disk.

In next step click on finish to complete the wizard.

Now should be able to see the extra space in your disks now.