Category Archives: Hyper-V

Hyper-V Compact VHD(X) Disk Task Taking Hours to Complete in GUI

The Scenario

I have a VM on my Windows Server 2012 R2 Standard with Hyper-V role. It has a dynamically expanding disk which I need to compact to reclaim disk space on the host.

The Problem

I used the Hyper-V Management console to compact the disk, but after several hours it’s still running. And because you can only compact a disk on a powered-off VM my business critical VM remains offline.

The Solution

In my case the compact process actually completed successfully within 30 minutes, it’s just the GUI had crashed even though it looked like it was still running normally (the green progress bar hadn’t quite reached the end). I found this out by look in the Event Logs:

Event Viewer > Applications and Services Logs > Microsoft > Windows > Hyper-V-VMMS > Operational log

Search for event ID 27301

“The system successfully compacted ‘:\Virtual Hard Disks\.vhdx’.”

Once I saw this I pressed cancel on the GUI compact window and restarted the Hyper-V management console. I was then able to successfully power-on my VM and the space had been successfully reclaimed.

I also noticed that the high disk activity that had been seen during the early stages of the disk compaction had completely stopped, however the above event log gave me the confidence to cancel the GUI.

NB To enable disk performance counter in Server 2012 R2 open an elevated command prompt and enter the following command “diskperf -y” then close/reopen the task manager window.

Disclaimer: provided “AS IS” with no warranties and confer no rights

Hyper-V VM not recognising F8 Safe Boot Mode Keystroke

The Scenario

I have a Windows Server Vm running in Hyper-V. I have a problem with the OS and need to boot into Safe Mode by pressing F8 at boot time.

The Problem

The VM is not responding to the F8 keystroke, even if i start pressing it repeatedly, even over-zealously (mimicking days of yore when I played Daley Thompson’s Decathlon on the ZX Spectrum) as soon as the VM starts. The Safe Mode menu fails to materialise, instead it just boots as normal.

The Solution

Change the VM Automatic Start Action settings by changing the Automatic start delay time from 0 to 5 seconds (or any number great than 3 seems to work). Click OK to Confirm.

f8_error

Now when you restart the VM and press F8 the menu will appear:

8_per_1

 

Get Hyper-V host name from guest VM

The Problem
I have a server that I know is a VM but I do not know what Hyper-V host it is on.

The Solution
Open an elevated PowerShell prompts on the guest VM and enter the following:

(get-item “HKLM:\SOFTWARE\Microsoft\Virtual Machine\Guest\Parameters”).GetValue(“HostName”)

The Hyper-V host name will be returned

NB: please be careful when pasting lines that have quotation marks into PowerShell and notepad, then into PowerShell. I’ve found the format of the quotation mark is not recognised and causes the command to fail. If in doubt, manually replace the quotation marks.

Disclaimer: provided “AS IS” with no warranties and confer no rights

AVG blocking Hyper-V Internet Connection (IE not responding to connection attempts)

The Scenario

I have a Windows 8.1 Pro client and I’ve just installed a new instance of AVG Internet Security.

avg5

On my client I have the Hyper-V feature enabled with several guest VMs running These VMs are connected to the Internet via an external vSwitch which is bound to the hosts main Ethernet NIC.

The Problem

Since installing AVG my guest VMs can no longer connect to any webpage

browser-error1

Running the diagnostics returns the error “website is online but isn’t responding to connection attempts”

2browser-error1

The Solution

In the AVG advanced firewall settings there is an option to allow all traffic from/to virtual machines, this must be enabled.

Open the AVG console and select the Firewall component

avg0

Open the Firewall settings (click the cog)

avg1

Select the Advanced settings option

avg2

Open the Expert mode

avg3

Navigate to the Advanced Settings and check the box next to “Allow any traffic from/to virtual machines supported by the firewall. Click Apply and OK to complete the reconfiguration.

avg4

The guest VM is now able to connect to the Internet.

 

Disclaimer: provided “AS IS” with no warranties and confer no rights

Cannot connect to Hyper-V host via Windows 8 Client and Hyper-V Manager

The Scenario

I have domain Windows 8.1 client with Hyper-V manager installed. There is also a Hyper-V host (Windows Server 2012 R2 with Hyper-V role). The client needs to connect to the Hyper-V host via the Hyper-V Manager. The user logged on to the client is a member of the Hyper-V Administrators group on the host.

The Problem

The connection attempt fails with the following error:

hvm-error1

The Solution

On the host open an elevated command prompt and run:

MOFCOMP %SYSTEMROOT%\System32\WindowsVirtualization.V2.mof

mofcomp

No reboot is required, the fix is immediate.

Disclaimer: provided “AS IS” with no warranties and confer no rights