đ§ Expand Virtual Hard Disks on Azure Windows VMs
đ§ Expand Virtual Hard Disks on Azure Windows VMs đ
This guide helps you quickly understand how to expand virtual disks for Windows VMs on Azure.
✅ Applies to:
- Windows VMs
- Flexible Scale Sets
đ Key Points:
- Default OS disk: 127 GiB
- Max OS disk: 4,095 GiB (limited to 2 TiB if MBR)
- Use GPT if you need more than 2 TiB on OS disk
- Cannot shrink existing disks
đ Expand Without Downtime (Data Disks Only):
- Works if disk is already > 4 TiB (Standard or Premium)
- Use Azure CLI, PowerShell, Portal, or ARM templates
- Not supported for OS disks or shared disks
đ Resize via Azure Portal:
- Go to the VM and click Stop to deallocate (if required)
- Under Settings, click Disks
- Select the disk you want to resize
- Click Size + performance
- Select a new (larger) size and click Resize
đ After Resizing:
- Extend volume in Windows Disk Management
- If size is not visible: rescan or restart the VM
đœ Expand the Volume in the Operating System
Once you’ve expanded the virtual disk, log in to the OS and expand the volume to use the new space. This can be done using either DiskPart or Disk Management via RDP.
Using DiskPart
- Open an RDP session to the virtual machine.
- Open Command Prompt and type
diskpart
. - At the DISKPART prompt, type
list volume
and find the target volume. - Type
select volume <volume number>
. - Type
extend [size=<size in MB>]
to expand the volume.
Using Disk Management
- Open an RDP session to the virtual machine.
- Launch Disk Management.
- Right-click the existing C: partition and select Extend Volume.
- Follow the wizard to complete the process.
đ« Expand Without Downtime – Support for Classic VM SKU
If you’re using a classic VM SKU, it might not support disk expansion without downtime.
Use this PowerShell script to check which VM versions support this feature:
Resize Managed Disk – PowerShell
# Sign in to Azure
Connect-AzAccount
Select-AzSubscription -SubscriptionName 'my-subscription-name'
# Set resource group, VM and disk names
$rgName = 'my-resource-group-name'
$vmName = 'my-vm-name'
$diskName = 'my-disk-name'
# Get VM reference
$vm = Get-AzVM -ResourceGroupName $rgName -Name $vmName
# Stop the VM (skip if expanding without downtime)
Stop-AzVM -ResourceGroupName $rgName -Name $vmName
# Get and resize the disk
$disk = Get-AzDisk -ResourceGroupName $rgName -DiskName $diskName
$disk.DiskSizeGB = 1023 # New size (must be larger than current)
Update-AzDisk -ResourceGroupName $rgName -Disk $disk -DiskName $disk.Name
# Restart the VM
Start-AzVM -ResourceGroupName $rgName -Name $vmName
Check VM SKU Support – PowerShell
Connect-AzAccount
$subscriptionId = "yourSubID"
$location = "desiredRegion"
Set-AzContext -Subscription $subscriptionId
$vmSizes = Get-AzComputeResourceSku -Location $location | Where-Object { $_.ResourceType -eq 'virtualMachines' }
foreach ($vmSize in $vmSizes) {
foreach ($capability in $vmSize.Capabilities) {
if (
($capability.Name -eq "EphemeralOSDiskSupported" -and $capability.Value -eq "True") -or
($capability.Name -eq "PremiumIO" -and $capability.Value -eq "True") -or
($capability.Name -eq "HyperVGenerations" -and $capability.Value -match "V2")
) {
$vmSize.Name
}
}
}
Kommentarer
Skicka en kommentar