Virtual Hard Disks - Paiet/Tech-Journal-for-Everything GitHub Wiki

Virtual Hard Disks

  • .VHD vs .VHDX
  • Gen 1 VMs can use VHD or VHDX files, but Gen 2 VMs can only use VHDX files.
  • Usually, one will opt for .vhdx to take advantage of performance benefits if backward compatibility is not required.

####Create VHD and VHDX files using Disk Management or Windows PowerShell Diskmgmt.msc or Rt. Clk off start Action > Create VHD>

PowerShell https://docs.microsoft.com/en-us/powershell/module/hyper-v/new-vhd?view=win10-ps

  • Hyper-V PowerShell module New-VHD New-VHD -Path C:\VHD\VHD1.vhd -SizeBytes 1GB New-VHD -Path C:\VHD\PSHFIXED.vhd -Fixed -SizeBytes 1GB

Conversions https://docs.microsoft.com/en-us/powershell/module/hyper-v/convert-vhd?view=win10-ps

  • Conversions can take place via Hyper-V Manager and PowerShell however, Do not attempt to convert a VHD to a VHDX if any of the following are true:

    • You have created a snapshot of the virtual machine
    • You are replicating the VHD using Hyper-V Replica
    • The VHD is the parent to one or more differential virtual hard disks Convert-VHD -Path C:\VHD\PSHFIXED.vhd -DestinationPath C:\VHD\PSHFIXED.vhdx
  • When you create a new VHDX file (not converted) it has a physical sector size of 4 K. A converted VHDX file has a physical sector size of 512 Bytes. You can change the physical sector size of a converted VHDX by running this piece of PowerShell before you power up the virtual machine: set-vhd C:\VHD\PSHFIXED.vhdx -PhysicalSectorSizeBytes 4096

####Mount virtual hard disks

Diskmgmt.msc

PowerShell2 cmdltes to do the same thing

  • Storage PowerShell module mount-diskimage -imagepath C:\temp\VHD1.vhd

  • Hyper-V PowerShell module mount-VHD -path C:\temp\VHD1.vhd

Storage Spaces is integrated with failover clustering, which allows it to deliver continuously available service deployments. [ ]expand storage pools [ ]configure Tiered Storage DemoPool creation with wizard as well as PowerShell

New-Volume -StoragePoolFriendlyName "DemoPool" -FriendlyName "Simple1" -Size 2GB -ResiliencySettingName "Simple" -FileSystem NTFS -AccessPath "S:" -ProvisioningType Thin td