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

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.
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.
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
- 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.
- 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.
- Partition, format and mount the new disk at a temporary path.
partedandmkfs.xfserase the device you name, so first check withlsblkthat/dev/sdcis 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
- Copy the data while services run. Archive mode (
-a) leaves out hard links, ACLs and extended attributes, so add-H,-Aand-X. The trailing slash on/datadrive/copies its contents.
$ sudo rsync -aHAX /datadrive/ /mnt/newdisk/
- Stop every service that has files open on
/datadrive. Your downtime starts here. - Copy what changed since the first pass. Between local paths,
rsynccopies each changed file whole, so large changed files lengthen the downtime.--deleteremoves files deleted from the old disk in the meantime.
$ sudo rsync -aHAX --delete /datadrive/ /mnt/newdisk/
- Back up
/etc/fstab, read the new partition’s UUID withblkid, and point the/datadriveline at it. Reload systemd, which builds its mounts from that file. Then remount/datadrivefrom 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
- Start the services and check them. Your downtime ends here. Later, test a reboot in a quiet window.
- 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>
- 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/fstabcan stop the VM from booting. Microsoft’s example addsnofail, 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.
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.
- Create the new VM from the same marketplace image with the default OS disk size, and install your software.
- Detach the data disks from the old VM and attach them to the new one.
- Add their
/etc/fstablines on the new VM. - 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.
Sources: Microsoft Learn, “Expand virtual hard disks on a Linux VM” (opens in a new tab); Microsoft Learn, “Select a disk type for Azure IaaS VMs - managed disks” (opens in a new tab); Microsoft Learn, “Use the portal to attach a data disk to a Linux VM” (opens in a new tab); Microsoft Learn, “Detach a data disk from a Linux VM” (opens in a new tab); Microsoft Learn, “Swap between OS disks using the Azure CLI” (opens in a new tab); AWS, “Modify an Amazon EBS volume using Elastic Volumes operations” (opens in a new tab); man7.org, “systemd.generator(7) - Linux manual page” (opens in a new tab); man7.org, “rsync(1) - Linux manual page” (opens in a new tab).