In this post I want to cover running SQL Server within Hyper-V on your own laptop.
For many years I’ve used virtualization to host Virtual machines on my own computers, something you might have noticed previously in my Azure DevOps 2019 post here. In fact, before Hyper- V was free within Windows I used VirtualBox.
Previously a former employer joked about the fact I had my own Data Centre running on my laptop. Because I was running a combination of Windows and Linux servers in Virtual machines.
In this post I’ll discuss tips for running SQL Server within Hyper-V on your own laptop or desktop. Note that this post is based on Hyper-V with Windows 10 installed, however parts of it can be applied to other versions.
Reasons to use Hyper-V
Now I know using Containers and Docker is becoming more popular, but there are still times when Virtual Machines might be a better option. For instance, when you want to simulate a deployment experience of an Operating System and application.
Another good reason to use Hyper-V to create Virtual machines is so that you can modify them and then move them somewhere else afterwards. For example, into Azure Stack or somewhere online hosted by a cloud provider.
If you want further information about Azure Stack you can read my previous post here. In addition, if you want to know more about cloud infrastructure options read my post about them here.
Visual Studio Subscription
Well if you are looking to keep your Virtual Machines long term I suggest trying to get a Visual Studio subscription.
Because then you can install development servers and their applications locally depending on which plan you use.
Previously this was known as an MSDN subscription. Note that if you intend to install Sharepoint using this subscription either you or your employer will need deep pockets because you can only get it with the most expensive plan.
I certainly recommend creating a single folder to store all your Virtual machines in. This will make them easier to manage because they will all be in one central place.
Now as far as I am concerned this is a must if you intend to use the same version of Windows Operating Systems.
This is where you essentially install an Operating System on one disk. Afterwards you sysprep it and then use it as a master disk for other disks that you create in the future.
It certainly saves a lot of space. Further information about sysprep can be found by following either of the links in the ‘Domain’ section.
For some reason it’s not very well known that you can use Powershell for a lot of Hyper-V tasks on your own laptop. However, you can, and I highly recommend you investigate it.
I also recommend to use Powershell more when you install applications and updates. One of the reasons why I suggest this is because I notice an very interesting issue that sometimes happens when you are using Hyper-V or Remote Desktop Connections.
Occasionally the installation screen will freeze if you minimize the session or when you lock your desktop.
Planning your network before configuring your environment will make your install easier. To clarify, you can use three types of network for your Virtual Machines.
- Private network; which is where they can only connect to each other depending on their network settings.
- Internal network; which is where they can connect to each other and your desktop as well depending on network settings. This can be done via a network adapter in the virtual machine and a virtual adapter that Hyper-V installs on your local computer.
- External network; which is where the virtual machines can connect to the rest of your network and potentially beyond.
Now if you’re looking to just deploy servers as a simple proof of concept a private network is suitable enough. An example of proof of concept may be setting up an AlwaysOn environment.
However, if you are looking to deploy an solution that you want to manage using an application or portal, then I recommend configuring an internal network.
I highly recommend this for complex applications that require a portal like Azure DevOps Server 2019.
For instance, one option is to first make sure you have an internal network created within Hyper-V. After this create another network adapter within your virtual machine. In addition, Whilst doing this confirm this adapter is on the internal network.
Afterwards, configure it to be on the same subnet as the internal adapter Hyper-V creates on your own laptop.
Now if you are building a Windows environment for long term use then you will have to set setup a Domain with at least one Domain controller. Jonathan Kehayias wrote an article to create such an environment many years ago here.
Things have changed slightly since he wrote this article. Nevertheless, you can use his article as a baseline and update the Operating Systems and technology involved.
However, you maybe interested in the post written by the SQL Undercover team instead. This post uses updated Operating Systems and you can read it here.
Operating System tip
Now if you do decide to build a whole domain I strongly recommend you use older versions of Windows Operating Systems for any Domain Controllers and routers you create.
Doing this will indeed make those virtual machines consume less resources. Plus, it will help with any Operating System limits you might have on your Visual Studio subscription.
Now if you are looking to use your virtual machines for anything more then a Domain Controller or router I have another recommendation. Which is to increase the number of Processors accordingly within the Virtual machine to at the very least two.
For more advanced applications like Sharepoint and Azure DevOps Server 2019 I recommend allocating as many virtual processors as you can, without stating more then the number of cores your laptop has.
Now in Hyper-V you can use dynamic memory. This is great; however it can cause issues when you want to install applications like SQL Server.
My advice is to set the memory to a decent static value whilst installing applications and then change them back to dynamic memory afterwards.
Now for latest versions of Hyper-V I certainly recommend setting you virtual machines to use Generation 2. However, I have noticed that sometimes that there are issues with some ISO files working with them.
If this is the case the simple solution is to create a machine as Generation 1 and see if it works on there afterwards.
Well that’s it from me about running SQL Server within Hyper-V on your own laptop.
I truly hope you have found these tips useful. If you have any other tips or recommendations about this topic then I gladly welcome them as a comment.
[…] Running SQL Server within Hyper-V on your own laptop […]
[…] you can probably tell from my previous post here I use Hyper-V on my Windows laptop. However, this may not be your personal choice for various […]
[…] Since the introduction of containers and Docker this has become a less popular option. However, you can still read an old post of mine with tips in here. […]