Resizing VHDX´s on running VM´s in Windows 2012 R2 Hyper-V

As I described in an earlier post about why you should think about creating VM´s with Windows 2012 now when the Windows 2012 R2 have arrived I have now tested the online VHDX resize function.

And as I already have emphasized is that you can only online resize VHDX´s that are connected to a SCSI controller, and it is only on Generation 2 VM that your Hyper-V VM´s can have the boot disk connected to the SCSI and also that limits the number of OS´s (Windows 2012/2012R2 and Win 8/8.1)

I have not yet successfully migrated a Gen 1 VM´s system disk to a Gen 2 but I am working on it 😛 (the Gen 2 uses UEFTI and GPT) and some kind of backup/restore will probably be required..  I will post updates in my pursue of this task.

Screen Shot 2013-06-28 at 22.56.20

In the following part of this post I want to show you how I resize both a VHDX with the system and boot partition on it and an additional VHDX with data on the VM running on the Generation 2.

As you can see with this PowerShell I can easily extend the VHDX and also with the following command I can get the minimum size that I can shrink it to, this depends on the volume inside and that can also be shrunk online of course, that has been possible since Windows 2008. I have also gone through this case in an earlier post, the main difference here with R2 is that it can be done online.

When checking the help for the Hyper-V PowerShell module in R2 it can be noted that the help information has not been updated as it says still that it is an offline operation 😛

Screen Shot 2013-06-30 at 16.55.16

So to resize during the VM is running is shown here in the following screendump, and as you can see, both the system drive and the L-drive are extended.

Screen Shot 2013-06-30 at 19.58.34

And here you can see how we can shrink the VHDX also, note that I have extended the system volume with 3 GB inside the VM also so the minimum have gone up all this when the VM was running!

Screen Shot 2013-06-30 at 19.59.50

Here is the Powershell

Get-VHD (Get-VM winshrink | Get-VMHardDiskDrive).path | Select @{Label="SizeGB";Expression={"{0:N0}" -f ($_.Size/1GB)}},@{Label="MinSizeGB";Expression={"{0:N0}" -f ($_.MinimumSize/1GB)}}

Get-VHD (Get-VM winshrink | Get-VMHardDiskDrive).path | where Path -match winshrink.vhdx | Resize-VHD -SizeBytes 30GB

Get-VHD (Get-VM winshrink | Get-VMHardDiskDrive).path | where Path -match L.vhdx | Resize-VHD -SizeBytes 60GB

Get-VHD (Get-VM winshrink | Get-VMHardDiskDrive).path | where Path -match winshrink.vhdx | Resize-VHD -ToMinimumSize

Get-VHD (Get-VM winshrink | Get-VMHardDiskDrive).path | where Path -match L.vhdx | Resize-VHD -ToMinimumSize

Happy extending and shrinking your SCSI attached VHDX hdd

Comments

Gil
Reply

“The requested resize operation could not be completed because it might truncate user data residing on disk”

What am I missing?

Leave a Reply to GilCancel reply

name*

email* (not published)

website