Azure managed disks: types, data disks, snapshots, resize
-
Phase 0: Before you start
-
Phase 1: The foundation
-
Phase 2: Day-to-day operations
-
Phase 3: Enterprise architecture
-
Phase 4: Troubleshooting step by step
-
Phase 5: Final project and career
Azure managed disks are the hard drives of your VMs. Azure stores them and keeps three copies, and you get to pick the speed, grow them and take snapshots. A lot of everyday VM tickets end up being about a disk: “the server is full”, “the app is slow”, “I deleted a file”.
We’ll go through the disk types, then add a data disk to web01, take a snapshot and restore a file from it, and grow a disk without rebooting.
You’ll also break a VM’s boot on purpose by leaving one word out of /etc/fstab, a mistake that causes real outages somewhere every week.
| Time | You need | Cost | By the end you can |
|---|---|---|---|
| About 60 minutes | web01 from Lesson 15, the CLI | A few US cents: two 4 GiB Standard SSD disks and a small snapshot for about an hour | Add, format, snapshot, restore and grow a data disk, and keep a VM bootable when a disk goes missing |
What it is, in one line
A managed disk is a virtual hard drive that Azure stores and replicates for you, and you decide its type, size and speed.
In Simple Words
Notebooks in a school locker
Think of a VM as a student and its disks as notebooks. The OS disk is the main notebook the student comes with, and data disks are extra notebooks you add for each subject so the maths notes don’t fill up the main one. A snapshot is a photocopy of a notebook on a given day, so if someone tears out a page you copy it back from the photocopy. And a bigger notebook is no use until you draw lines on the new pages, which is why a grown disk needs one more step inside Linux before you can use the space.
Engineer's View
Disk types, sizes and the details that matter
- Standard HDD (sizes named S4, S6 and up): cheapest, slow, fine for backups and dev/test.
- Standard SSD (E1, E2 and up): steady low latency for web servers and light apps.
- Premium SSD (P1 to P80): the usual production choice, where IOPS and MB/s go up with size. A 64 GiB P6 gives 240 IOPS while a 1 TiB P30 gives 5,000.
- Premium SSD v2 and Ultra Disk: here you set IOPS and throughput separately from size. They’re for data disks only, not OS disks, and they have their own lesson (Lesson 58).
- Billing is by tier, not bytes: a 33 GiB disk gets billed as the 64 GiB tier, so choose sizes that sit on the tier boundaries (4, 8, 16, 32, 64, 128 GiB and so on).
- Two speed limits apply: the disk has its limit and the VM size has its own disk limit, and whichever is lower wins. Put a fast disk on a small VM and it’s still slow.
- Host caching: ReadWrite for OS disks, ReadOnly for read-heavy data, None for write-heavy logs.
- Disk states: Attached (VM running), Reserved (VM deallocated), Unattached (no VM, still billed).
- Zones: a zonal VM can only use disks in the same zone.
- Snapshots: incremental snapshots keep only the changed blocks, on Standard storage, though the first one holds all the used data. They’re crash-consistent, a bit like pulling the power cord, so for databases either stop the app first or use Azure Backup (Lesson 35).
- Grow, never shrink: most data disks up to 4 TiB can grow while the VM is running, but shrinking isn’t supported.
Linux names disks sda, sdb, sdc in the order it finds them, and that order can change between boots. So in /etc/fstab use the /dev/disk/azure/scsi1/lun0 links and UUIDs, and never /dev/sdc.
How it works, step by step
Growing a data disk means four layers have to catch up, one after the other:
- Azure disk:
az disk update --size-gb 8grows the disk in storage while the VM keeps running. - Kernel: Linux picks up the new size by itself, or you tell it with a rescan.
- Partition:
growpartstretches partition 1 to the end of the disk. - Filesystem:
resize2fs(ext4) orxfs_growfs(XFS) fills out the bigger partition, and only at this point doesdfshow the new size.
At boot Linux reads /etc/fstab and mounts each line. If the disk on a line is missing and that line has no nofail, systemd waits about 90 seconds and then drops into emergency mode, which on Azure means no SSH, no Run Command, and a VM that still looks “Running” in the portal.
So every data disk line in fstab gets nofail. Then the VM boots without the disk and only the app complains, instead of the whole server going dark.
Hands-on lab: Azure managed disks on web01
Before you run any command, double-check it
Read every command twice before you press Enter. Check the target: the system or account, the IDs, the names and the sizes. These commands are for learning and were tested in our lab, not on your system. At work, run the read-only list commands first, follow your change process, make sure a backup exists, and ask a second person to check anything that changes or deletes data. You run them at your own risk.
You’ll add a data disk to web01, put a file on it, snapshot it, “lose” the file and then get it back. Start web01 and look at the disks you already have:
1Start web01 and list your disks
Run this:
az vm start --resource-group rg-saat-vms --name web01
az vm boot-diagnostics enable --resource-group rg-saat-vms --name web01
az disk list --resource-group rg-saat-vms --query "[].{name:name, sku:sku.name, sizeGb:diskSizeGB, tier:tier, state:diskState, zone:zones[0]}" -o tableYou should see something like this:
Name Sku SizeGb Tier State Zone
----------------------------------------------- ----------- -------- ------ -------- ------
web01_OsDisk_1_4c9e1d0b7a2f4e6c9b8a1d2e3f4a5b6c Premium_LRS 64 P6 Attached 1
win01_OsDisk_1_8f2a6c4e1b3d4f7a9c0e2b4d6f8a0c1e Premium_LRS 64 P6 Reservedweb01’s disk shows Attached because the VM is running, while win01 is deallocated so its disk shows Reserved. Boot diagnostics is switched on now too, and you’ll need it in the Break It lab.
2Create a 4 GiB data disk and attach it
Run this:
az disk create --resource-group rg-saat-vms --name web01-data01 --size-gb 4 --sku StandardSSD_LRS --zone 1 --tags course=saatvedha-azure lesson=19 -o none
az vm disk attach --resource-group rg-saat-vms --vm-name web01 --name web01-data01 --lun 0 --caching ReadOnly
az vm show --resource-group rg-saat-vms --name web01 --query "storageProfile.dataDisks[].{lun:lun, name:name, caching:caching}" -o tableYou should see this:
Lun Name Caching
----- ------------ ---------
0 web01-data01 ReadOnlyDon’t skip --zone 1: web01 lives in zone 1, so its disks have to be there as well. B2ats_v2 takes up to 4 data disks, and bigger sizes take more.
3Partition, format and mount it
Save this script on your laptop. The last line writes it with Linux line endings, because Windows line endings break bash:
$s = @'
set -e
D=$(readlink -f /dev/disk/azure/scsi1/lun0)
parted $D --script mklabel gpt mkpart data ext4 0% 100%
partprobe $D; sleep 2
mkfs.ext4 -q -L data ${D}1
mkdir -p /data
U=$(blkid -s UUID -o value ${D}1)
echo "UUID=$U /data ext4 defaults,nofail 0 2" >> /etc/fstab
mount -a
echo "invoice batch 2026-10-20" > /data/hello.txt
lsblk -o NAME,SIZE,MOUNTPOINT $D
df -h /data
'@
[IO.File]::WriteAllText('C:\azure-lab\disk-setup.sh', $s.Replace("`r`n", "`n"))Run it on web01:
az vm run-command invoke --resource-group rg-saat-vms --name web01 --command-id RunShellScript --scripts '@C:\azure-lab\disk-setup.sh' --query "value[0].message" -o tsvYou should see something like this:
Enable succeeded:
[stdout]
NAME SIZE MOUNTPOINT
sdb 4G
└─sdb1 4G /data
Filesystem Size Used Avail Use% Mounted on
/dev/sdb1 3.9G 24K 3.7G 1% /data
[stderr]The script finds the disk by its LUN and not its name, so it doesn’t matter whether yours turned up as sdb or sdc. The fstab line uses the UUID and nofail.
4Take an incremental snapshot
Run this:
az snapshot create --resource-group rg-saat-vms --name snap-web01-data01 --source web01-data01 --incremental true --sku Standard_LRS --tags course=saatvedha-azure lesson=19 -o none
az snapshot show --resource-group rg-saat-vms --name snap-web01-data01 --query "{name:name, incremental:incremental, sku:sku.name, sizeGb:diskSizeGB}" -o tableYou should see this:
Name Incremental Sku SizeGb
----------------- ------------- ------------ --------
snap-web01-data01 True Standard_LRS 45Lose the file, then restore it from the snapshot
Delete the file, the way a user would by mistake:
az vm run-command invoke --resource-group rg-saat-vms --name web01 --command-id RunShellScript --scripts 'rm /data/hello.txt; ls /data' --query "value[0].message" -o tsvMake a new disk from the snapshot and attach it as LUN 1:
az disk create --resource-group rg-saat-vms --name web01-data01-restore --source snap-web01-data01 --sku StandardSSD_LRS --zone 1 --tags course=saatvedha-azure lesson=19 -o none
az vm disk attach --resource-group rg-saat-vms --vm-name web01 --name web01-data01-restore --lun 1Mount it read-only, copy the file back and unmount:
az vm run-command invoke --resource-group rg-saat-vms --name web01 --command-id RunShellScript --scripts 'mkdir -p /restore; mount -o ro /dev/disk/azure/scsi1/lun1-part1 /restore; cp /restore/hello.txt /data/; umount /restore; cat /data/hello.txt' --query "value[0].message" -o tsvYou should see this:
Enable succeeded:
[stdout]
invoice batch 2026-10-20
[stderr]You’ve copied one file back without touching anything else on the live disk. Now detach the restore disk so you don’t leave two disks with the same UUID on one VM:
az vm disk detach --resource-group rg-saat-vms --vm-name web01 --name web01-data01-restore
az disk delete --resource-group rg-saat-vms --name web01-data01-restore --yes6Find disks nobody is using
You’ll run this query in every cost review, because detached disks keep on billing:
az disk list --query "[?diskState=='Unattached'].{name:name, group:resourceGroup, sizeGb:diskSizeGB, sku:sku.name}" -o tableIf the restore disk was deleted properly, the list comes back empty. In a real subscription it hardly ever does.

