Expand OS disk on a Linux VM using the Azure CLI with the Azure CLI 1.0
The default virtual hard disk size for the operating system (OS) is typically 30 GB on a Linux virtual machine (VM) in Azure. You can add data disks to provide for additional storage space, but you may also wish to expand the OS disk. This article details how to expand the OS disk for a Linux VM using unmanaged disks with the Azure CLI 1.0.
CLI versions to complete the task
You can complete the task using one of the following CLI versions:
- Azure CLI 1.0 – our CLI for the classic and resource management deployment models (this article)
- Azure CLI 2.0 - our next generation CLI for the resource management deployment model
azure config mode arm
In the following samples, replace example parameter names with your own values. Example parameter names include myResourceGroup and myVM.
Expand OS disk
Operations on virtual hard disks cannot be performed with the VM running. The following example stops and deallocates the VM named myVM in the resource group named myResourceGroup:
azure vm deallocate --resource-group myResourceGroup --name myVM
azure vm stopdoes not release the compute resources. To release compute resources, use
azure vm deallocate. The VM must be deallocated to expand the virtual hard disk.
Update the size of the unmanaged OS disk using the
azure vm setcommand. The following example updates the VM named myVM in the resource group named myResourceGroup to be 50 GB:
azure vm set \ --resource-group myResourceGroup \ --name myVM \ --new-os-disk-size 50
Start your VM as follows:
azure vm start --resource-group myResourceGroup --name myVM
SSH to your VM with the appropriate credentials. To verify the OS disk has been resized, use
df -h. The following example output shows the primary partition (/dev/sda1) is now 50 GB:
Filesystem Size Used Avail Use% Mounted on udev 1.7G 0 1.7G 0% /dev tmpfs 344M 5.0M 340M 2% /run /dev/sda1 49G 1.3G 48G 3% /