Welcome to Part 2 in the Building Your Own VM Lab blog series. In the Part 1, we went over the basic considerations for picking the host that fits you and your situation best. This included the box(i.e. laptop, desktop, cloud), the host software(i.e. VMWare, Hyper-V, etc.), and host hardware configurations which come in to play when not going the cloud route.
For this post I will assume that you have picked a software platform for your host. The platform I have chosen to use for my VM host is Hyper-V. If you choose to use something different, please keep in mind my screen shots will look different than what you will see, but the VM steps and basic ideas of the steps I outline will still apply. If you have any problems following my steps, leave a comment and I will do my best to help you along.
The first step I did was to create a virtual switch for each of the types of network connections I wanted. I recommend go ahead and create a virtual switch for External, Internal, and Private network types. An external network is just exactly what it sounds like, it’s an external network connection that allows the VM the ability to talk to the host and the outside world. An internal network is a connection that allows the VM to talk to the other VM’s on that host, along with the host computer. A private network is a connection that allows the VM’s on that network to talk to each other, but it does not allow the VM’s to talk to the host, or vice versa.
Once you have the network switches in place for your VM’s, you can do one of two things. You can start building the VM’s one by one, or you can do what I’m going to show you, which is to build a template machine(s) to use for all of the machines you will create.
Hyper-V Virtual Machine Templates
One of the main uses of a VM Lab is learning, though a lot of us use the VM lab for presentation environments. Either way, there are two handy features of setting up your lab in a virtual environment. With a virtual environment you can setup virtual machine templates and virtual machine snapshots, which will talk about later. Both feature comes in handy when you make big mistakes, which can happen very easily when you are learning in a lab environment. You can setup as many templates for virtual machines as you think you need and can store. Some prefer to keep just a basic version for each valid server OS, while others keep variations of each server OS with different software pre-loaded. My library of templates includes: Windows Server 2012 R2 with SQL Server, Windows Server 2012 R2 Core (No GUI), Windows Server 2012 R2 with Sharepoint 2013 Enterprise, Ubuntu Server, and Ubuntu Desktop. For this post we are going to focus on setting up a Windows Server 2012 R2 Standard Full GUI VM template. We’ll go over the settings for creating a template virtual hard disk file and using the sysprep Windows utility to “blank” the installation.
- Once you have Hyper-V Manager open, is to look over to the right hand side and select “New” and the option for Virtual Machine.
- The wizard will open to the “Before you Begin” page. You can go ahead and click Next to go to the next page.
- This page is where you will name the machine. Don’t spend a lot of time on this because this is the VM that you will configure the base disk for templating. When you are done, click Next.
- Unless you have a reason that you want to have your templates be a Generation 1, go ahead and click Generation 2 here and click Next.
- This page is where you will assign memory. Don’t go crazy and use up all of your host memory, but don’t use too little so that the installation takes forever. I would recommend 4-8 GB of RAM for this, depending on the available RAM on the host. Once you have the RAM selected, click Next.
- On this page, select which Virtual Network Switch you want to plug this virtual machine in to. For this, I would recommend an external connection. Keep in mind this machine is only going to be used to create this disk. You want to give this machine an external connection so that you can patch the install up to current and download any software you want installed on this VM for each server to have that is created as a child from this disk. Once you select the connection, click Next.
- This tab is where you configure what disk this VM will use. Since we are creating the “Parent” for our difference set, we will select the option to create a new disk. In this spot, the name of the disk and location is very important. You want to name the disk in a way to tell you what configuration you on the disk. You also want to save it in a place where you will store your template drives for differencing. For this example, I will name the disk “Win2012R2_GUI” and store it in a folder named “Differencing”, where I will store all of my template drives. I usually leave the disk size alone, because for these templates, this size seems to be fine for me. Once you have setup the options correctly, go ahead and click Next.
- On this page, you can select “Install an operating system later” if you want but I will go ahead and select my installation media. When you do that, it connects the iso file to the cdrom drive for you. Then click Next.
- On the final tab, verify that the options displayed are the options you wanted to select, then click Finish.
Congratulations, you now have a VM. Now, turn on your VM and go through the steps to install the Windows Server 2012 R2 OS. I’m not going to go through all the steps of the installation process here because everyone will probably have different options for how they want to setup their server. Install any software that you may want on all of your servers and install applicable updates. Once that is complete, we will use the Windows utility sysprep. Start by opening an administrator Command Prompt by pressing the windows key, typing cmd, and right clicking Command Prompt when it appears and selecting “Run as Administrator”. In the window that appears, type sysprep.exe and press Enter. When the sysprep window opens, make sure the options for “Generalize” and “Shutdown”, then click OK. Sysprep will take it from here and generalize the installation and shutdown the VM when it’s done. Now you have your parent disk ready to make duplications of it.
To make a duplication of that drive, we will go back to the main Hyper-V Manager window.
- Go to the right hand side and click “New” and “Hard Drive”.
- Again, here’s our favorite “Before you Begin”. Go ahead and click Next.
- Here you will select the type of hard disk file, vhd or vhdx. I personally select vhdx because it supports larger disk size and is the new format. Select the file type and click Next.
- This page is where you will select disk format. Since we are creating a child disk, select the option for differencing and click Next.
- On this screen, select the name for the drive and where you want to store the disk and click Next.
- On this page is where we will select the parent disk that we created earlier as the template for this disk. Once you browse to that drive file, click Next.
- On the Summary page, verify that the displayed settings are correct, then click Finish.
Now you have a child drive. To setup a VM for this drive, follow the same steps you did for creating the VM for setting up the parent drive until you get to the Virtual Hard Disk step and select the option for using an existing disk. Navigate to the child drive you just selected. On the OS installation disk step, select the option for installing an OS later.
Congrats. You now have a parent templating disk and it’s first child. The next post we will cover setting up the first VM in our Virtual Machine Lab. We will cover a little bit on basic networking and basic Active Directory setup. This first VM will lay the ground work for your virtual network for connectivity to each other.
As always, please share your experiences, questions, or comments below. I look forward to hearing from everyone. If you have any questions for me, feel free to email me, email@example.com, or on twitter @JoshLuedeman.