There are multiple scenarios where you might require expanding disk size on the virtual machines. 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 GB (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). 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. Expanding OS disks still need a downtime because of understandable dependencies but Microsoft Azure now supports expanding data disks without requiring any downtime.

In this article I explain the steps required to avail this feature. Please note this feature is currently in preview and only supports data disks.

Limitations:

You can now expand your data disks without deallocating your VM.

The preview for this has the following limitations:

  • Only supported for data disks.
  • If a disk is 4 TB or less, you can’t expand it beyond 4 TB without deallocating the VM. If a disk is already greater than 4 TB, you can expand it without deallocating the VM.
  • Not supported for Ultra disks, Premium SSD v2 (preview) disks, or standard HDDs.
  • Not supported for shared disks.
  • Install and use either:

Steps to expand data disks without downtime.

To enable this functionality you will have to register for LiveResize feature for your subscription. You can use the following command to enable this feature:

Register-AzProviderFeature -FeatureName "LiveResize" -ProviderNamespace "Microsoft.Compute"

It may take a few minutes for registration to complete. To confirm that you’ve registered, use the following command:

Get-AzProviderFeature -FeatureName "LiveResize" -ProviderNamespace "Microsoft.Compute"

Once you enable LiveResize feature, you can go ahead and follow below steps:

  1. In the left menu under Settings, select Disks.Screenshot that shows the Disks option selected in the Settings section of the menu.
  2. Under Disk name, select the disk you want to expand.Screenshot that shows the Disks pane with a disk name selected.
  3. In the left menu under Settings, select Size + performance.Screenshot that shows the Size and performance option selected in the Settings section of the menu.
  4. In Size + performance, select the disk size you want. Screenshot that shows the Size and performance pane with the disk size selected.
  5. Select Resize at the bottom of the page.Screenshot that shows the Size and performance pane with the Resize button selected.

Expand volume in the operating system

Windows requires you to perform few additional steps to reflect these changes at the server. You won’t see the changes within the machine unless you use DiskPart or Disk Manager. I usually prefer disk manager since this gives a user interface and makes the navigation easy. But in case you have a limitation, you can go ahead and use diskpart command line utility as well.

Using DiskPart

  1. Open an RDP connection to your VM.
  2. Open a command prompt and type diskpart.
  3. At the DISKPART prompt, type list volume. Make note of the volume you want to extend.
  4. 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.
  5. At the DISKPART prompt, type extend [size=<size>]. This extends the selected volume by size in megabytes (MB).

Using Disk Manager

  1. Start a remote desktop session with the VM.
    1. Open Disk Management.Screenshot showing Disk Management.
  2. Right-click on existing C: drive partition -> Extend Volume.Screenshot showing how to extend the volume.
  3. Follow the steps you should be able to see the disk with updated capacity:Screenshot showing the larger C: volume in Disk Manager.