Skip to content


Category: Hyper-V

To compact a dynamically expanding Linux virtual hard disk you will first need to zerofill the unused area. This is done by using the dd(data dump) tool.

This will create a file filled with NULL chars and then remove it.

When it is finished, shut down the machine and compact the disk.

You can compact the VHD by following the “2. Compact VHD” – step here


I downloaded Netscaler VPX for Hyper-V from Citrix downloads and tried to import it to my Hyper-V 2012R2 machine but it failed with an error “Hyper-V did not find virtual machines to import from location“.

Reason for the import failing is because the NSVPX image has been created on 2008R2(Hyper-V2) and due to changes to the platform they are incompatible. You can read more about it here.


The short answer is to create a new machine.

Create a new virtual machine with the following settings: (values in bold are mandatory)
Specify Generation: Generation 1
Assign Memory: Startup memory: 2048 (do not select dynamic memory)
Configure Networking: Connection: (Select your preferred Connection)
Connect Virtual Hard Disk: Use an existing virtual hard disk (the .vhd image).

…and make sure the following is configured: (edit if needed)
Number of virtual processors:2
Network Adapter: May not be a “Legacy Network Adapter”


PowerShell equivalent of above:


Now configure your network settings. You will need at least one adapter for the management IP address (NSIP) for the NetScaler. Additional adapters may be needed in your environment.


I stumbled into a problem importing a few machines that had previously been deleted from Hyper-V. All the files and configurations were still available.

Running the “Import Virtual Machine” wizard did not find any machines to import, so I wrote a few lines to import the machines via powershell:

…which resulted in an error when trying to import one of the machines:

I had to get more information:

Virtual Disks missing. I verified that the files were present and that the paths were correct in the .xml file. This is a disk-intensive machine and therefor the vhd-files(disks) are distributed to 3 different physical harddrives.

It seems to be assumed, that the images are present on the same volume. After moving all the images to the same location both the wizard and Import-VM worked.




Netscaler VPX Express is a free version of the NetScaler VPX appliance, but with a few limitations. You don’t have the same throughput, there is no SSL Offload and you need to renew the (free)license every year.. which is good enough for some cases.


Update 2015-04: Follow the link: Import Netscaler VPX to Hyper-V 2012R2.



Information below is kept for future reference.

Convert a NSVPX VMDK(VMWare) to VHD(Hyper-V)


I wanted to test the Netscaler VPX Express in my homelab but at the time there were no download available for Hyper-V. There were downloads for VMWare, XEN and KMS hypervisors.

I downloaded the current image for VMWare, “NetScaler VPX for ESX 10.5.e Build 52.1115.e

In an earlier post, i wrote how to convert an vmdk image to Hyper-V:


Create a new virtual machine with the following settings: (values in bold are mandatory)
Specify Generation: Generation 1
Assign Memory: Startup memory: 2048 (do not select dynamic memory)
Configure Networking: Connection: (Select your preferred Connection)
Connect Virtual Hard Disk: Use an existing virtual hard disk (the image above).

…and make sure the following is configured: (edit if needed)
Number of virtual processors: 2
Network Adapter: May not be a “Legacy Network Adapter”


Start the machine

If you get the “Invalid Slice” message you need to repair the bootloader, which can be done with the FreeBSD LiveCD.

Download the “FreeBSD-8.4-RELEASE-i386-livefs.iso”, mount it and reboot the machine.

From the Main Menu, select the following:

From the Configuration Menu, select:


Now select the freebsd partition and press “S” to make it bootable and “W” to write changes.

When asked for Boot Manager, select:

Press “Q” to finish and then exit the installer, make sure the CD-image is unmounted and reboot.

You should now be able to boot the netscaler.


After some initial configuration, login with the default credentials: NSROOT/NSROOT.







I came across an virtual machine in .ova format. OVA is an open standard for packaging and distributing virtual appliances. The .ova-package(file) is a tar-archive which can be decompressed and you will get two files: .ovf and .vmdk.

