How to reduce VM date disk size using the example of Azure VM

Sometimes you need to change a VM data disk size, but disk expanding is a simple operation. If you need to reduce disk size, it is not an obvious operation. For example, the Azure portal shows you that this operation can’t be performed.

⚠️ Caution ⚠️ Before starting any actions with a disk, make sure there is no disk activity on that drive. Stop the services and close applications that work with this disk to prevent data loss. ⚠️

The migration to a smaller disk includes creating a disk of a smaller size and copying all data to it. In the Azure portal find and open the required VM, then click on Disk in the menu blade. In opened windows click on Create and attach a new disk. Type the new disk name and its size, then click Save at the top.

Connect to VM via RDP. After that open the Computer Management console (compmgmt.msc) and navigate to Disk Management. Right-click to a new disk, then choose Initialize Disk.

GPT partition style is the best option for disk initialization. Click on OK.

Create a New Simple Volume by clicking on rectangular with black line, disk size, and caption Unallocated.

Set the disk size. By default, the wizard uses the whole free disk size.

Choose drive letter. In our example, we use the letter E.

Format the partition.

Afterward, the new volume E appears in the Windows File Explorer. Next, open the command prompt or Powershell and run robocopy command with ACL preserving flags.

robocopy d:\ e:\ *.* /mir /sec /e /z /r:2 /w:5

This task requires to use robocopy because no other way doesn’t allow saving security rights for folders and files as it was on the original disk.

After copying is done, detach the disk in the Azure portal.

Change the drive letter of the existing data disk from old to new one (in our example from E to D).

👇👇👇
💬Discuss or ask a question in the Telegram💬

📕Читать эту же статью на русском 👉 https://dzen.ru/media/samsitblog/kak-umenshit-razmer-dopolnitelnogo-diska-dlia-virtualnoi-mashiny-na-primere-azure-vm-64ce4644699e20047496a0ad


Posted

in

,

by