In this article, we will guide you through the process of compacting a virtual hard disk in Hyper-V. While the shrinking operation reduces the capacity of the disk, the compact operation removes empty blocks, effectively reducing the file size of the virtual hard disk without affecting its capacity. Keep in mind that compacting cannot be applied to fixed virtual hard disks.
Before proceeding with compacting or shrinking a virtual hard disk, follow these steps:
- Empty the recycle bin on the virtual machine.
- Defragment the disk to consolidate free space.
- Create a backup of critical data to protect against potential hard disk failure.
For more detailed guidance, visit Appuals.
Table of Contents
Compact Virtual Hard Disk: Step-by-Step
- Turn off the Virtual Machine:
- The virtual machine using the disk must be powered off before you can perform the compact operation.
- Open Hyper-V Manager:
- Launch the Hyper-V Manager application.
- Access Virtual Machine Settings:
- Right-click on the virtual machine whose disk you want to compact and select Settings.
- Select the Hard Drive:
- Under the IDE Controller 0, click on the Hard Drive to view the attached virtual hard disk settings.
- Edit the Virtual Hard Disk:
- Click on the Edit button to launch the Edit Virtual Hard Disk Wizard.
- Locate the Disk Page:
- The wizard will prompt you to locate the disk. Choose the appropriate virtual hard disk and click Next.
- Choose Compact Action:
- From the action menu, select Compact and click Next.
- Verify Changes:
- On the summary page, review the changes about to be made. If everything looks correct, click Finish to complete the process.
- Inspect the Disk:
After the process is complete, click on the Inspect button to verify that the virtual hard disk file size has been reduced.
Click on the hard drive under IDE controller 0 to get access to the virtual hard disk attached to this virtual machine.
Choose the edit button to open the edit virtual hard disk wizard.
Edit the virtual hard disk wizard locate the disk page, and then choose next.
In the choose action menu, simply select the compact action and then click next.
On the summary page, you need to verify the changes that are about to be made to the virtual hard disk. Click on the finish button to complete the action, and then close the wizard.
Why Compact or Shrink Virtual Hard Disks?
The need to compact or shrink a virtual hard disk arises when you want to reduce its physical storage footprint on the host system. Simply deleting content from the virtual machine will free up space on the virtual hard disk but will not reduce the physical disk size on the host system. Compacting removes the unused blocks, effectively freeing up space on the physical disk.
Depending on your requirements, choose between compacting (to reduce file size) or shrinking (to reduce capacity) a virtual hard disk. Both operations help manage disk space more efficiently in virtual environments.
Learn more: How to Create and Delete Checkpoints in Hyper-V.