The last time I gave an overview of hyper-V 3.0 and added many new enterprise-level features, which deserves attention.
This time, we continue to focus on hyper-V 3.0 and test virtual hard disk management.
Test script download
All scripts in this series pass the Windows Server 8 (powershell ise x64) test.
1. Create a virtual hard disk
Create a virtual hard disk in vhd format, with a size of 10 GB and dynamic expansion
New-vhd
-Path
F: \ work \ TMP \ hyper-V \ newvhd. vhd
-Vhdtype
Dynamic
-Vhdformat
Vhd
-Sizebytes
10 GB
Execution result:
2. Convert vhd to vhdx format
Convert-vhd
-Path
F: \ work \ TMP \ hyper-V \ newvhd. vhd
-Destinationpath
F: \ work \ TMP \ hyper-V \ newvhd. vhdx
-Vhdformat
Vhdx
Execution result:
I thought that convert-vhd could convert vhdx to other virtual hard disk formats such as vmdk, VDI, HDD, and IMG. Well, it can only be converted between vhd and vhdx.
3. view basic information about a virtual hard disk
Get-vhd
-Path
F: \ work \ TMP \ hyper-V \ newvhd. vhdx
Execution result:
4. Mount and detach a virtual hard disk
Mount-vhd
-Path
F: \ work \ TMP \ hyper-V \ newvhd. vhdx
Dismount-vhd
-Path
F: \ work \ TMP \ hyper-V \ newvhd. vhdx
Execution result:
5. Test the virtual hard disk
Test-vhd
-Path
F: \ work \ TMP \ hyper-V \ newvhd. vhdx
Execution result:
6. Expand the virtual hard disk capacity
Resize-vhd
-Path
F: \ work \ TMP \ hyper-V \ newvhd. vhdx
-Sizebytes
20 GB
Execution result:
7. Optimize virtual hard disks
Optimize-vhd
-Path
F: \ work \ TMP \ hyper-V \ newvhd. vhdx
-Mode
Quick
Execution result: