Managing Data Disks in a Windows Virtual Machine
Virtual machines often need additional storage beyond the OS disk. Azure (and other cloud platforms) allow you to attach, detach, and resize data disks easily. Below are the steps for adding, removing, and updating a data disk in a Windows VM.
1. Adding a Data Disk
Steps:
- Navigate to VM in Portal
Go to the Azure portal → Select your VM → Under Settings, choose Disks. - Attach New Disk
Click + Add data disk → Select Create disk or choose an existing managed disk. - Configure Disk
Provide disk name, type (Standard HDD/SSD, Premium SSD), and size. - Save & Restart VM
Click Save. The disk is now attached to the VM. - Initialize in Windows
- Log in to the VM via RDP.
- Open Disk Management (
diskmgmt.msc). - Locate the new disk (it will appear as “Unallocated”).
- Right‑click → Initialize Disk → Choose partition style (GPT recommended).
- Create a New Simple Volume, assign a drive letter, and format with NTFS.
Explanation:
Adding a disk involves two parts: attaching it at the cloud level and configuring it inside the OS. Without initialization, Windows won’t recognize the disk for use.
2. Removing a Data Disk
Steps:
- Unmount in Windows (Optional)
If the disk contains data, back it up. You can also remove the drive letter in Disk Management to prevent accidental use. - Detach in Portal
Go to VM → Disks → Data disks.
Select the disk → Click Detach. - Save Changes
Click Save. The disk is now detached from the VM but still exists as a managed disk resource. - Delete Disk (Optional)
If you no longer need it, go to Azure Disks resource → Delete.
Explanation:
Detaching removes the disk from the VM but does not delete it. This ensures data safety and allows re‑attachment later. Deleting is permanent.
3. Updating (Resizing) a Data Disk
Steps:
- Stop VM (Recommended)
While resizing can be done online, stopping the VM avoids potential issues. - Resize in Portal
Go to VM → Disks → Select disk.
Change the Size (GB) to a larger value → Save. - Restart VM
Start the VM again. - Extend Volume in Windows
- Open Disk Management.
- Right‑click the existing partition → Extend Volume.
- Follow the wizard to allocate the new space.
Explanation:
Resizing increases the disk capacity but doesn’t automatically extend the partition inside Windows. Extending the volume ensures the OS can use the additional space.
Best Practices:
- Always backup critical data before disk operations.
- Use Premium SSDs for high‑performance workloads.
- Monitor disk usage with Azure Monitor to plan scaling.
- Prefer Managed Disks for easier administration and reliability.
Leave a Reply