Installing Linux On Hyper-V

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:

  1. Insert the Linux installation ISO in the virtual machine.
  2. Run through the installation which will fail to detect the network card. Ignore any errors relating to missing network connectivity.
  3. 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”.
  4. Insert the Linux Integration Services ISO in the virtual machine.
  5. Mount the ISO inside the OS by entering the command: mount /dev/cdrom /media
  6. Run the install script by entering the commands:
    cd /media
  7. 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
  8. Start the install by entering:
  9. Once complete, reboot the system then login again as administrator (running “sudo bash” again if necessary), e.g. enter the command:
  10. Before we can configure the network adapter we must create a stub device configuration file:
    vi /etc/sysconfig/network-scripts/ifcfg-eth0
    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.
  11. 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:
    dhclient eth0
    yum install system-config-network-tui

    Respond "y" when prompted to download and install packages.
  12. 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.
  13. 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:
    vi /etc/sysconfig/network-scripts/ifcfg-eth0
    Then adding the line:
    Then hitting the usual “:wq” to save and exit.
  14. 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.
  15. 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:
    yum update
  16. 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.

9 thoughts on “Installing Linux On Hyper-V”

  1. When I try the mount command as shown above I get “mount: you must specify the filesystem type”. If I add “-t iso9660” (as suggested elsewhere) I get “mount: no medium found on /dev/sr0” …. any ideas?

    1. I think you’re mounting the CDROM a second time for updates, but either way with a build of CentOS which has successfully loaded the hv_blkvsc driver. The only known problem is AFTER that is loaded in place of the ata_piix driver, according to the Microsoft KB article here:

      The solution posted there will work (just tried it). That’s an annoying limitation. I mean the reason to have integration components loaded is to improve integration, not to reduce capability, LOL! Sounds like there is some internal performance issue there which justifies it, shame.

      Thanks for the pointer, it’s useful to have documented. I hadn’t noticed myself because I only needed the CDROM to install Linux then the IC. Let’s hope the next IC build resolves that.

    2. For what it’s worth, that’s the exact behavior that occurred when I neglected Step 4: “Insert the Linux Integration Services ISO in the virtual machine.” The CentOS install ISO was still in place. Oops!

  2. Thank you! I’m migrating from VirtualBox to Hyper-V now that i upgraded to Windows 8 and this post was very useful for me! I didn’t have any access to internet, and when i tried to access DVD drive it shows the same message than Kevin, and your post (and comment!) helped me to install it (finally!).
    Just sorry my bad English. With your post, i wrote one about it in Portuguese-Brazil and i just want to say thank you. I wait to help other people the same way your post helped me. O/

  3. to avoid all this typing add a legacy network adapter hardware before the install of the OS. after the install of the integration services, and rebooting, your eth0 device will be there. then you can just remove the legacy network adapter.

    still have to do the ata device thing though.



    1. Yes the Legacy Network Adapter is well known and it does appear to help with the initial installation. The bit of typing in point 8 which is saved is more than consumed by fiddling around with the VM hardware, and perhaps you have no access to that if it is a provisioned VM.

      With experience I found that the Legacy Network Adapter doesn’t save time at all and that is why I didn’t even include it my procedure. The problem is it is still critical to make sure ALL the correct drivers are loaded, else you lose performance and risk a host crash. You’ll notice warning messages in the Hyper-V server’s event log when you’re not running the latest drivers.

      Actually this is procedure is a couple of steps longer than the minimum because I’ve added some best practice steps like downloading the handy “system-config-network” tool and setting the DHCP host name to match so that DDNS registrations are performed correctly (see my blog post on getting Linux VMs to behave properly with DNS registrations like Windows does).

      A default installation with Legacy Network Adapter “et volla” is nothing more than an incomplete installation which runs slower and risks a host crash. I guess (and from what I have seen in various operations departments) most people won’t bother to continue with any further configuration. That is why I left it out of the procedure altogether.

      From start to finish the list I made was (at the time of writing) the most optimal way I feel to reach a FULLY configured (and potentially accelerated) Linux VM configuration.

      The one thing given which is better with the Legacy Network Adapter is you get the chance to update during installation. But since we will run an update at the end (and you really should do that regularly) it doesn’t have any use unless there is something in the distribution which you must download before I starts. But then you should take a later fixed distribution to start with.

  4. For those who have difficulties with Slackware Linux 14.1’s post installation on hyper-v and after the system perform the first boot and screen hangs at the following message ” Kernel panic – not syncing : VFS : Unable to mout root fs on unkown -block “. I made a step by step guide on how to fix this:

    I hope I have contributed 🙂

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s