Installing a supported Linux distribution (typically CentOS or RedHat) as a virtual machine on a Microsoft Hyper-V server may require Linux Integration Services to run efficiently and use network adapters without un-necessary (legacy) software emulation. Running without the virtualization drivers loaded will not only waste the power of the host, but run slower, cause issues with the system clock and risk a total (host) system crash affecting other virtual machines.
Other distributions of Linux, such as Ubuntu, already include built-in versions of the Hyper-V drivers. That sounds good, but be careful because you cannot guaranty that the combination of Linux built-in drivers and the host will be compatible. There is also the possibility (which I have experienced) that older Linux Hyper-V drivers will not even boot on newer Hyper-V server versions.
Here’s a quick guide to installing CentOS on Hyper-V. The process should be the same on other systems too, perhaps with a few modifications, e.g. use of “apt-get” instead of the “yum” command.
You can download the integration services at the Microsoft download site. Here is a link to the current (at time of writing) 3.4 version:
The procedure for installation is basically:
- Insert the Linux installation ISO in the virtual machine.
- Run through the installation which will fail to detect the network card. Ignore any errors relating to missing network connectivity.
- Finish the installation, reboot then login with administrative (root) privilege. If SUDO is active you will need to run “sudo bash” first to elevate all following commands until you enter “exit”.
- Insert the Linux Integration Services ISO in the virtual machine.
- Mount the ISO inside the OS by entering the command: mount /dev/cdrom /media
- Run the install script by entering the commands:
- You should see a list of subdirectories for each major kernel version, e.g. RHEL63 for RedHat Enterprise Linux v6.3. RedHat should work for Decide which version to use, take the closest match, e.g. the highest version if you are installing in the latest Linux version. Enter the command to change to that directory:
cd RHEL## e.g. cd RHEL63
- Start the install by entering:
- Once complete, reboot the system then login again as administrator (running “sudo bash” again if necessary), e.g. enter the command:
- Before we can configure the network adapter we must create a stub device configuration file:
A new file is created in the (hard to use) VI text editor. Hit the INSERT key to start editing then enter the following text:
Then hit the ESCAPE key then enter the text “:wq” to save and quit followed by RETURN.
- Although it is possible to edit the network configuration files further to manually set the DHCP or static address, hostname and DNS server information, that is way too complex. We will temporarily activate the adapter using DHCP in order to download the system network configuration tool then use that to complete the configuration. Enter the commands:
yum install system-config-network-tui
Respond "y" when prompted to download and install packages.
- Start the network configuration tool by entering:
Select devices then “eth0”. Change the network settings as you desire, either enabling the DHCP option for dynamic addressing, or entering fixed address information manually. Save the changes then enter the DNS configuration. Set the hostname to your unique name on the network, changing from the default “localhost.localdomain”. Save the changes and exit the tool.
- If you are using DHCP and want the DNS name registered properly, you have to duplicate the hostname setting, because strangely Linux does not use the existing hostname from the network configuration during DNS registration. Do this by running:
Then adding the line:
Then hitting the usual “:wq” to save and exit.
- Finally, reboot to test the configuration is saved and initialized automatically at start-up.
After rebooting and logging-in again, the “ifconfig” command should show details about the “eth0” LAN adapter including the IP address you configured.
- Now you have a Linux virtual machine installed with all drivers and network connectivity loaded in Hyper-V, you should update all components to the current service level over the internet:
- IMPORTANT: Due to a bug in the current integration components, the DVD/CD drive (or mounted ISO) will fail to load due to the known Microsoft issue KB2600152. To workaround that, issue the command:
insmod /lib/modules/$(uname -r)/kernel/drivers/ata/ata_piix.ko
Then you can use the normal command to mount the drive inside Linux:
mount /dev/cdrom /media
And you’ll have to do it every time after a reboot until they fix it.
I would prefer a behaviour in Linux similar to Windows where plug-and-play devices always initialize themselves in the system. That would ease the second part after installing the integration services. It’s good to see Ubuntu with Hyper-V drivers included, but it appears they are not updated so frequently. So you may have to follow the first part of the procedure above (if you can get it to boot at all) even if your Linux distribution includes Hyper-V.