Expand the OS drive of a Virtual Machine (ARM)

05 Jun Expand the OS drive of a Virtual Machine (ARM)

Azure1

 

When you create a virtual machine (VM) in a Resource Group from Azure Marketplace, the default OS drive is 127 GB. Despite the fact that it’s recommended to add data disks to the VM  for applications and CPU intensive workloads installation, in many cases customers need to extend the OS drive to support certain situations, for example:

Support old/legacy applications.

Lift and Shift scenarios (On Prem to Cloud)

Steps to resize the disk

  1. Sign-into your Microsoft Azure account using Power Shell:
Command
Login – AzureRmAccount

Select – AzureRmSubscription – SubscriptionName ‘my-subscription-name’

  1. Select your Resource group name and VM name:
Command
$rgName = ‘my-resource-group-name’

$vmName = ‘my-vm-name’

 

  1. Get a reference to your Virtual Machine:
Command
$vm = Get-AzureRmVM -ResourceGroupName $rgName -Name $vmName

 

  1. Stop the Virtual Machine.
Command
Stop-AzureRmVM -ResourceGroupName $rgName -Name $vmName

 

  1. Set the OS disk size to desired value, greater than the current size and less than 1023 (maximum)
Command
$vm.StorageProfile.OSDisk.DiskSizeGB = 1023

Update-AzureRmVM -ResourceGroupName $rgName -VM $vm

 

  1. Start the team VM after above command is completed
Command
Start-AzureRmVM -ResourceGroupName $rgName -Name $vmName

 

And that’s done! Now RDP into the Virtual Machine, Open Disk Management and expand the drive using the new space.

Nikhil Verma
nikhil.verma@mismosystems.com
1Comment
  • Bablofil
    Posted at 23:54h, 10 June Reply

    Thanks, great article.

Post A Comment