DevOps Peach

Azure Basics · Virtual Machines – Sizes, Disks, Connecting, Availability and Scale Sets · Lesson 2 of 5

VM Disks — OS, Temporary and Data Disks

Every VM has an OS disk and often a temporary disk (data lost on deallocate/redeploy); extra data disks are managed disks of type Standard HDD/SSD, Premium SSD, Premium SSD v2 or Ultra.

Practice interactively →

flowchart TB
  VM["vm-web"] --> OS["OS disk (managed)<br/>/dev/sda, C:"]
  VM --> T["Temporary disk (on the host)<br/>/mnt or D: — may be lost"]
  VM --> DD["Data disk data1 (managed)<br/>LUN 0"]
  OS --> ST[("Azure Storage")]
  DD --> ST
Disk Behaviour
OS disk Holds the operating system; a durable managed disk
Temporary disk On the physical host, fast; data is lost when the VM is deallocated, resized, redeployed or the host fails — use it only for swap/cache. Some newer sizes have no temp disk
Data disk Added for application data; each size limits the maximum number of disks

Managed disk types

Type Used for
Standard HDD (Standard_LRS) Backups, rarely used dev/test
Standard SSD (StandardSSD_LRS) Web, dev/test needing consistency
Premium SSD (Premium_LRS) Production, databases
Premium SSD v2 / Ultra Very high IOPS, flexible performance tuning

az vm stop only shuts down the OS — compute is still billed; az vm deallocate releases the hardware (compute billing stops, the temp disk is wiped).

Command Meaning
az vm disk attach -g rg-devops-lab --vm-name vm-web --name data1 --new --size-gb 32 Create and attach a 32 GiB data disk
az vm deallocate -g rg-devops-lab -n vm-web Stop and end compute billing

Preparing a new data disk on Linux

lsblk                                   # find the new disk, e.g. sdc
sudo parted /dev/sdc --script mklabel gpt mkpart xfspart xfs 0% 100%
sudo mkfs.xfs /dev/sdc1
sudo mkdir -p /data && sudo mount /dev/sdc1 /data
sudo blkid /dev/sdc1                    # copy the UUID into /etc/fstab

Use the UUID in /etc/fstab with the nofail option, because device names like sdc can change between reboots.

Performance limits

A disk's IOPS and throughput depend on its type and size, and the VM size has its own caps. A fast disk on a small VM is limited by the VM, so check both. Premium SSD v2 and Ultra let you set IOPS and throughput separately from capacity. Smaller Premium SSDs can burst above their baseline for short periods.

Host caching stores disk reads on the host: ReadOnly suits database data disks, None suits write-heavy log disks, and ReadWrite is mainly for the OS disk.

Snapshots, images, and resizing

Encryption

All managed disks are encrypted at rest with platform-managed keys. You can use customer-managed keys through a disk encryption set, and encryption at host extends encryption to temporary disks and caches. For new deployments Microsoft recommends encryption at host over the older in-guest Azure Disk Encryption.

Delete disks you no longer need: a disk left after deleting its VM keeps costing money.

Practice interactively →