Overview and What You Will Learn
An Azure managed disk is a block storage volume that Azure creates, replicates and manages for a virtual machine, and its type decides the performance and cost you get. The right type depends on the IOPS, throughput and latency the workload needs, not on a general feeling that production deserves the best option. In this lab, you will attach a Standard SSD disk and a Premium SSD disk of the same size to one VM, mount both, and measure them with the same benchmark.
- Telling the five managed disk types apart and what each is built for
- Separating the OS disk from data disks
- Attaching, formatting and mounting a data disk using stable device paths
- Benchmarking two disk types with
fio - Spotting limits that come from the VM size and from caching
Why This Matters in Production
A team at a trading platform like Zerodha puts its production database on a Standard HDD because it was the cheapest option shown during setup. During peak hours, every query slows down. The database and the VM were fine, but the disk could not deliver the IOPS a transaction-heavy workload needs, and no amount of query tuning fixes a storage limit.
Core Principles
Azure offers five managed disk types. Standard HDD and Standard SSD suit cost-sensitive work, Premium SSD gives provisioned performance for production, and Premium SSD v2 and Ultra Disk let you tune performance independently of size.
production?} Q1 -->|No| Q2{Rarely accessed?} Q2 -->|Yes| HDD[Standard HDD] Q2 -->|No| SSD[Standard SSD] Q1 -->|Yes| Q3{Tune IOPS
independently?} Q3 -->|No| P[Premium SSD] Q3 -->|Yes| V[Premium SSD v2
or Ultra Disk] classDef start fill:#D1FAE5,color:#1E293B classDef dec fill:#F97316,color:#FFFFFF classDef low fill:#F1F5F9,color:#1E293B classDef std fill:#326CE5,color:#FFFFFF classDef top fill:#8B5CF6,color:#FFFFFF class W start class Q1,Q2,Q3 dec class HDD,SSD low class P std class V top
The types compare like this:
| Disk type | Typical use | Key trait |
|---|---|---|
| Standard HDD | Backups, rarely accessed data, dev and test | Lowest cost, variable latency |
| Standard SSD | Web servers, light apps, dev and test | Consistent latency at low cost |
| Premium SSD | Production databases, I/O-heavy apps | Provisioned IOPS tied to disk size |
| Premium SSD v2 | Demanding databases, flexible tuning | IOPS and throughput set separately |
| Ultra Disk | Highest-end databases, very low latency | Highest limits, tunable on the fly |
Every VM has an OS disk, created with the VM, and can have separate data disks. Keeping application data on its own data disk lets you resize, snapshot, move or reattach it without touching the operating system. A disk's performance is also capped by the VM size it is attached to, so a fast disk on a small VM can still be throttled.
Detailed Step-by-Step Practical Lab
Set the variables used throughout the lab. The VM size supports Premium storage and has enough disk throughput for a meaningful comparison.
export RG=rg-disks-lab-indiaexport LOCATION=centralindiaexport VM=vm-disks-lab- Create the resource group and a VM. The
--storage-skuvalue sets the OS disk to Standard SSD, sinceStandard_LRSwould give you Standard HDD:
az group create --name $RG --location $LOCATION az vm create \ --resource-group $RG \ --name $VM \ --image Ubuntu2204 \ --size Standard_D2s_v5 \ --storage-sku StandardSSD_LRS \ --admin-username azureadmin \ --generate-ssh-keys- Create two 256 GiB data disks, one of each type, so the comparison is like for like:
az disk create \ --resource-group $RG \ --name disk-data-standard \ --size-gb 256 \ --sku StandardSSD_LRS az disk create \ --resource-group $RG \ --name disk-data-premium \ --size-gb 256 \ --sku Premium_LRS- Attach both disks to fixed LUNs with host caching turned off, so caching does not skew the benchmark:
az vm disk attach --resource-group $RG --vm-name $VM \ --name disk-data-standard --lun 0 --caching None az vm disk attach --resource-group $RG --vm-name $VM \ --name disk-data-premium --lun 1 --caching None- Check each disk's SKU and performance tier. Premium SSD disks report a tier such as
P15, which maps to fixed IOPS and throughput limits in the Azure documentation:
az disk show --resource-group $RG --name disk-data-standard \ --query "{sku:sku.name, tier:tier, sizeGB:diskSizeGB}" --output table az disk show --resource-group $RG --name disk-data-premium \ --query "{sku:sku.name, tier:tier, sizeGB:diskSizeGB}" --output tableRememberThe
diskIOPSReadWriteproperty is filled in only for Premium SSD v2 and Ultra Disk, where you set IOPS yourself. For Premium SSD and Standard SSD, performance follows from the size tier, so look up the tier in the Azure managed disk documentation.
- Connect to the VM and look at the disks. Azure creates stable paths based on the LUN, so you do not have to guess names like
/dev/sdc:
az ssh vm --resource-group $RG --name $VM --local-user azureadmin lsblkls -l /dev/disk/azure/scsi1/- Format and mount both disks:
sudo mkfs.ext4 /dev/disk/azure/scsi1/lun0sudo mkfs.ext4 /dev/disk/azure/scsi1/lun1 sudo mkdir -p /mnt/standard /mnt/premiumsudo mount /dev/disk/azure/scsi1/lun0 /mnt/standardsudo mount /dev/disk/azure/scsi1/lun1 /mnt/premium- Make the mounts survive a reboot by using the disk UUID and
nofail, so a missing disk cannot block boot:
for LUN in 0 1; do UUID=$(sudo blkid -s UUID -o value /dev/disk/azure/scsi1/lun$LUN) [ $LUN = 0 ] && DIR=/mnt/standard || DIR=/mnt/premium echo "UUID=$UUID $DIR ext4 defaults,nofail 0 2" | sudo tee -a /etc/fstabdone- Benchmark both disks with the same random read and write test. Direct I/O bypasses the guest page cache:
sudo apt-get update && sudo apt-get install -y fio for DIR in /mnt/standard /mnt/premium; do echo "== $DIR" sudo fio --name=randrw --directory=$DIR --rw=randrw --rwmixread=70 \ --bs=4k --iodepth=32 --numjobs=1 --size=2G --runtime=30 --time_based \ --direct=1 --ioengine=libaio --group_reporting | grep -E "IOPS="doneCompare the IOPS lines. The Premium disk should show higher and steadier numbers. If both come out close to each other, the VM size's disk limit is probably the bottleneck, which is exactly the kind of cap the last best practice below describes.
- Exit the VM and clean up:
az group delete --name $RG --yes --no-waitProduction Best Practices & Common Pitfalls
Common MistakeChoosing Standard HDD or Standard SSD for a production database only to cut cost, without checking the workload's IOPS and latency needs against the disk's limits. The database can be tuned perfectly and still run slowly because the disk cannot keep up.
TipMeasure before you buy. Benchmark with a tool like
fio, or watch the disk IOPS and queue depth metrics in Azure Monitor on the existing system, then pick the cheapest tier whose limits clear your peak with headroom.
- Keep application data on a separate data disk. It can be resized, snapshotted and reattached to another VM independently of the operating system.
- Match the VM size to the disk. Each VM size has its own maximum IOPS and throughput across all its disks, so an undersized VM throttles even the fastest disk.
- Set host caching deliberately. ReadOnly caching often helps read-heavy database data files, while write-heavy disks and log volumes usually use None. Premium SSD v2 and Ultra Disk do not support host caching.
- Save Ultra Disk and Premium SSD v2 for workloads that need them. They allow independently tuned IOPS and throughput, but they have regional and zone requirements and cost more than a plain Premium SSD.
- Choose redundancy on purpose. Locally redundant storage (LRS) keeps copies in one datacenter, while zone-redundant storage (ZRS) survives a zone failure for supported disk types.
- Use stable device paths and UUIDs in
fstab. Device names such as/dev/sdccan change between reboots or when disks are added. - Encrypt according to your compliance needs. Managed disks are encrypted at rest by default with platform-managed keys, and a disk encryption set lets you use your own keys from Key Vault.
Quick Reference & Troubleshooting Commands
| Command | Description |
|---|---|
az disk create --sku Premium_LRS |
Create a Premium SSD disk |
az vm disk attach --lun N --caching None |
Attach a disk to a fixed LUN with chosen caching |
az disk show --query "{sku:sku.name, tier:tier}" |
Check a disk's SKU and size tier |
az disk update --size-gb N |
Grow a disk, which usually needs a VM restart or deallocation |
lsblk |
List block devices inside the VM |
ls -l /dev/disk/azure/scsi1/ |
Show stable LUN-based device paths |
| Problem | Cause | Fix |
|---|---|---|
| Premium disk will not attach | VM size does not support Premium storage | Use a size with an s in its name, such as Standard_D2s_v5 |
| Disk missing after reboot | Mounted by device name, or no fstab entry |
Mount by UUID with nofail |
| Disk is slower than expected | VM size or disk tier limit reached | Check the VM's disk limits and the disk's tier |
diskIOPSReadWrite is empty |
Property applies only to Ultra and Premium SSD v2 | Read the tier and look up its limits |
| Ultra Disk will not attach | VM is not zonal or has no Ultra support | Deploy in a supported zone with Ultra enabled |