Lesson 3 of 5 Azure Virtual Machines

Managing Virtual Machine Disks

This lesson explains disk roles, managed disk types, caching and the operations administrators perform on disks.

Learning outcomes

After completing this lesson, you will be able to:

  • Describe the OS, data and temporary disks.
  • Distinguish between the managed disk types.
  • Explain how disks are added, expanded, converted and snapshotted.

Disk roles

Every VM has an OS disk containing the operating system, a managed disk that persists when the VM is stopped. Most sizes also have a temporary disk (D: on Windows, /dev/sdb1 or /mnt on Linux) on the host's local storage, used for page or swap files; its data is lost when the VM is deallocated, resized or moved to another host. Data disks are managed disks attached for application data, up to the size's limit.

Sort into groups

Which disk holds it?

Exam skills 3.2.5

Decide which disk each kind of data belongs on.

Log in to try this activity Interactive activities are free with an account.

Disk types

Managed disks come in five types. Standard HDD suits backups and infrequent access. Standard SSD suits web servers and light production. Premium SSD suits production and performance-sensitive workloads, with IOPS and throughput tied to the disk size tier (for example P30, 1 TiB). Premium SSD v2 lets capacity, IOPS and throughput be set independently and changed without downtime, but cannot be an OS disk. Ultra Disk offers the highest performance with sub-millisecond latency for transaction-heavy databases, also data disks only. Premium SSD v2 and Ultra Disk have regional and zonal availability limits.

Standard HDD
MediaHDD
OS diskYes
PerformanceLowest
Choose when Backups, dev/test
Standard SSD
MediaSSD
OS diskYes
PerformanceModerate
Choose when Light production
Premium SSD
MediaSSD
OS diskYes
PerformanceScales with disk size
Choose when Production
Premium SSD v2 / Ultra
MediaSSD
OS diskNo
PerformanceConfigured independently of size
Choose when Databases needing tuned IOPS

Disks use LRS by default, and Premium SSD and Standard SSD are also available as ZRS disks that survive a zone failure. Host caching is set per disk: ReadOnly for read-heavy data such as database data files, ReadWrite for the OS disk, and None for write-heavy data such as logs.

The following diagram compares Premium SSD with Premium SSD v2 for a disk that needs more IOPS without more capacity.

Getting more IOPS without more capacity. Premium SSD ties IOPS to the size tier, so more IOPS means a bigger disk with capacity that is not needed. Premium SSD v2 sets IOPS independently of capacity and changes it online, so the data moves to a v2 disk with the required IOPS.
The scenario is illustrative.
Scenario questions

Choosing a disk type and caching

Exam skills 3.2.5

Choose the disk type or host caching setting for each requirement.

Log in to try this activity Interactive activities are free with an account.

Managing disks

New data disks are added on the VM's Disks page (or with az vm disk attach --new --size-gb) and must be initialized, partitioned and formatted inside the operating system. A disk's size can be increased, for some types without deallocating the VM, but never decreased; after expanding, the partition and file system must be extended in the guest. A disk's type can be changed, for example from Standard SSD to Premium SSD, while the VM is deallocated (or online for some conversions).

Snapshots are read-only point-in-time copies of a disk, full or incremental (only changes since the last snapshot, cheaper), used to create new disks or back up before changes. Shared disks attach one Standard SSD, Premium SSD, Premium SSD v2 or Ultra disk to several VMs for clustered applications such as Windows Server Failover Clustering. Unattached disks continue to be billed, so Azure Advisor flags them.

True or false

Working with disks

Exam skills 3.2.5

Check how disks are added, expanded, copied and shared.

Log in to try this activity Interactive activities are free with an account.
Worked example

Running out of disk performance

A SQL Server VM uses a 512 GiB Premium SSD data disk. Monitoring shows the disk constantly at its IOPS limit, while capacity use is only 30%. The administrator wants more IOPS without paying for more capacity and without downtime. The region supports all disk types. What should you recommend?

With Premium SSD, IOPS grow only with a larger size tier, which adds unneeded capacity. A Premium SSD v2 (or Ultra) data disk lets IOPS be set independently of capacity and changed online, so migrate the data to a Premium SSD v2 disk with the required IOPS. Also check that the VM size's disk IOPS limit is high enough, because the VM can cap disk performance. Enabling ReadWrite caching on a database data disk risks data loss and is not recommended.

Check yourself

Can a managed disk be made smaller?

Show answer

No. Disks can be expanded but never shrunk.

Exam Tips

Remember for the exam

  • Data on the temporary disk is lost on deallocation or redeployment.
  • Disks can be expanded, never shrunk; extend the partition in the guest.
  • Premium SSD v2 and Ultra Disk cannot be OS disks.
  • ReadOnly caching for read-heavy data, None for write-heavy logs.