Tuesday, 7 April 2009

Building the base images and making them immutable (read-only) - Part I

So, today I am going to cover building the base images for a Windows Server 2003 development environment. I'm not going to step through how to install Windows 2003, there are plenty of other documents that describe that elsewhere on the InterWeb. Instead I'll describe the important bits of VirtualBox to help those starting out with this. I will begin with an overview of the disk types in VirtualBox we are going to use and what they mean.

So, there are two types of disk of importance to this tutorial.
  1. Normal Disks: Just standard read/write disks implemented through either files on the filesystem OR as raw partitions on a physical disk (advanced and not what we do here!).
  2. Immutable Disks: These are read-only disks attached to a virtual machine that aren't changed as a result of anything that goes on during usage of the machine and perfect for what we want to achieve.

Other types will become evident in later tutorials but for now these are all we need to care about.

So, without further ado lets describe the process of creating an immutable base Windows 2003 image!

Stage 1: Create the first Virtual Machine

This bit is fairly easy, but essentially I create a Virtual Machine named "W2K3_Base1_NoAD" with as much memory as I can - usually just under 50% of physical memory. When it comes to selecting the Hard Disk for the virtual machine I select "New" and the new disk wizard pops up. skip through the first screen and on the "Storage Type" screen ensure "Dynamically expanding storage" is checked. This ensures we have the smallest image we can for the immutable base image. Select a location for the disk - I use the structure in the following diagram but this requires some config file hacking to make it so clean (see later - and heed the warning!!") - and a size. For the size I have found 20Gb is about the right size for a good W2K3 install + a few server products such as BizTalk Server 2006 R2 and MOSS 2007, etc. Once you have this click "Finish" on the next page and this new disk should be the disk selected back in the Virtual Machine wizard. Click "Next" and "Finish" to finish the creation of the virtual machine.

Job done. All that remains is to do some final "tweaking" of the machine config so we can begin installing. If you select the machine in the left hand column of VirtualBox and click "Settings" you can tune the underlying "hardware" of the virtual machine. On the presented "General->Basic" settings page I usually crank up the Video Memory to 32Mb. Not sure it matters too much but it makes me feel better. On the "Network Settings->Adapter1" I set the "Attached to:" value to "NAT" as this is the only combination that works on my laptop due to some wierd low level firewall drivers being installed. incidentally the same reason I can't use VMWare on this laptop either. NAT works though, and - as a bonus - works very well.

That's it. You are now ready to power on the machine and install your favourite (or required!) OS - which for this is Windows Server 2003 R2 if you hadn't already guessed!

Stage 2: Install the base Windows 2003 Server software

This bit is pretty easy and I won't bore you too much with the details. The hardest thing here is pointing the CD/DVD to either the physical media or an iso image of the installation media. I choose the latter because I download them from my MSDN subscription. Doesn't really matter which one you use as long as the media is valid and you have a valid key.

Attach a CD/DVD by one of 2 methods (well, 3 but I am leaving the command line alone for now - a future tutorial perhaps). Either select the virtual machine in the VirtualBox console and select the "CD/DVD-ROM" page. In the property sheet select the "Mount CD/DVD Drive" option and then point to the physical drive with the CD/DVD in or select the "Virtual Media Manager" button highlighted on the right in the diagram below (click to "Go Large")


The same functions can be accessed using the "Devices->Mount CD/DVD" menu options when the VM is powered on.

Power up the machine and walk through the chosen OS installation routine.


Once this is complete, let the machine reboot and log in. You can choose to carry out a "Windows Update" now, which I tend to do to make sure the server is as secure as possible before exposing to incoming network connections, or leave it until you have installed IIS 6.0. Since an IIS requirement is pretty ubiquitous in the world of .NET training and development I have chosen to have this as part of the very base installation.

Once you have installed all the required base components do a Windows Update again and then you are good to compact the disk to use the smallest space possible.


To be continued tomorrow ....

4 comments:

  1. Where's the continuation of this, please?

    ReplyDelete
  2. Hi,

    I just got on your blog to learn about the hard disk world and VirtualBox....

    Are you planning to blog again from the point where you stopped? I already created the folder structure :)

    Really hope you're coming back!

    Kr,

    Pieter

    ReplyDelete
  3. There's no tomorrow... we are all doomed!

    ReplyDelete
  4. tomorrow never comes...

    My blogging was interrupted by life and one very large integration iniative in the banking world and this took a lower priority.

    This coinciding with a data loss and a dodgy hard drive has resulted in tomorrow being the death of all blogging.

    I am about to return. this will be completed :)

    ReplyDelete