Install Linux on Hyper-V

This is a how-to for installing CentOS 6.3 on Hyper-V.  It was performed on Windows Server 2012, however it should work with all versions of Hyper-V running on Windows 8 Pro, Window Server 2008 and 2008 R2.  The Linux Integration Services for Hyper-V provided by Microsoft is designed for use on Redhat based Linux distributions.  Our goal is to have a functional Linux desktop environment running the X Window System that is available through the Hyper-V console.

Why CentOS and not a different Linux flavor that plays more friendly with Hyper-V out of the box?  CentOS is the only distribution I’ve found so far that both allows seamless Hyper-V console support as well as the ability to use the Windows Remote Desktop Protocol (RDP) through MSTSC to connect in with.  Enabling RDP support for Linux will be in a forthcoming article.  (EDIT: )

Before proceeding, please ensure that the Hyper-V role is installed and configured with internet access.

Download the CentOS 6.3 x86_64 DVD image here:

Download the Linux Integration Services v3.4 image here:

Task:  Create a virtual machine.

First, create a virtual machine in the Hyper-V manager.  If this is an unfamiliar task, read through this document:

For your Linux VM, initially use default settings (dynamic memory should be disabled, but dynamically expanding hard discs are okay).  Connect your CentOS ISO image to the CD/DVD drive for installation.  After creating the new VM, it is critical to remove the default network adapter and install at least one legacy network adapters.  Connect this to the virtual switch of your choice.

Task:  Install the operating system.

Start your Hyper-V Linux VM.

You will not have a mouse for this part of the installation through the Hyper-V Console.  Use the tab, space, enter, and arrow keys to navigate through fields and select buttons.  The tab key in particular will be useful in cycling between fields with multiple options, with space selecting radio buttons and opening drop down boxes.

  • Power on the virtual machine from the Hyper-V console.
  • Install or upgrade an existing system
  • Select language and key mappings
  • Choose basic storage devices
  • Specify a full hostname, with the machine name preceding, e.g.:
  • Select your time zone.
  • The installation type should use all space.
  • Configure Network and edit the System eth0 device.
    • Check the Connect Automatically box
    • IPv4 Settings (if not dynamically assigned)
      • Enter in IP address, netmask, and gateway
      • Multiple DNS servers can be separated with a comma.
  • Installation type uses all space.
  • Choose Desktop, or Desktop-minimal type installation.
  • After file installation, allow the computer to reboot.
  • Create a non-root user.
  • Synchronize date and time over the network
  • Kdump will probably not function, but this is okay.

Task:  Configure Linux Integration Services:

  • Download the most current version (v3.4 or greater is required).
  • Login into the console as root.  Note:  the mouse still does not work yet.
  • Insert the LinuxICv34.iso image through the Hyper-V Console Media > DVD-Drive menu.
  • The disk will auto mount and open the file explorer.  Use tab to highlight folders and arrow keys to scroll to the RHEL63 directory, and press enter.  Do the same to run the script.  Be sure to specify it to “Run in Terminal.”
  • When the RPM installer finishes, use ALT+F4 to close all windows.
  • Use the CTRL-ALT-DEL button on the Hyper-V Console to bring up the shutdown menu.
  • Shutdown.

Task:  Finalize Hyper-V integration of network adapters:

This task is optional, but since the mouse now works, this should be easier to navigate than previous tasks.  You can elect to remove the legacy network adapter and add the Hyper-V synthetic adapter while the VM is turned off.  Doing so will drastically increase Ethernet performance in the Linux VM.  While using static IPs is optional, it is recommended because CentOS does not report its IP to the DNS service in most environments.

  • In the Hyper-V Linux VM settings, remove all legacy network adapters and install normal network adapters.  When done, hit OK to save settings and start the virtual machine.
  • Login as root.  In Gnome, configure network connections through System > Preferences > Network Connections to setup the new Ethernet devices, and set IPs.
    • The original System eth0 can now be deleted since it was associated with the legacy adapter.
    • Configure Auto eth1 (or similarly named) as appropriate.
      • For my example, I installed only one adapter and relabeled it to be called eth0
  • Open a terminal to rename eth initialization scripts.
    • To start, cd /etc/sysconfig/network-scripts/
    • Verify that an ifcfg-eth0 file exists.  If the adapter is listed as something else, mv ifcfg-ethX ifcfg-eth0 where ethX is the number of the first Ethernet device listed.
    • Open the initialization script with your favorite text editor and verify that NAME=eth0 (or whatever you chose) for this first device and ONBOOT=yes.  Change the device name.
      • Basic vi commands:  use “i” to insert.  :wq will save and close the file.
  • Next, fix the device name.  Open the /etc/udev/rules.d/70.persistent-net.rules file with vi or your favorite editor.
    • Delete the PCI device (tulip) as it is no longer used (this was the legacy adapter).
      • Basic vi commands:  “dd” will delete a line.  The “cw” command will allow you to replace a word where the cursor is.
    • Change the NAME=”eth1” to NAME=”eth0” on the remaining PCI device.
  • Reboot, and press the ESC key at boot to show the detailed boot information.  Ensure that eth0 is loading and used as the primary Ethernet device.

One thought on “Install Linux on Hyper-V

  1. Pingback: Connect to Linux through RDP « (The) Geek Hobbyist

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 )

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s