Dealing with over-sized disks in Azure

How to downsize a data disk on an Azure VM

 

Even with the best intentions, we often find that customers have dozens or hundreds of virtual machines in Azure which are using a small fraction of the disk space they have provisioned to them. This may not be a big issue with thin-provisioning for standard data disks, but for managed SSDs the customer incurs all of the cost of the storage provisioned, no matter how little they are using.

A common occurrence of this happens when provisioning an image from the Azure portal that includes a SQL Server installation. It is in good practice to create multiple disks for SQL to operate correctly and more efficient, however, generally what is provisioned is a 1TB disk by default. In the following screenshot, there is a 1TB disk provisioned, but we are only utilizing about 14GB of space on that drive:

Notes before getting started

  • Disk A refers to original data disk attached to VM (larger disk)
  • Disk B refers to new, smaller data disk

 

The process

 

1) Provision Disk B through the Azure portal and attach to desired VM

2) Initialize/Format Disk B within the Azure VM

a. You can assign any drive letter

 

3) Copy all data from Disk A to Disk B

a. You may have to stop services that are accessing Disk A to complete this task

b. You can use the ROBOCOPY CMD:

robocopy F:\ E:\ *.* /e /sec /Xd System Volume Information $RECYCLE.BIN

c. In this example, F:\ is the source disk (A) and E:\ is the destination disk (B); *.* will copy all
files; /e copies subdirectories; /sec copies files with security; /Xd excludes directories

 

4) Detach Disk A from VM in the Azure portal

5) Change the drive letter of Disk B to reflect Disk A’s original drive letter

6) Start services that were stopped when copying files

7) Test important services to ensure all files are accessible by programs that are needed

8) Delete Disk A from the Azure portal to stop incurring charges

 

Daniel Ruberg
Author

Daniel has over 8 years of Network Administration and Engineering experience. He finished his undergraduate degree in Computer Management Information Systems from Liberty University in 2008. He's obtained several industry leading certifications including: Certified Information Systems Security Professional (CISSP), AZ-300 & AZ-301: Microsoft® Azure Solutions Architect Expert, AZ-500: Microsoft® Azure Security Technologies, Microsoft® Certified Solutions Expert: Cloud Platform and Infrastructure. Daniel has deployed, managed, and migrated several production workloads to Microsoft Azure utilizing the latest technologies that the Microsoft cloud has to offer.

Recommended for you.