✅ Checkpoint: /data on web01 is mounted from web01-data01, hello.txt is back, and only the snapshot and web01-data01 are left from this lesson.
Break It, Then Fix It
Keep web01 running for this part. Both of these breaks happen on real servers all the time.
1Break it: grow the disk, but Linux still shows the old size
Grow the disk to 8 GiB while web01 is running, then check it:
az disk update --resource-group rg-saat-vms --name web01-data01 --size-gb 8 -o none
az vm run-command invoke --resource-group rg-saat-vms --name web01 --command-id RunShellScript --scripts 'lsblk -o NAME,SIZE,MOUNTPOINT /dev/disk/azure/scsi1/lun0; df -h /data' --query "value[0].message" -o tsvYou’ll see something like this:
[stdout]
NAME SIZE MOUNTPOINT
sdb 8G
└─sdb1 4G /data
Filesystem Size Used Avail Use% Mounted on
/dev/sdb1 3.9G 28K 3.7G 1% /dataThe disk is 8G but the partition and filesystem are still at 4G. If even the disk still shows 4G, the kernel hasn’t caught up yet, and the rescan below sorts that out too. This is the classic “I resized it and nothing changed” ticket.
Fix it: rescan, then grow the partition, then grow the filesystem:
az vm run-command invoke --resource-group rg-saat-vms --name web01 --command-id RunShellScript --scripts 'D=$(readlink -f /dev/disk/azure/scsi1/lun0); echo 1 > /sys/class/block/$(basename $D)/device/rescan; growpart $D 1; resize2fs ${D}1; df -h /data' --query "value[0].message" -o tsvYou should see something like this:
[stdout]
CHANGED: partition=1 start=2048 old: size=8384512 end=8386559 new: size=16775135 end=16777182
Filesystem Size Used Avail Use% Mounted on
/dev/sdb1 7.8G 28K 7.4G 1% /data
[stderr]
resize2fs 1.47.0 (5-Feb-2023)
Filesystem at /dev/sdb1 is mounted on /data; on-line resizing requiredresize2fs prints its progress to stderr, so don’t worry about that part. df now shows 7.8G and the app kept running the whole time.
2Break it: one missing word in /etc/fstab
Take nofail out of the line (plenty of old guides leave it out anyway), detach the disk and restart:
az vm run-command invoke --resource-group rg-saat-vms --name web01 --command-id RunShellScript --scripts 'sed -i /data/s/defaults,nofail/defaults/ /etc/fstab; grep /data /etc/fstab' --query "value[0].message" -o tsv
az vm disk detach --resource-group rg-saat-vms --vm-name web01 --name web01-data01
az vm restart --resource-group rg-saat-vms --name web01 --no-wait
Start-Sleep -Seconds 240
az vm boot-diagnostics get-boot-log --resource-group rg-saat-vms --name web01 | Select-String -Pattern 'Timed out|Dependency failed|emergency|locked'You’ll see something like this:
[ TIME ] Timed out waiting for device dev-disk-by\x2duuid-0b6c1f3e-....device - /dev/disk/by-uuid/0b6c1f3e-...
[DEPEND] Dependency failed for data.mount - /data.
[DEPEND] Dependency failed for local-fs.target - Local File Systems.
You are in emergency mode. After logging in, type "journalctl -xb" to view system logs,
Cannot open access to console, the root account is locked.Now web01 is stuck. The portal says “Running”, but SSH and Run Command can’t reach it because the agent never started, and since Ubuntu’s root account is locked you can’t log in through the Serial Console either (Lesson 60 covers the full rescue).
Fix it: give the VM its disk back and restart it, then put nofail back in:
az vm disk attach --resource-group rg-saat-vms --vm-name web01 --name web01-data01 --lun 0 --caching ReadOnly
az vm restart --resource-group rg-saat-vms --name web01
az vm run-command invoke --resource-group rg-saat-vms --name web01 --command-id RunShellScript --scripts 'sed -i /data/s/defaults/defaults,nofail/ /etc/fstab; grep /data /etc/fstab; df -h /data' --query "value[0].message" -o tsvYou should see something like this:
[stdout]
UUID=0b6c1f3e-... /data ext4 defaults,nofail 0 2
Filesystem Size Used Avail Use% Mounted on
/dev/sdb1 7.8G 28K 7.4G 1% /dataTo clean up, remove the fstab line first, then the disk and the snapshot, and then stop web01:
az vm run-command invoke --resource-group rg-saat-vms --name web01 --command-id RunShellScript --scripts 'umount /data; sed -i /data/d /etc/fstab' -o none
az vm disk detach --resource-group rg-saat-vms --vm-name web01 --name web01-data01
az disk delete --resource-group rg-saat-vms --name web01-data01 --yes
az snapshot delete --resource-group rg-saat-vms --name snap-web01-data01
az vm deallocate --resource-group rg-saat-vms --name web01
C:\azure-lab\Find-LabResources.ps1 -Lesson 19You should see this:
Nothing tagged course=saatvedha-azure is left.
✅ Checkpoint: You grew a live disk, rescued an unbootable VM, and web01 is deallocated with only its OS disk.
This happened at work
The 2 a.m. patch reboot that didn’t come back
An insurance company patched its Linux app servers every second Sunday. One night three of the twelve VMs didn’t come back after the reboot, and while the portal showed them as Running, SSH timed out and the monitoring agent had gone quiet.
The on-call engineer opened boot diagnostics and found the same screen on all three: “Timed out waiting for device” and emergency mode. Weeks earlier somebody had detached an old log disk from those VMs to save money, but the fstab lines were still there without nofail, and nothing showed up until the next reboot.
What they changed: to get past the boot, the engineer attached a small empty disk at the same LUN and then removed the stale lines. The build template now writes every data disk line with UUID and nofail, and a weekly check compares the fstab entries against the disks Azure says are attached.
Common mistakes and troubleshooting
| Mistake | What you see | What to do |
|---|---|---|
| Data disk in fstab without nofail | VM hangs in emergency mode after a reboot | Always add nofail, and mount by UUID. |
| Mounting /dev/sdc in fstab | The wrong disk mounts after a reboot | Use UUID= or /dev/disk/azure/scsi1/lunN instead. |
| Grew the disk, skipped growpart/resize2fs | df still shows the old size | Rescan, run growpart, then resize2fs or xfs_growfs. |
| Disk created without the VM’s zone | Attach fails | Create the disk in the VM’s zone. |
| Buying size instead of speed | App slow on a big Standard HDD | Look at the tier’s IOPS and the VM size’s disk limit. |
| Deleted VMs, forgot the disks | Bill keeps growing | Run the Unattached disk query once a month. |
| Treating a snapshot as a backup plan | No history, no app-consistent copy | Use Azure Backup for policies and retention (Lesson 35). |
Interview questions
Click a question to open it. Each one is phrased the way an interviewer would ask it, and underneath you’ll find why they ask it and one way you could answer in your own words.
Fresher level
1. What managed disk types does Azure offer?
Why they ask this: It’s a quick check that you know the options.
How you might answer: There’s Standard HDD, Standard SSD, Premium SSD, Premium SSD v2 and Ultra Disk. Standard is for low cost or dev/test and Premium SSD is the normal production pick, while Premium SSD v2 and Ultra let you set IOPS and throughput separately, which suits databases.
2. What’s the difference between an OS disk and a data disk?
Why they ask this: They want to know you understand how a VM is laid out.
How you might answer: The OS disk holds the operating system and boots the VM, and data disks are the extra ones for application data, logs or databases. Keeping data separate lets you resize, snapshot or move it without going near the OS.
3. You added space to a disk in the portal but Linux doesn’t show it. Why?
Why they ask this: It’s one of the first tickets most people get.
How you might answer: Growing the Azure disk doesn’t grow the partition or the filesystem. I’d rescan the disk if needed, run growpart on the partition, and then resize2fs or xfs_growfs on the filesystem.
2–5 years experience
4. A Linux VM won’t boot after someone removed a data disk. What happened and how do you fix it?
Why they ask this: They want to see fstab knowledge and calm troubleshooting.
How you might answer: My first guess is that the fstab line for that disk has no nofail, so systemd waited for it and dropped into emergency mode. I’d confirm that in boot diagnostics. The quickest way out is to attach the disk again, or a blank one at the same LUN, restart, and then fix fstab.
Longer term, I’d make sure every data disk line uses UUID and nofail.
5. An app on a Premium SSD is slow. What do you check?
Why they ask this: They want to hear about both limits.
How you might answer: I’d start with the disk tier’s IOPS and throughput limits and see whether the metrics show we’re hitting them. Then I’d check the VM size’s own disk limit, because the lower of the two wins. After that I’d look at caching, and on smaller Premium disks whether the bursting credits have run out.
6. How do you restore one file from a managed disk snapshot?
Why they ask this: They’re after a practical method, not “restore the whole VM”.
How you might answer: I’d create a new disk from the snapshot in the same zone, attach it to the VM or to a helper VM, mount it read-only and copy the file across. Then I’d detach and delete that temporary disk so the server isn’t left with two disks sharing one filesystem UUID.
Senior level
7. How would you control disk costs across a large estate?
Why they ask this: They want ongoing governance, not one-off cleanups.
How you might answer: I’d run regular Resource Graph reports for Unattached disks and old snapshots, tag everything with an owner and expiry, and have automation flag what’s left over. I’d also size on tier boundaries, move idle data to cheaper types, and make sure VM delete options remove OS disks where that’s what we want.
8. When would you choose Premium SSD v2 over Premium SSD?
Why they ask this: They want reasoning about cost and performance.
How you might answer: When a database needs high IOPS on not much data. With Premium SSD I’d have to buy a big disk just to get the IOPS, whereas Premium SSD v2 lets me set capacity, IOPS and throughput separately, often for less money. It can’t be an OS disk though, and I’d check it’s supported in the region and zone.
9. Are disk snapshots enough to protect a production database?
Why they ask this: They want to see if you understand the limits of crash consistency.
How you might answer: No. A snapshot is crash-consistent, like pulling the power cord, and it only covers one disk at a time. For a database I’d rely on Azure Backup or the database’s own backups to get application-consistent copies, retention policies and restores we’ve actually tested. Snapshots are handy for a quick rollback before a change.
Quick quiz
Q1. A 33 GiB Premium SSD is billed as which size?
- 33 GiB
- 32 GiB
- 64 GiB
- 128 GiB
Show answer
C — Disks are billed by tier; 33 GiB rounds up to the 64 GiB P6 tier.
Q2. A disk on a deallocated VM shows which state?
- Attached
- Reserved
- Unattached
- Stopped
Show answer
B — Reserved means it belongs to a deallocated VM.
Q3. What makes a Linux VM boot when a data disk is missing?
- noatime
- nofail in /etc/fstab
- ReadOnly caching
- A bigger OS disk
Show answer
B — nofail lets boot continue without that disk.
Q4. After az disk update grows a disk, what else is needed in Linux?
- Nothing
- A reboot only
- growpart and resize2fs
- A new VM
Show answer
C — The partition and filesystem must grow too.
Q5. A zonal VM in zone 1 can use disks from:
- Any zone
- Zone 1 only
- Regional disks only
- Another region
Show answer
B — Disks for a zonal VM must be in the same zone.
Quick recap
You can now deal with the disk tickets that make up a big chunk of VM support.
- Standard HDD, Standard SSD, Premium SSD, Premium SSD v2 and Ultra differ in speed and price.
- You’re billed by tier, and speed is whichever is lower: the disk limit or the VM size limit.
- Find data disks by LUN, and mount them by UUID with nofail.
- Growing a disk needs growpart and resize2fs (or xfs_growfs) inside Linux.
- To restore a file, create a disk from a snapshot and mount it read-only.
Next lesson
Lesson 20: Images, Azure Compute Gallery and VM scale sets → Next you’ll capture web01 as an image and run a set of identical web VMs that Azure can grow and shrink for you.
Further reading: Azure managed disks
Want to go deeper into Azure managed disks? See Microsoft’s Azure managed disk types and Expand virtual hard disks on a Linux VM. You can also see the full plan for this course on the Azure Cloud Administration course page.
