Setting up Windows development environment with VirtualBox

Over the years, I’ve used many virtualization software for testing, hacking, and development work. So far my favorite virtualization software is VirtualBox.

I’ve written about using Vagrant and Veewee to make that process easier. I’ve since changed my strategy slightly:

  • I don’t recommend using Veewee anymore, because silly Ruby compatibility issues. I like the idea of Veewee, but in my opinion jumping through hoops to get it to work with Vagrant is no longer worth it. It is often quicker to just build a VirtualBox vm and then create a Vagrant box out of it than taking the Veewee extra step and remembering those extra commands. I couldn’t find the link now, but I thought I read somewhere that Vagrant has plans to make VM box creation easier;
  • I don’t use Vagrant for managing Windows VMs anymore. I tried but my effort was not too successful so far. Again, I read it somewhere that Windows support will be provided in future release of Vagrant. We will see.

My use cases in the past mostly involves single VM. For networking among Linux VMs, the instruction in my Vagrant post still works. But what if you want to build a Windows VM environment with domain controller, database servers, web servers, and other application servers based on a single VM image. So far I’ve built an environment with a domain controller and a separate application server (I will soon install SQL Server on it). Here is my notes for reference. The host machine is Lenovo W520 running Linux Mint 14.

  1. Download Windows 2012 ISO here;
  2. Start creating a base Windows 2012 VM in VirtualBox. Use the vdi disk type to make it easier working with VirtualBox;
  3. I could have installed the Data Center eval edition, but chose the standard instead. I didn’t choose the Core edition. Using the Core edition might make more sense in a real production environment, but I’d like to get something going quickly and also want to use the same image for all future VM needs, so the standard non-Core install works the best for now. I may come back and play with the Core edition down the road;

    Note: There are sites that talks about the possibility of activating Windows with an official license key, so that future VMs based on this image no longer need activation. My advice is: don’t bother with it. Licensing issue aside, my reasoning is that if you decide the VMs are going to be part of a domain, they then need to have their unique SID, which requires a separate Windows key, I think. Plus, I’ve run eval edition of Windows that has past its validation date but it still functions, probably in some limited capacity, but so far it hasn’t affected me. So I am hopeful that for my purposes, the eval edition of Windows 2012 will satisfy my need.

  4. Build the base VM with NAT networking. It is convenient for the VM to have access to the web directly. We will add additional network card(s) when we clone this base image.

    Once the base VM is built, copy that single vdi file somewhere else. Then remove/delete this base VM from your system all together;

  5. Make the base vdi immutable by running this:
    [code language=”text”]
    VBoxManage modifyhd pathTo/myBase.vdi –type immutable
  6. Build a domain controller based on this image. When creating a VirtualBox hard disk, use the base vdi file. At this point, add in a second network adapter, which should be type “Internal Network”. Take the VirtualBox default value for the rest of the fields;
  7. Finish building the VM, change the VM to a proper name, such as DCServer or whatever you feel is appropriate;
  8. Shutdown the VM, then run this command against the vdi file in your new VM’s Snapshots folder:
    [code language=”text”]
    VBoxManage modifyhd ~/Virtual Machines/myNewVM/Snapshots/{someName}.vdi –autoreset false
    This step is necessary, otherwise VirtualBox resets the VM to the base image after every reboot;
  9. Now install the appropriate software and set this VM as a domain controller. Follow instructions here.
  10. Configure the network card for the “Internal Network” by assigning a fixed IP address. If you’ve followed the instructions, the second network card should be called Ethernet 2. I didn’t bother with IPv6, and gave my VM the fixed IP address of I left everything else to its default value;
  11. Turn off all Windows firewalls. In addition, open up “Group Policy Management”, expand to Domains->MyDomain->Default Domain Policy. Right click and choose “Edit…”. Group Policy Management Editor opens up. Under “Computer Configuration”, expand to Policies->Windows Settings->Security Settings->Account Policies. Change password policy accordingly. Remember to make sure the policy is enforced by right clicking and picking Enforce.
  12. Take a snapshot of the machine. Mark every disk file under the Snapshot folder so its autoreset is false.
  13. Now build another VM. Add the second network adapter for “Internal Network”. When done, shut it down and change its vdi disk file’s autoreset property, described above;
  14. Because this VM and the domain controller VM use the same base image, so by default they will have the same SID, which will prevent them to be in the same domain. Fix that by starting this new VM, then run sysprep. Follow the instructions here, if you need it.
  15. Reboot the new VM again, configure its “Ethernet 2” before it can join the domain we created earlier. Here is my configuration. Once again I didn’t touch IPv6:
    IP address:
    Subnet mask:
    Default gateway:
    Preferred DNS server:
  16. Rename the VM to an appropriate name, for example, sql1. Then join the domain we created earlier. Obviously the other domain controller VM needs to be up and you’ve run sysprep on this second VM. If you haven’t assigned a different SID for this new VM, you will receive error message like “the domain join cannot be completed because the SID of the domain you attempted to join was identical to the SID of this machine …”
  17. Repeat the process of building other VMs to join the domain, if you have the need.

Any comments/suggestions welcome. Good luck!

, ,

3 responses to “Setting up Windows development environment with VirtualBox”

  1. It’s very important to configure WINS server of the member node to be same as IP of the Domain Controller. Otherwise, even if they are on the same network you won’t be able to join the domain.

    ps: thanks for the blog post, it had useful info that ultimately led me in the right direction.

  2. Thanks for the comment, Alex.

    I’ve done this a couple of times and I didn’t have to mess with WINS. So this is strange, but I am happy you’ve got a solution!

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.