🔧 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:

  1. Go to the VM and click Stop to deallocate (if required)
  2. Under Settings, click Disks
  3. Select the disk you want to resize
  4. Click Size + performance
  5. 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

  1. Open an RDP session to the virtual machine.
  2. Open Command Prompt and type diskpart.
  3. At the DISKPART prompt, type list volume and find the target volume.
  4. Type select volume <volume number>.
  5. Type extend [size=<size in MB>] to expand the volume.

Using Disk Management

  1. Open an RDP session to the virtual machine.
  2. Launch Disk Management.
  3. Right-click the existing C: partition and select Extend Volume.
  4. 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

PopulÀra inlÀgg i den hÀr bloggen

🚀 IntuneWin – Deploying Win32 Apps via Intune 🎯

Boost Your Graphics Power med GPU-acceleration i Azure Virtual Desktop!

Block Personal devices to acces to Desktop apps like teams, Onedrive etc and how to troubleshooting the issue.