Can you shrink an Azure managed disk?

Deleting files doesn’t reduce the cost: Azure charges a managed disk for its size, not its data.

Published 21 October 2026 · Updated 3 November 2026 · By Vineet (opens in a new tab), Infrastructure engineer, Zoorik

Shrink an Azure managed disk? Shrink in place is crossed out, so copy to a new disk instead

Short answer. No, you can’t shrink an Azure managed disk in place. Microsoft says shrinking an existing disk “isn’t supported and might result in data loss.” For a data disk, copy the data to a new, smaller disk, move the mount and delete the old disk. An OS disk needs a new VM.

How Azure charges a disk

Azure charges a managed disk for its provisioned size. It “maps the provisioned size (rounded up) to the nearest offered disk size”. So a 200 GiB Standard SSD is charged as the 256 GiB size, E15.

Premium SSD and Standard SSD sizes are fixed, doubling from 4 GiB to 32,767 GiB. A 512 GiB Premium SSD (P20) costs the same whether it holds 500 GiB or 5 GiB.

Premium SSD v2 has no fixed sizes. You pay for the GiB you provision, plus any IOPS and throughput above its free 3,000 IOPS and 125 MB/s.

Say a VM has four 512 GiB data disks, 2,048 GiB in all, holding 1,000 GiB. More than half of what you pay for, 1,048 GiB, is empty.

More than half of the 2,048 GiB you pay for holds no data One bar, drawn to scale from 0 to 2,048 GiB, with ticks at 0, 1,000 and 2,048 GiB. A bracket over the whole bar reads Charged: 4 disks × 512 GiB = 2,048 GiB. A violet segment from 0 to 1,000 is the data, 1,000 GiB. An amber segment from 1,000 to 2,048 is empty, 1,048 GiB or 51% of what you pay for. More than half of the 2,048 GiB you pay for holds no data Charged: 4 disks × 512 GiB = 2,048 GiBData 1,000 GiBEmpty 1,048 GiB, 51%01,0002,048 GiB
The four disks are set end to end, to scale. The bar shows how much of the size you pay for is empty, not which disk holds which data.

fstrim and the discard mount option tell Azure which blocks are free. Microsoft says this saves money on disks charged for the storage they consume, “such as unmanaged standard disks and disk snapshots.” A managed disk is charged for its size, so it isn’t one of them.

Azure can expand a data disk without deallocating the VM, with exceptions such as taking a Premium SSD past 4 TiB. When the data shrinks again, the size and its charge stay.

Why it can’t shrink in place

A disk is a block device, and its filesystem can place data in any block, including the last ones. Removing the end of the disk would destroy that data. A safe shrink must first move the data away from the end. Azure can’t do that from outside your VM.

A shrink in place destroys the data past the new end Illustration of one 512 GiB disk drawn as an outlined bar with 9 data blocks spread along it. An arrow from the disk's end to its midpoint is labelled shrink in place to 256 GiB, and a dashed line marks that new end through the disk. The 6 violet blocks before it are labelled data kept. The 3 red blocks past it are labelled data lost. A shrink in place destroys the data past the new end shrink in place to 256 GiB512 GiB diskdata keptdata lost
Illustration: the block positions are a shape, not a measurement, and 256 GiB is the next size down from 512 GiB.

The filesystem has limits of its own, covered in shrinking ext4 and shrinking XFS. Whatever the filesystem, on Azure the route is a copy.

Copy to a smaller disk

On a Linux VM, copy the data to a new, smaller disk in two rsync passes, and stop services only for the second. The steps follow Microsoft’s attach and detach guides.

The examples use /datadrive as the data mount and /dev/sdc as the new disk. With an NVMe controller, the new disk and its partition are paths such as /dev/nvme0n2 and /dev/nvme0n2p1.

Steps on a Linux VM

  1. Measure what each mount holds with df -Th, then choose the new size. On Premium SSD and Standard SSD, pick one of the fixed sizes: a 1,100 GiB disk is charged as 2,048 GiB. Premium SSD v2 has no fixed sizes, but in most regions with availability zones it attaches only to zonal VMs.
  1. In the Azure portal, open the VM’s Disks pane and select Create and attach a new disk. Set its Storage type and Size (GiB), then select Save.
  2. Partition, format and mount the new disk at a temporary path. parted and mkfs.xfs erase the device you name, so first check with lsblk that /dev/sdc is the new, empty disk.
sudo parted /dev/sdc --script mklabel gpt mkpart xfspart xfs 0% 100%
sudo partprobe /dev/sdc
sudo mkfs.xfs /dev/sdc1
sudo mkdir /mnt/newdisk
sudo mount /dev/sdc1 /mnt/newdisk
  1. Copy the data while services run. Archive mode (-a) leaves out hard links, ACLs and extended attributes, so add -H, -A and -X. The trailing slash on /datadrive/ copies its contents.
