Bernhard's Homepage

GNS3 - Create a Windows 2008 R2 template

GNS3 - Create a Windows 2008 R2 template

I wanted to create an efficient Windows template, that runs well within GNS3. Windows 10 is too big for my liking, I wanted something smaller. Windows XP is extremely small, but a lot of programs are no longer supporting it.

So I chose an OS from the Windows 7 family, Windows Server 2008 R2. It has the big advantage that installation media are officially available, at least so far. In addition it includes several networking server programs.

But these older versions Windows versions are no longer supported. So they should never be exposed to the internet. But in the closed environment of a GNS3 project its usage is acceptable, IMHO.

However, if you prefer, choose a different version of Windows. The following instructions may give you also some hints in this case.

Installation Media

Download these ISOs and copy them to the GNS3/images/QEMU directory. When using the GNS3VM use WinSCP to upload them to the /opt/gns3/images/QEMU directory.

Windows 2008 R2 https://www.microsoft.com/en-us/download/details.aspx?id=11093
virtIO Drivers https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/archive-virtio/virtio-win-0.1.173-9/virtio-win-0.1.173.iso

I had issues with the latest VirtIO drivers, so I recommend to stick with version 0.1.173.

Shared Folder (optional)

I’m going to use a shared folder for the Windows VMs. That allows easy exchange of data and programs betwenn the VMs and the host. On the Linux side Samba will be used to provide a file service, that the Windows VMs allow to exchange files.

On a Linux based GNS3 create the directory shared in the GNS3 directory, then install Samba.

When using the GNS3VM the shared folder resides in the GNS3VM. You can use WinSCP to transfer files between the shared folder /opt/gns3/shared of the GNS3VM and your host.

To install Samba open the command line in the GNS3VM and enter:

mkdir /opt/gns3/shared
sudo apt-get update
sudo apt-get install --no-install-recommends samba

Create the Installation Template

Open the GNS3 preferences and select the QEMU / Qemu VMs section. Use “New” to create the Windows template. The “New QEMU VM template” wizard will start and it asks a couple of questions:

  • Name: Give the VM a name, e.g. Win2008
  • Qemu binary: Select a qemu-system-x86_64 binary
  • RAM: 1024 MB
  • Console type: vnc or spice (if you have a spice viewer installed)
  • Disk image: Select “New image”, then “Create”
    • Use the defaults in the next two dialogs (‘binary and format’ and ‘qcow2 options’)
    • Set “windows2008r2-install.qcow2” as file location and choose a suitable disk size, for example stick with the default 30.000 MiB.
    • Finish the QEMU image creator wizard.
  • “Finish” the wizard

Now edit the freshly created template and modify it:

In the general settings mainly change the boot priority to “HDD or CD/DCD-ROM”. Additionally I changed the symbol to the Microsoft logo.

Template General settings

In the HDD settings change the disk interface to “scsi”.

Template HDD

In the CD/DVD section enter the Windows installation ISO.

Template CD/DVD

The network settings can remain unchanged. I only changed the name format, but that’s optional. I kept the default e1000 adapter type, it’s working quite well.

Template Network

The most complex changes have to be made in the advanced tab.

Add the following string as one long line to the additional options.

-vga qxl -usbdevice tablet -rtc base=localtime
-nic user,model=e1000,hostname=winvm,restrict=yes,smb=/opt/gns3/shared
-drive file=/opt/gns3/images/QEMU/virtio-win-0.1.173.iso,media=cdrom

Here a short breakdown:

  • -vga qxl
    This uses the (virtual) QXL adapter for video. As this adapter type is compatible to VGA, the display works even without a special driver, just without the advanced features.
  • -usbdevice tablet
    This emulates a tablet as a mouse device. The main advantage is, that absolute pointer positions are transmitted to the VM, so the mouse pointer in the host display and the VM are synchronized.
  • -rtc base=localtime
    Set the realtime clock of the VM to the local time of the host, default is to use the UTC time.
  • -nic user,model=e1000,hostname=winvm,restrict=yes,smb=/opt/gns3/shared
    Add a network link between the VM and the host used by the shared folder. If you don’t want this feature, leave this out.
  • -drive file=/opt/gns3/images/QEMU/virtio-win-0.1.173.iso,media=cdrom
    Add a second CD/DVD with the virtIO drivers.

Very important: Don’t miss to uncheck the “Use as a linked base VM” option.

Template Advanced

At last apply the changes with “OK”, then leave the preferences with “OK”.

Installation

Drag the Windows 2008R2 template into a temporary project and start it. The OS installation will begin the usual way. First it will ask for the language preferences, then let the installation continue with “Install now”. Next you have to select the OS variant, choose the default “Windows Server 2008 R2 Standard (Full Installation)”. Then you have to read and accept the license. Finally select the custom install.

Now you should select the drive, but there is none to choose from. That’s because Windows hasn’t yet loaded the driver for the virtual disk. Select “Load Driver”, confirm with OK and then select the driver with “2k8R2” in its path.

Install select Driver

Now Windows detects our virtual hard drive and the installation can continue.

Install Harddisk detected

Finally the freshly installed Windows boots. You have to set the administrator password and then you are in.

We are not yet done, the display adapter still uses the standard VGA driver. We need to start the Device Manager (Start / Control Panel / System and Security / System / Device Manager), select the display adapter, right-click, then select the driver software update.

Device Manager

In Update Driver Software select “Browse my computer for driver software”. In the following “Browse for driver” window set the search location to D:\, then continue with “Next”.

Update Driver Software

Windows scans the drivers disk and installs the QXL device driver. Windows finally needs a reboot to activate this new driver.

Activate Shared Folder in Windows (optional)

If you enabled the shared folder in QEMU, it’s now time to activate it on Windows. In Windows start the Explorer and open “Map network drive” (F10 / Tools / Map network drive…). Choose a drive letter and set \\10.0.2.4\qemu as the folder, then Finish.

Activate Shared Folder in Windows

Starting an .EXE from the network drive takes quite some time and requires, that the file has execute permission on the Linux side (chmod +x). In most cases it’s easier to copy the .EXE to drive C: and start it from there.

Windows Updates (optional)

If you like, you can install the updates to bring the installation to a more recent state. But that will take about one hour and will need additional 3 GB of disk space.

In 2016 Microsoft released a rollup of the updates released so far, it’s a sort of unofficial SP2. Download and install KB3020369 and KB3125574.

In 2019 Microsoft changed the code signing method to SHA-2, install KB4490628 and KB4474419.

And last but not least add the cumulated update from January 2020, KB4539601.

Windows Activation Workaround

As Windows 2008 R2 is no longer supported, you can’t activate it. So you get only 10 days until Windows will start nagging you. The workaround is to cheat with the date/time. We will instruct QEMU to use always the same date and time, when starting the Windows VM. Additionally we will remove the CD/DVD settings.

But first we need to disable the internet time synchronization in Windows. Click on the date/time in the lower right and start the “Change date and time settings…” function. Select the Internet Time tab and “Change settings…”. Here disable the “Synchronize with an Internet time server” setting and confirm it with OK.

Now shutdown the Windows VM and remove the node from the GNS3 project. Then open the GNS3 preferences and navigate to the QEMU / Qemu VMs settings.

Then edit the Windows template:

  • Advanced / Additional options: Change -rtc base=localtime to -rtc base=YYYY-MM-DDThh:mm:ss, for example -rtc base=2021-02-16T14:07:00. The date/time entered must be later than the installation time.
  • Advanced / Additional options: Remove the -drive file=...,media=cdrom option for the second CD/DVD.
  • CD/DVD: Clear the image name of the first CD/DVD.
  • General settings: Change the boot priority to HDD.

Apply these changes with OK, leave the preferences with OK.

Then drag the updated template to the project and start it. It now shows the date you set.

Enable IE for Web Browsing (optional)

By default the Internet Explorer Enhanced Security Configuration (IE ESC) is enabled, which prevents using the IE for web browsing.

If you want to enable it:

  • Open the Server Manager (Start -> Administrative Tools -> Server Manager)
  • In the right window pane scroll to the Security Information section
  • Click “Configure IE ESC” on the far right
  • Select Off for both Administrators and Users
  • Click OK

Then start IE and run the first time configuration.

Customization

You may now modify some Windows settings and/or install some utilities.

At least you should install the sdelete utility. Download it from https://docs.microsoft.com/en-us/sysinternals/downloads/sdelete and move sdelete64.exe out of the ZIP file to C:\.

Disk Optimization

This is the final step (hooray).

Caution: This operation requires about 30 GB of free disk space.

If installed, run sdelete64 -z C: in a Windows Command Prompt window.

Now shutdown the VM and delete the node from the project.

To optimize the VM open the command line in the GNS3VM/Linux server and enter:

cd /opt/gns3/images/QEMU
qemu-img convert -c -O qcow2 windows2008r2-install.qcow2 windows2008r2.qcow2
rm windows2008r2-install.qcow2*

Then open the GNS3 preferences, navigate to the QEMU / Qemu VMs settings and edit the Windows template:

  • HDD: change disk image from windows2008r2-install.qcow2 to windows2008r2.qcow2.
  • Advanced: Enable “Use as a linked base VM”.

Apply these changes with OK, leave the preferences with OK.

Now your template is finally ready for regular use.