How to increase the Azure VM Disk size on Linux.

When working with an Azure Linux Virtual Machine (VM), you may need to expand the root disk (OS disk) or data disk to accommodate growing storage requirements. This guide walks you through increasing the disk size from the Azure portal and resizing partitions within the Linux VM.
💡 Note: Make ensure that you have taken necessary backups before you start performing the below activities.
Step 1: Expand Disk Size from Azure Portal
Before partitions inside the VM are resized, the disk size must be increased from the Azure portal.
For Root Disk (OS Disk)
- Go to the Azure Portal (portal.azure.com) and navigate to Virtual Machines.
- Select your Linux VM and go to Disks in the left menu.
- Click on the OS Disk and select Size + Performance.
- Increase the disk size (e.g., 30GB to 64GB).
- Click Save to apply changes.
For Data Disk
- In the Disks section, locate the attached data disk.
- Click on the data disk and increase the size.
- Click Save to apply changes.
💡 Note: You may need to restart the VM for the changes to take effect.
Step 2: Resize Partitions Inside Linux VM
Once the disk is expanded in Azure, log in to the VM and resize the partition.
SSH into the Virtual Machine
Use an SSH client (e.g., PuTTY or Terminal) to connect:
ssh user@your-vm-ip
Verify the Disk Size
Run the following commands to check if the disk reflects the new size:
lsblk
You should see the increased disk size, but the partition may still show the old size.
df -h
This command displays the mounted file systems and their sizes.
Step 3: Expand the Root Disk Partition
The root partition must be resized to utilize the additional space.
For LVM-Based Systems
- Check the Volume Group Name:
sudo vgs
- Extend the Logical Volume:
sudo lvextend -l +100%FREE /dev/mapper/rootvg-rootlv
- Resize the Filesystem:
sudo resize2fs /dev/mapper/rootvg-rootlv
- Verify the Changes:
df -h
For Non-LVM Systems
- Resize the Partition:
sudo growpart /dev/sda 2
- Expand the Filesystem:
sudo resize2fs /dev/sda2
- Confirm the Changes:
df -h
Step 4: Expand the Data Disk Partition
If you have attached additional data disks, follow these steps.
- Identify the Data Disk Partition:
lsblk
Look for disks like /dev/sdb
.
- Resize the Partition:
sudo growpart /dev/sdb 1
- Resize the Filesystem:
- For ext4 Filesystem
sudo resize2fs /dev/sdb1
- For XFS Filesystem:
sudo xfs_growfs /mnt/data
- Verify the Expansion:
df -h
Step 5: Restart the VM (If Needed)
If the changes are not reflected, restart the VM:
sudo reboot
After rebooting, verify the storage changes using:
df -Th
Hope the blog helps you.