Virtual Hard Drives are the nuts and bolts of Virtualized Servers. This includes Linux Servers, but converting the hard drives provided some interesting findings.
After reading a bunch of the Microsoft documents about running Hyper-V for performance, there’s a big push to move all machines From Generation 1 to Generation 2 and Hard Drives to the VHDX Format.
In my job at SolarWinds, I get to play with a handful of Linux Virtual Appliances (vApp). Many of these run on one flavor or another of Linux. Since I’m a huge nerd and want to try and tweak everything I started playing with a few of these recently. So, being a good geek, I tried to convert the VHD files to the VHDX format.
# Converting Linux VHDs
$SourceVHD = "C:\Hyper-C\Virtual Hard Disks\data.vhd"
$TargetVHD = $SourceVHD + 'x'
Convert-VHD -Path $SourceVHD -DestinationPath $TargetVHD -VHDType Dynamic
It ran pretty quickly…
but it consumed more space than anticipated. So I optimized it.
Optimize-VHD -Path $TargetVHD -Mode Full
After the optimization, it was…
The exact same size – seems odd. 3.32 GB –> 50.3 GB [a 15x increase in size]
For a few weeks, I just let this be on the back-burner of my mind while other things took precedent.
Then I was perusing some other best practices document and ran into Best Practices for running Linux on Hyper-V.
Reading the very first recommendation, it said to use 1 MB Block sizes. Wasn’t there a block size option when converting VHD’s? Let’s try that out. What’s the worst that could happen, right?
# Converting Linux VHDs
# Let's try this again...
$SourceVHD = "C:\Hyper-C\Virtual Hard Disks\data.vhd"
$TargetVHD = $SourceVHD + 'x'
Convert-VHD -Path $SourceVHD -DestinationPath $TargetVHD -VHDType Dynamic -BlockSizeBytes 1MB
Great Caesar’s Ghost! It ran even faster, and this time look at the file size!
This is awesome! Of course, I’ll be sure to test this completely before moving something like this into production, but I’m certainly hopeful!
Anyone else made changes like this with positive or negative results? I’d love to hear about it.
Until next time kiddos – Ramble on!