Automating the process of shrinking Azure Linux VM disks
May 18, 2025
In many Azure environments, virtual machines are often provisioned with disks that are larger than necessary, leading to wasted storage and increased costs. While Azure does not provide a built-in, automated way to reduce partition sizes and shrink overall disk capacity, optimizing disk usage can significantly improve efficiency. To address this gap, I have developed the Disk Shrinking Engine (DSE), a tool designed to automate the process of reducing partition space and resizing disks for Azure Linux virtual machines.
Disk Shrinking Engine
The Disk Shrinking Engine (DSE) is a tool to shrink the LVM OS disk of Azure Linux Virtual Machines. It is designed to help users reduce the size of their virtual machine disks, making them more efficient and cost-effective. The engine automates the process of resizing logical volumes, physical volumes, and partitions, ensuring that the disk space is optimized without losing any data.
The process involves creating a snapshot of the original disk, preparing a new source disk, resizing logical volumes, physical volumes, and partitions, and finally creating a new VM with the target resized disk.
Getting Started
For more information on how to use the Disk Shrinking Engine, please refer to the GitHub repository. The repository contains detailed instructions on how to set up and use the tool, as well as examples of how it can be used to shrink Azure Linux VM disks.