sudo rsync -aHAX /datadrive/ /mnt/newdisk/
  1. Stop every service that has files open on /datadrive. Your downtime starts here.
  2. Copy what changed since the first pass. Between local paths, rsync copies each changed file whole, so large changed files lengthen the downtime. --delete removes files deleted from the old disk in the meantime.
sudo rsync -aHAX --delete /datadrive/ /mnt/newdisk/
  1. Back up /etc/fstab, read the new partition’s UUID with blkid, and point the /datadrive line at it. Reload systemd, which builds its mounts from that file. Then remount /datadrive from the new line, so any mistake shows now.
sudo cp /etc/fstab /etc/fstab.bak
sudo blkid
# In /etc/fstab, the /datadrive line becomes:
# UUID=<new-uuid>   /datadrive   xfs   defaults,nofail   1   2
sudo systemctl daemon-reload
sudo umount /mnt/newdisk
sudo umount /datadrive
sudo systemctl start /datadrive
  1. Start the services and check them. Your downtime ends here. Later, test a reboot in a quiet window.
  2. Detach the old disk. Microsoft warns that removing a data disk without editing fstab could stop the VM from booting. Step 7 already removed its line and unmounted it.
az vm disk detach -g <resource-group> --vm-name <vm-name> -n <old-disk-name>
  1. Delete the old disk once you’re sure. A detached disk isn’t deleted, and you still pay for its size. For a way back, snapshot it first: a snapshot is charged only for the data it holds. Then delete the disk in the portal.

What the copy costs

  • Downtime. Steps 5 to 8, for every service on that mount.
  • Risk. A mistake in /etc/fstab can stop the VM from booting. Microsoft’s example adds nofail, which “ensures that the VM starts even if the file system is corrupt or the disk doesn’t exist at boot time.”
  • Double cost. You pay for both disks from step 2 to step 10.
  • A new fixed size. When the data grows you expand again, and when it shrinks you copy again.
Downtime spans steps 5 to 8, double cost spans steps 2 to 10 10 numbered steps read top to bottom: 1 Measure and choose the size, 2 Create and attach the new disk, 3 Partition, format and mount it, 4 First copy, services running, 5 Stop the services, 6 Second copy, 7 Move the mount, 8 Start the services, 9 Detach the old disk, 10 Delete the old disk. A red bracket beside steps 5 to 8 is labelled downtime. An amber bracket beside steps 2 to 10 is labelled both disks charged. Downtime spans steps 5 to 8, double cost spans steps 2 to 10 1Measure and choose the size2Create and attach the new disk3Partition, format and mount it4First copy, services running5Stop the services6Second copy7Move the mount8Start the services9Detach the old disk10Delete the old diskdowntimeboth disks charged
The ten steps of the copy route above are drawn evenly, not to scale in time. Each copy takes as long as the data needs.

EBS volumes can’t shrink in place either. How to shrink an EBS volume covers the AWS side.

Shrinking an OS disk

You can’t swap in a smaller OS disk. Azure can swap a VM’s OS disk for another managed disk, but only when “the current and replacement OS disks are the same size.”

The copy above doesn’t work for an OS disk, which also holds the partitions the VM boots from (/boot and /boot/efi in Microsoft’s examples). Even growing an OS disk takes the VM down: expanding without downtime “is supported only for data disks.”

So a smaller OS disk means a new VM. Your services are down from when they stop on the old VM until they start on the new one.

  1. Create the new VM from the same marketplace image with the default OS disk size, and install your software.
  2. Detach the data disks from the old VM and attach them to the new one.
  3. Add their /etc/fstab lines on the new VM.
  4. Start the services, then delete the old VM and its OS disk.

How Amoeba rightsizes data disks

Amoeba makes this copy for you, once, on the data disks of running Windows and Linux VMs. Then it rightsizes them without any downtime. It never touches the OS disk.

  • The pool. Amoeba moves the VM’s data disks onto one btrfs pool sized to your data, with room to grow. On Azure the pool uses Premium SSD v2 where your VM’s region and zone offer it, and Premium SSD otherwise.
  • The move. Amoeba copies your data while your services run. Then it switches each mount to the pool, with a short restart of the services that use it. If the switch fails, it puts the original mounts back and tries again.
  • The old disks. Once the switch is checked, Amoeba snapshots each old disk and deletes the disk. It keeps the snapshot for 7 days, then deletes it too.
  • Rightsizing. Amoeba grows the pool before it fills, and sooner when data arrives fast. When your data goes down and stays down, it shrinks the pool one disk at a time. So you pay for close to what you use.

The trade-offs: you pay for both sets of disks only while the move runs, then for the snapshots while they’re kept. Data on zone-redundant (ZRS) disks moves to a locally redundant pool and loses its zone redundancy.

Azure managed disk cost optimization covers the move and what a VM needs.

Block storage optimization with Amoeba Estimate your saving

Find your own number

One command in your terminal. One PDF report with your estimated saving at list price.

Estimate your saving
Talk to the builders

Thirty minutes with the people who build Amoeba.

Book a demo (opens in a new tab)

Or write to founders@zoorik.com