In cloud computing, flexibility and scalability are critical aspects of managing resources efficiently. Azure offers a seamless way to resize your virtual machine (VM) disks to accommodate changing storage needs. This article walks you through the process step by step, ensuring smooth resizing of your Azure VM.
Evaluating disk performance
Before resizing, evaluate your Azure VM disks to determine if they are affecting performance or hampering resource availability. Available disk space and performance indicators can guide us in determining if resizing is necessary. Microsoft Azure provides valuable tools to identify disk-related issues affecting VM performance. To know what these metrics are, open your Azure VM, and in the overview section, you’ll be able to find them.
Resizing disk storage in Azure portal
Limitations to expand without downtime
- Expansion is only supported for data disks.
- For disks under 4 TiB, deallocate the VM and detach the disk before expansion.
- Not supported for Ultra disks or Premium SSD v2 disks.
- Not applicable to shared disks.
- Requires the latest Azure CLI, Azure PowerShell module, Azure portal, or Azure Resource Manager template with API version 2021-04-01 or newer.
- Some classic VMs may not support this feature.
Steps to resize Microsoft Azure VM disk
If your disk meets the requirements for resizing without downtime, skip to step 2.
- In the Azure portal, go to the virtual machine in which you want to expand the disk. Select Stop to deallocate the VM.
- In the left menu under Settings, select disks.
- Under Disk name, select the disk you want to expand.
- In the left menu under Settings, select Size + Performance.
- In Size + Performance, select the disk size you want or enter a custom disk size.
- After configuring the size, click Resize to implement the changes.
Resizing disk by using PowerShell
-
Open PowerShell ISE or a PowerShell window in administrative mode.
-
Sign in to your Microsoft Azure account in resource management mode and select your subscription.
Connect-AzAccount Select-AzSubscription –SubscriptionName 'my-subscription-name'
Replace ‘my-subscription-name’ with the name of your Azure subscription.
- Set your resource group name, VM name, and disk name:
$rgName = 'my-resource-group-name' $vmName = 'my-vm-name' $diskName = 'my-disk-name'
Replace ‘my-resource-group-name’, ‘my-vm-name’, and ‘my-disk-name’ with your actual resource group name, VM name, and disk name.
- Obtain a reference to your VM.
$vm = Get-AzVM -ResourceGroupName $rgName -Name $vmName
-
Stop the VM before resizing the disk.
Stop-AzVM -ResourceGroupName $rgName -Name $vmName
-
Obtain a reference to the managed OS disk. Set the size of the managed OS disk to the desired value and update the disk.
$disk= Get-AzDisk -ResourceGroupName $rgName -DiskName $diskName $disk.DiskSizeGB = 1023 # Set the desired disk size in GB Update-AzDisk -ResourceGroupName $rgName -Disk $disk -DiskName $disk.Name
Ensure that the new size is greater than the existing disk size. The maximum allowed size for OS disks is 4,095 GB.
- When the command finishes executing, restart the VM.
Start-AzVM -ResourceGroupName $rgName -Name $vmName
Resizing disk using DiskPart
- Open a remote desktop session connection to your VM.
- Open a command prompt and type
diskpart
. - At the diskpart prompt, type
list volume
. Note the volume number of the partition you want to extend. - Type
select volume <volumenumber>
to select the volume you want to extend. - Type
extend [size=<size>]
to extend the selected volume by the specified size in megabytes. - Type
shrink [size=<size>]
to shrink the selected volume by the specified size in megabytes. - Once the operation is completed, you can verify the changes by typing
list volume
.
Resizing disk using Disk Manager
- Start a remote desktop session with the VM.
- Open Disk Management.
- Right-click on the existing partition (C: drive) and select “Extend or Shrink Volume”.
- Specify the size of the volume you want to extend or shrink, accept the default maximum size.
- Review the settings and click “Finish” to complete the volume extension process.
Restart VM
Once the disk resizing process completes, restart the virtual machine to ensure that the new disk size and performance settings take effect. Downgrading disk types (e.g., from Premium SSD to Standard HDD) may require a 24-hour waiting period after any disk changes to take effect.