How to expand virtual hard disks attached to a Windows virtual machine
Article
Applies to: ✔️ Windows VMs ✔️ Flexible scale sets
When you create a new virtual machine (VM) in a resource group by deploying an image from Azure Marketplace, the default operating system (OS) disk is usually 127 GiB (some images have smaller OS disk sizes by default). You can add data disks to your VM (the amount depends on the VM SKU you selected) and we recommend installing applications and CPU-intensive workloads on data disks. You may need to expand the OS disk if you're supporting a legacy application that installs components on the OS disk or if you're migrating a physical PC or VM from on-premises that has a larger OS disk. This article covers expanding either OS disks or data disks.
An OS disk has a maximum capacity of 4,095 GiB. However, many operating systems are partitioned with master boot record (MBR) by default. MBR limits the usable size to 2 TiB. If you need more than 2 TiB, create and attach data disks and use them for data storage. If you need to store data on the OS disk and require the additional space, convert it to GUID Partition Table (GPT). To learn about the differences between MBR and GPT on Windows deployments, see Windows and GPT FAQ.
Important
Unless you use Expand without downtime, expanding a data disk requires the VM to be deallocated.
Shrinking an existing disk isn’t supported and may result in data loss.
You can expand data disks without deallocating your VM. The host cache setting of your disk doesn't change whether or not you can expand a data disk without deallocating your VM.
This feature has the following limitations:
Only supported for data disks.
If a Standard HDD, Standard SSD, or Premium SSD disk is 4 TiB or less, deallocate your VM and detach the disk before expanding it beyond 4 TiB. If one of those disk types is already greater than 4 TiB, you can expand it without deallocating the VM and detaching the disk. This doesn't apply to Premium SSD v2 or Ultra Disks.
Or an Azure Resource Manager template with an API version that's 2021-04-01 or newer.
Not available on some classic VMs. Use this script to get a list of classic VM SKUs that support expanding without downtime.
Expand with Ultra Disk and Premium SSD v2
Expanding Ultra Disks and Premium SSD v2 disks have the following additional limitations:
You can't expand a disk while a background copy of data is also occurring on that disk, like when a disk is being hydrated from snapshots.
You can't expand a VM that's using NVMe controllers for Ultra Disks or Premium SSD v2 disks without downtime.
Important
Allow up to ten minutes for the correct size to be reflected in Windows VMs and Linux VMs. For Linux VMs, you must perform a Linux rescan function For Windows VM that doesn't have a workload, you must perform a Windows rescan function. You can rescan immediately, but if it's within ten minutes, you might need to rescan again to display the correct size.
Regional availability
Resizing Ultra Disks and Premium SSD v2 disks is currently available in all Premium SSD v2 and Ultra supported regions except the following:
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.
Warning
The new size should be greater than the existing disk size. The maximum allowed is 4,095 GB for OS disks. (It's possible to expand the VHD blob beyond that size, but the OS works only with the first 4,095 GB of space.)
Select Resize at the bottom of the page.
Resize a managed disk by using PowerShell
Open your PowerShell ISE or PowerShell window in administrative mode and follow the steps below:
Sign in to your Microsoft Azure account in resource management mode and select your subscription:
The new size should be greater than the existing disk size. The maximum allowed is 4,095 GB for OS disks. (It is possible to expand the VHD blob beyond that size, but the OS works only with the first 4,095 GB of space.)
Updating the VM might take a few seconds. When the command finishes executing, restart the VM:
Remote into the VM, open Computer Management (or Disk Management) and expand the drive using the newly allocated space.
Expand the volume in the operating system
When you've expanded the disk for the VM, you need to go into the OS and expand the volume to encompass the new space. There are several methods for expanding a partition. This section covers connecting the VM using an RDP connection to expand the partition using Using Diskpart or Using Disk Manager.
Using DiskPart
When you've expanded the disk for the VM, you need to go into the OS and expand the volume to encompass the new space. There are several methods for expanding a partition. This section covers connecting the VM using an RDP connection to expand the partition using DiskPart.
Open an RDP connection to your VM.
Open a command prompt and type diskpart.
At the DISKPART prompt, type list volume. Make note of the volume you want to extend.
At the DISKPART prompt, type select volume <volumenumber>. This selects the volume volumenumber that you want to extend into contiguous, empty space on the same disk.
At the DISKPART prompt, type extend [size=<size>]. This extends the selected volume by size in megabytes (MB).
Using Disk Manager
Start a remote desktop session with the VM.
Open Disk Management.
Right-click on existing C: drive partition -> Extend Volume.
Follow the steps you should be able to see the disk with updated capacity:
Expanding without downtime classic VM SKU support
If you're using a classic VM SKU, it might not support expanding disks without downtime.
Use the following PowerShell script to determine which VM SKUs it's available with:
Learn about your virtual machine storage options and how to choose between standard and premium, managed and unmanaged disks for your Azure virtual machine.