Information about the machine settings (vCPUs, Memory, NIC etc.) is stored in the .ovf file. The .ovf file is a .xml-file. You can launch the file in your favorite browser/xml-parser.

Now you need to create a machine manually with the specifications found in the .ovf. Virtual appliances are very picky on the specifications and might refuse to boot, crash, or get into problems later if the configuration is not exact (2 CPUs for example).

A Legacy Network Adapter may be needed for the system to recognize the NIC, in that case you need a Generation 1 virtual machine. I have also seen Dynamic Disks on a *nix system grow endlessly. Using a fixed disk corrected the problem. YMMW.


The diskimage(.vmdk) has to be converted into a native Hyper-V diskimage(.vhd/.vhdx).

I tried Microsoft Virtual Machine Converter but it failed and OVF Import/Export tool required an System Center VMM management server which i didn’t have.


It turned out that VirtualBox had tools to to convert the image successfully.

You can either download and install VirtualBox, or for a GUI version scroll further down and follow the instructions how to use “CloneVDI”.



Use VirtualBox command line utilities to convert the image.

Download and install VirtualBox from


You can deselect the USB/NIC drivers and other options during the installation. They will not be needed for converting diskimages and you will get less clutter on your machine.




You don’t need to start VirtualBox.

VirtualBox has a commandline utility that will be used to convert the image.

VBoxManage clonemedium: (earlier versions used VBoxManage clonehd) This Commandline duplicates a virtual disk/DVD/floppy medium to a new medium (usually an image file).

VBoxManage clonemedium [disk|dvd|floppy]

[--format VDI|VMDK|VHD|RAW|]
[--variant Standard,Fixed,Split2G,Stream,ESX]

In this example, the source diskimage is named “infile.vmdk” and is located in the C:\HYPER-V directory. Output image will be of vhd-format and named “outfile.vhd”. The commandline is: "VBoxManage.exe clonemedium --format vhd infile.vmdk outfile.vhd"



Use CloneVDI to convert the image.


CloneVDI is the (VirtualBox) GUI-tool for cloning images, but it does not support all image formats that VirtualBox VBoxManage does (and vice versa).

Download CloneVDI from the following location: VirtualBoxFourm


The CloneVDI is a pretty straightforward utility.

If you get an error about an unsupported format, try VirtualBox commandline utils instead.


Shrinking disks on your Hyper-V guests

A few of my guests run on SSD drives. Occasionally I reclaim diskspace by defragmenting and compacting the VHD;s. I have managed to free up to 20GB diskspace on a single guest, which is pretty much SSD wise. However, first of all, you should consider before putting R/W intense operations, such as VMs, on your SSD;s.


Since this is a process that will take quite some time I wanted to make it as automated as possible.


1. Defrag with Raxco perfect disk. This script is run remotely on the target machines. Errorhandling is omitted for readability.


2. Compact VHD:s. Run in powershell on the Host. Make sure the actual VM is turned off.


Unlike VMWare or Virtual PC, Hyper-V does not have a functionality to share folders between the host and guest.You have to rely on a network connection to share folders or utilize a RDP session to transfer data.

There has been an update for Hyper-V called “Enhanced Session Mode” but its only available if your host is a Windows Server 2012 R2 and your guest is either a Windows Server 2012 R2 or a Windows 8.1. The Enhanced Session mode connection uses a RD session via the virtual machine bus (VMBus) and does need a network connection.

If you have network access, or can use the Enhanced Session Mode, you are probably fine… but my Hyper-V host is on an isolated network and I can not use the Enhanced Session Mode since my guests mainly consist of Windows 2008 R2 Servers.

However. It is possible to make a snapshot/checkpoint to export the data, or mount/dismount disks. There is plenty-a-lot of information about this on the net.

My solution for transferring data to the host is by scripting .ISO images(mkisofs) and use powershell to mount them.


(Un)Mount the CD/DVD image on your Hyper-V guests.

Get information of currently mounted images: