Archive

Posts Tagged ‘Hyper-V’

Setting up file sharing between guest and host OS in Hyper-V using an Internal network

March 29, 2013 1 comment

This post talks about making the network configuration settings made on a Hyper-V virtual machine in order to allow file sharing between the virtual machine and host OS. There are 3 types of Hyper-V networks that the virtual machine could be using – Private, Internal and External. Private does not allow any communication except between virtual machines using the same Hyper-V virtual switch. So in order to enable file sharing either an "Internal" or an "External" virtual switch is required.

To learn how to set up an Internal or External virtual switch and the nuances of each, refer here. This post assumes that the VM in question has been configured to use an "Internal" connection type.

On the VM, chose "Network and Sharing Center" > "Change Adapter Settings" to show that we have simple virtual adapter with no connection to any physical network.

clip_image001

Doing an ipconfig on the machine through command prompt shows the adapter is assigned a 169.254.X.X IP which shows it is a limited connection right now. This is because we are using an "Internal" virtual switch type on Hyper-V and are not connected through the physical adapter on the host machine.

clip_image002

So in order to get this virtual machine to be able to communicate with the host, I went about assigning it a static IP address. First, bring up the properties of the adapter from the right click menu.

clip_image003

From the "Ethernet Properties" dialog, selected the "Internet Protocol Version 4 (TCP/IPv4)" option and clicked on the "Properties" button.

clip_image004

When on the IPv4 properties dialog, I need to set a static IP on the adapter that is on the same subnet as the host machine. What this will enable is the ability for the Virtual Switch to route communication between the host and guest operating systems. I chose the IP address shown below because my host machine runs with a 192.168.1.X IP. Set the subnet mask to 255.255.255.0 as shown to ensure same subnet and clicked "OK" to finish.

Now I could have made other settings such as the gateway (which shouldn’t have mattered since there is no physical network connection and Preferred DNS Server which I will eventually have to come back to when I set up the DNS service on this machine. But I am doing the bare minimum here to get the communication working.

clip_image005

On the "Ethernet Properties" dialog, clicked "Close" to apply the settings and move along.

clip_image006

Confirmed that the settings were applied.

clip_image007

Created a new folder called "Transfer" to serve as a go-between for file transfers between the guest and host OS and selected to share it with "Specific people…"

clip_image008

Clicked on "Share" to begin sharing the folder.

clip_image009

The "Network discovery and file sharing" dialog shows up. Selected "No, make the network that I am connected to a private network". It wouldn’t matter greatly because the machine is on an internal network anyway but it is the right choice to make.

clip_image010

Once that is done, the shared folder should be accessible at the path indicated in the screen below. Clicked on "Done" to close out of this.

clip_image011

So let’s try accessing this folder from the host. Opened a file explorer window and type the path shown above in the address bar. The first time connection will require username and password to be typed in. We get away with not using domain specification here because the virtual machine has not been added to a domain yet. If we did, we may have had to use a valid domain user login.

clip_image012

In any case, once authentication is through you are able to view the contents of the folder on the host operating system. Added a file here to complete the test.

clip_image013

And here’s the file on the guest. Besides testing the ability to transfer data, this has also verified the working of the virtual switch.

image

And that’s all there is to that.

Advertisements
Categories: Hyper-V Tags: , ,

Installing Windows Server 2012 on a Hyper-V virtual machine

March 29, 2013 1 comment

Installing Windows Server 2012 is a pretty straight-forward exercise akin to installing any of the latest Windows client operating systems. In this post the focus is on installing the OS on a Hyper-V virtual machine which once the disk is correctly mounted, is exactly the same as installing on a physical machine.

If you do not have a Hyper-V virtual machine yet and would learn how to create one, refer here. If you already have a virtual machine with a blank virtual hard drive ready for installation, the following would be the step by step method.

Within Hyper-V manager, selected the virtual machine target from the list and clicked on "Connect".

clip_image001

And once the VM window popped up as below, verified that the ISO file containing the OS I am about to install is still mounted as a virtual disk on the VM

clip_image002

Since this is good, clicked on the "Start" button to launch it.

clip_image003

If the ISO is a good bootable OS disk the following screen should appear indicating launch of the Windows Server 2012 installer. It is now about making the right selections and getting the OS installed. Clicked "Next".

clip_image004

Clicked "Install Now"

clip_image005

Entered the product key and clicked "Next".

clip_image006

And since I am not cool enough yet to work just with the Core, selected "Server with a GUI" option and hit "Next".

clip_image007

Next screen, License Terms – read (skimmed really), accepted, clicked "Next".

clip_image008

Next, you get to select the kind of installation you want to proceed with. You have two options one of which – "Upgrade" is not valid because it is only applicable when there is an existing version of Windows running on the machine on which you’re currently running the installer. Since we started with a blank VM, there is nothing to overwrite. Therefore, the obvious choice to make here is "Custom". Clicked on the "Custom" button to move on ahead.

clip_image009

Due to the simplicity of what this machine will need to do, I have desisted from my favorite pastime of making drive partitions during OS installation and chosen the virtual hard drive in its entirety to serve as the OS partition. Clicked "Next".

clip_image010

And off we go. The installation procedure could take a while. In my case it took 7 minutes.

clip_image011

When done, you get to provide the Administrator password for the machine. Now this is something I have done in the past and forgotten to set the domain policy later on to not expire. It gets painful when the password expires and you need to change it. This time hopefully, I will remember to configure and document the steps to set the administrator password not to expire. Typed in a safe password here and hit "Finish".

clip_image012

Done.

clip_image013

Logged in for the first time and here’s what we have

clip_image014

Creating a new Hyper-V Virtual Machine

This post covers the creation of a new virtual machine on Hyper-V where the host environment has the following resources and settings:

  • Operating System – Windows 8
  • Memory – 32 GB
  • Processor – Intel Core i5 – Quad core
  • Disk Space – Over 700 GB available

This is not to say that a host machine with a different or lesser configuration is not suitable. It is just important to note that the resources allocated to the virtual machine and the guest operating system are dependent on what the host can support with enough left over for the host to run its own programs, processes and services.

Started with the Hyper-V Manager and chose to create a new virtual machine.

clip_image001

You see the "Before you begin" screen to start with. Skipped ahead by clicking on "Next >"

clip_image002

On the next screen, gave a name to the VM and selected a location to save it to. Clicked on "Next >" to move on

clip_image003

On the next screen, allocated 512 MB memory to the machine. This should really depend on what the machine is intended to be used for and what memory capacity it requires to have based on the workloads it is expected to handle. Clicked on "Next >" to continue with VM creation.

clip_image004

On the next screen, made the choice of the network switch that the VM will use for communication. Refer to the post here to learn how to set up a virtual network switch on Hyper-V. The choice made as shown in the screen here is an "Internal" virtual switch that allows communications between all VMs connected to this switch and also with the host OS. Clicked on "Next >".

clip_image005

The following screen is where you define the properties of the virtual hard drive that will constitute the virtual machine. Firstly, I chose to create a new virtual hard drive because I didn’t already have one. You can also use an existing .vhdx file if you have one installed. Secondly, I made the choice of allocating the suggested 127 GB. This can be hiked up or down based on how much storage is required on the machine based on its purpose. Important to note here is that allocating 127 GB doesn’t mean that a space that large is blocked off on the disk. The disk increases gradually as data is added to it. Clicked on "Next >".

clip_image006

On the following screen, you get to make a choice of when and what operating system is to be installed on the new virtual hard drive being set up. I chose to install Windows Server 2012 from an ISO image that I had available and clicked "Next >"

clip_image007

The next screen shows a summary of choices made. Clicked "Finish" and done.

clip_image008

This only covers the creation of a new virtual machine and assigning it a virtual hard drive. If it is a newly created virtual hard drive, bear in mind that it will have nothing on it yet and therefore will need to go through an OS installation before it becomes useful.

Categories: Hyper-V Tags: ,

Setting up a virtual switch for a Hyper-V network

March 29, 2013 13 comments

This post speaks to how to set up a virtual switch to be used as the network over which several virtual machines can communicate. We start by launching the Hyper-V Manager application and choosing the "Virtual Switch Manager" from the "Actions" menu on the right

clip_image001

There are three types of virtual switches available – External, Internal and Private.

  • External allows you to connect your VMs to each other and to the physical host machine. It requires a physical adapter on the host machine that will be used to communicate with the physical network that the host is connected to.
  • Internal allows communications between the VMs and the host operating system. It does not require a physical adapter on the host machine and will not allow communication with any actual physical network.
  • Private only allows communications between the virtual machines. It does not allow any communication of the VMs with the host operating system.

Setting up an Internal connection type

Since I may require some transfer of information between the host and the guest operating systems, I decided to use the "Internal" virtual switch type. From past implementations, I have seen that you can change the nature of the virtual switch later but will need to restart the Virtual Machines to reflect changes.

Especially if you are switching to or from the "External" type, it will affect the connection on the host because Hyper-V switches out the physical adapter on the host so that the host operating system may start using a virtual adapter as well. This is because the way the networking works is that the host operating system is no longer allow to use the physical adapter on the host machine once an "External" switch has been configured. A new virtual adapter is installed on the host that becomes the outlet of communication for the host OS. The VMs and the host OS all communicate with the virtual switch through their individual virtual adapter which then routes communication to the other machines for internal conversations and out through the physical adapter on the host machine for external communications.

Made the selection and clicked on "Create Virtual Switch"

clip_image002

Gave the switch a name and chose not to use a VLAN identifier for the host operating system. Clicked on "OK"

clip_image003

And that’s all there is to it for an Internal switch type. At this point, a virtual machine configured to use this connection should be able to communicate with other virtual machines configured to use it and the host operating system given the static IP address allocated to the virtual adapter on the VM is in the same subnet as the host.

To understand how to set this up so that files can be interchanged between the guest and the host, refer to this post on the topic.

Now if you wanted to have your virtual machine have the ability to communicate over the physical network on the host, meaning the ability to access the Internet and so on (assuming your host machine can), an "External" switch will be required.

Setting up an External connection type

An important thing to note about the "External" switch is that it affects the network set up on the host machine as well. Once an "External" switch is set up, the host operating system is no longer able to communicate directly with the physical adapter. Instead, all machines, physical and virtual will use a virtual adapter to communicate with the virtual switch which then routes traffic among machines or in and out through the physical adapter.

clip_image004

Setting up an External Connection Type

So to be able to compare the before and after scenario, here’s the state of the network adapters on my host before I used the "External" switch type. This picture represents the set up at the end of the "Internal" switch type configuration above.

clip_image005

The vEthernet adapter is the Virtual Switch that the "VirtualNet" network I set up above uses. Doing an ipconfig yields the following showing that the vEthernet adapter is unconnected and the host OS is currently connected through the WiFi adapter to the physical network.

clip_image006

Now to change the VirtualNet network type to "External", I went back to the Hyper-V Manager, launched the Virtual Switch Manager and selected the existing "Internal" network called "VirtualNet" that I created above. I changed the "Connection Type" to "External network" and selected the adapter from the drop down that is connected to the physical network. Then clicked on "Apply".

clip_image007

The following warning is presented. This is expected because changes are being made to the network adapters on the host machine. Clicked on "Yes" to apply changes.

clip_image008

And here is the after picture. The WiFi adapter now appears bridged through the Network Bridge added to the picture. The vEthernet adapter on the other hand is now connected to the physical network.

clip_image009

ipconfig now shows the following output

clip_image010

And the multiplexor network bridge properties show the following

clip_image011

A virtual machine set up to use this connection now should be able to tunnel through to the physical connection on the host. One thing to ensure is that the virtual machine is able to accept a DHCP assigned IP. If it has a static IP, you may need to switch it to automatically acquire IP and DNS settings. That done, you should be able to browse the Internet through the virtual machine and DNS resolution would work just fine.

%d bloggers like this: