A basic Windows XP machine can do a lot of things. Apart from facilitating an environment for a user's applications, it can do things like self maintenance, updates, hardware changes, etc. This is nice in a physical environment with lots of different pieces of hardware but in a virtual instance things hardly change, the environment is pretty much set and all tricks to speed things up usually have an adverse effect on the infrastructure. All these virtual instances need to share the often rather limited amount of resources.
To keep things in check, there's a lot of things that can be done to optimize an XP image for a virtual desktop. This guide is created from several documents that are already out there but also from our own experience and experience from a couple of other VDI specialists.
This guide is based on Windows XP because of its low resources usage compared to Vista and even Windows 7. The general idea however also applies to those versions although specific services and registry keys will most likely not work. Skipping Vista, the next version of this guide will focus on Windows 7.
This guide also focuses on VMware View but everything else also applies to templates created with Citrix XenDesktop whether or not combined with a Provisioning Server.
Not all steps are completely documented since most are obvious and some would take too long to explain (and keep things readable). If there are steps that I need to elaborate on, don’t hesitate to email me.
Aligning the disk
The following steps must be follow to create an aligned disk. This is very important because if the disk is misaligned, almost every read or write to the disk layer will result in a double or triple amount of IOs on the storage side. And since storage IOps is usually the bottleneck with VDI, we don’t want that!
This part of the guide uses a Linux distibution because there's probably no Windows (XP) VM already installed and Linux boots from iso so we don't need to install anything. The steps are therefore a bit elaborate because not everybody knows Linux. If you do already have a Windows VM you can also add a new disk to that and use 'diskpart.exe' to align the disk.
- Create a new VM, and choose to create a new disk
- Connect an Ubuntu ISO to the DVD drive (http://www.ubuntu.com/getubuntu/download), and boot from it
- Open a Terminal, and enter the following commands
- sudo su –
- fdisk –l
- (choose disk without a partition)
- fdisk /dev/sdb
- n (new partition)
- p (primary)
- 1 (partition number)
- enter (first block)
- enter (last block)
- a (make bootable)
- 1 (partition number)
- x (expert mode)
- b (change startblock)
- 1 (partition number)
- 128 (128 x 512 byte = 64k)
- w (write)
We now have a Template with Disk Alignment on 64kB.
Installing the OS
This part of the document describes how to create a new VDI template. It is based on Windows XP with Service pack 3 but can also applies to Service pack 2.
- Use a volume license Windows XP ISO that already has SP2/SP3 on it.
- Build a new VM that has at least 512 MB memory and a 6 – 8 GB drive. You may need more or less depending the applications that will be installed.
- Attach the Windows XP ISO to the CD/DVD drive and set it to connect at power on.
- Attach the LSIlogic driver floppy image “/vmimages/floppies/vmscsi-1.2.0.2.flp” to the Floppy drive.
- On the VM Edit Settings window go to the Options tab and in the General section uncheck the Enable logging check box.
- Go to the Boot Options section and check the box to force going into the BIOS on next boot. Power on the VM and when the BIOS appears go to Advanced, I/O Device Configuration. Disable the Serial, Parallel and Floppy ports.
- Go to VM, Edit settings, disconnect the CD and floppy, set them both to Client device.
- Install VMware Tools, choose to do a Custom install. Do not install the Shared Folders driver.
Configure the template
Now you can start building the actual template and configure the following settings. This is needed for an optimal working template with full performance options.
- Go to My Computer properties, Advanced tab, Performance settings. Choose “Adjust for best performance”, click Apply.
- Go to Startup and Recovery settings. Set the debugging information to none, uncheck the “Send an administrative alert”. Click OK.
- Go to Error Reporting and choose Disable error reporting and uncheck the notify box.
- Go to the Remote tab and uncheck both boxes. Click Apply.
- Go to the Automatic Updates tab and turn off automatic updates. Click Apply.
- Go to the System Restore tab and turn off System Restore. Click Apply.
- Go to Add/Remove Programs, Add/Remove Windows Components. Go to Accessories and Utilities, remove Games and remove the optional components shown below.
- Remove MSN Explorer, Networking Services, Outlook Express and Windows Messenger.
- Open User Accounts, click Change the way users log on or off, Uncheck both boxes and click apply.
- Right-click on the taskbar, go to properties and check the box to Display Log Off.
- Right-click on the Start button and choose Open All Users. Delete the three shortcuts for Set Program Access and Defaults, Windows Catalog and Window Update.
- Open Computer Management again, go to Services, Stop and disable these services.
- Computer Browser
- Help and Support
- Indexing Service
- IPSec Service
- Network Local Awareness
- Security Center
- Shell Hardware Detection
- SSDP Discovery Service
- System Restore Service
- Task Scheduler
- Themes
- Windows Firewall/Internet Connection Sharing (ICS)
- Wireless Zero Configuration
- Go to Start, Run and type cmd to open the CMD prompt. Type “FSUTIL behavior set disablelastaccess 1” and press Enter.
- Type “sfc /purgecache”, press enter, type “sfc /cachesize=0” and press enter. Type exit.
- Go to Start, Settings, Printers and Faxes. Go to File, Server Properties, Advanced tab and uncheck all of the boxes.
- Open Internet Explorer, go to Tools, Windows Update. Install the Microsoft Update by clicking the Go button. Install all High Priority updates and under Software, Optional install Root Certificates Update. (first time + second time)
- Don’t install the following updates
- .Net Framework 1.0/2.0/3.0/3.5 Language Packs
- Microsoft Base Smart Card Cryptographic Service Provider Package: x86
- Microsoft Windows Search 4.0 for Windows XP
- Go to the cmd prompt and run this command to unregister the language bar. “Regsvr32.exe /u msutb.dll”
- Go to My Computer properties, Advanced tab, Performance settings, Advanced tab and set the page file on the C drive to 512MB, click Set. Do not reboot yet.
- Download and install the User Profile Hive Cleanup tool. The fastest way to find this tool is to search Google for uphclean.
Additional Windows Tweaks
- [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters] right-click on Parameters and choose New, DWORD value, type DisableTaskOffload and set the Data to 1.
- [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control] right-click on Control and choose New DWORD value, type ServicesPipeTimeout and set the Data to 120000 decimal.
- [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server] and add a new DWORD value called AllowRemoteRPC and set it to 1. This will allow shadowing of the XenDesktop session for remote support. Once this key is set you can shadow a session by running this command “shadow 0 /server:VMNAME.
- [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run] and delete the VMware Tools name.
- [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server] Value Name: TSAdvertise Data Type: REG_DWORD Value Data: 1 (0 = Disabled, 1 = Enabled)
The Remote Assistance feature is a convenient way for an administrator to remotely connect to a computer and with permission view the screen, move the mouse, use the keyboard and chat online.
- [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon] Value Name: DisableCAD Data Type: REG_DWORD Value Data: 1 (0 = Require Ctrl+Alt+Delete, 1 = Disable)
This setting controls whether users are required to press Ctrl+Alt+Delete as a security precaution before logging into the system.
- [HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management] Value Name: DisablePagingExecutive Data Type: REG_DWORD Value Data: 1 (0 = Disabled, 1 = Enabled)
This setting specifies whether kernel-mode drivers and kernel-mode system code can be paged to disk when not in use.
- [HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management\PrefetchParameters] Value Name: EnablePrefetcher Data Type: REG_DWORD Value Data: 0 (0 = Disabled, 1 = Enabled)
http://msdn.microsoft.com/en-us/library/ms940847(WinEmbedded.5).aspx
Create a default user profile
- Create a new user profile and logon with that account. This is needed for copy this profile later to the Default user profile. In this profile are the most default user settings.
- Right-click on the desktop and go to display properties, set the theme to Windows Classic.
- Set the Screen Saver to none. Click Apply.
- Right-click on the taskbar and go to properties. Go to the Start Menu tab and choose Classic Start Menu, click apply, click Customize.
- Scroll to the bottom of the Advanced Start menu options and check the box for “Show Small Icons in Start menu” and uncheck the “Use Personalized Menus” box. Click OK, and click OK.
- Right-click on the desktop and go to properties. Go to the Desktop tab and click Customize Desktop, uncheck the Run Desktop Cleanup Wizard every 60 days, click OK, click Apply.
- Go to the Appearance tab and click Advanced, uncheck all of the boxes and click OK. Click OK.
- Right-click on the taskbar, go to Toolbars and choose Quick Launch.
- Open the Control Panel, go to the View menu, choose Status bar and List.
- Right-click on the Go button and uncheck the Go Button.
- Right-click on the toolbar and choose Customize, set the Text options to No text labels and set Icon options to Small icons.
- Go to Tools, Folder Options, View tab and check/uncheck the boxes below.
- Uncheck “Hide extensions for known file types”
- Go to Start, Run and type regedit, go to this key, HKEY_USERS\.DEFAULT\Control Panel\Desktop and delete the SCRNSAVE.EXE name.
- Go to HKEY_CURRENT_USER\Control Panel\Desktop and change the MenuShowDelay to 0.
- Right-click on Internet Explorer on the desktop and go to properties. Set the Home page to blank and click Delete and then click Delete all, check the box to Also delete files.
- Go to the Advanced tab and check/uncheck the boxes below:
- Check “Force offscreen compositing even under Terminal Server”
- Uncheck “Enable page transitions”
- Uncheck “Enable visual styles on buttons and controls in webpages”
- Uncheck “Show friendly HTTP error messages”
- Uncheck “Use smooth scrolling”
- Open Internet Explorer and go through the first time startup wizard, choose to keep. Change the default search provider from Live Search to Google.
Save the default user profile
Login with the Local Administrator account, and save the Default user profile. This can be done with the following steps.
- Right-click on My Computer, go to Properties, Advanced, User Profiles Settings, select temp, copy to, browse to c:\documents and settings\default user, change Permitted to use to Authenticated users. Click OK, Click Yes to the confirm copy question.
- Delete the temp user account and user
Group Policy settings
GPOs Under Terminal Services
- Limit maximum color depth = Enable (16bit)
This setting lets you set the color depth for Remote Desktop sessions.
- Allow users to connect remotely using Terminal Services = Enable
This setting ensures that the local policy enabling Remote Desktop connections is configured.
- Remote Windows Security Item from Start Menu = Disable
Setting this to Disable ensure that users have a log off mechanism.
- Remove Disconnect option from Shut down dialog = Enable
This setting minimizes the possibility of users disconnecting rather than logging off.
GPOs Under VMware View
The VMware View ADM files can be found on the following place:
“C:\Program Files\VMware\VMware View\Server\Extras\GroupPolicyFiles”
- VMware View Agent Configuration
- VMware View Client Configuration
- VMware View Common Configuration
- VMware View Server Configuration
Disable VMware View Debug Logging!
Since VMware View 3.1.2, Debug Logging is ON by default. Because of generating large logfiles and a lot of IOPS, you can set the following regkeys to stop Debug Logging:
- Change: Disable “Debugmode en Tracemode” (HKLMàSOFTWAREàVMware, Inc.àVMware VDMàDebugEnabled=False & TraceEnabled=False)
- Change: Disable “View Composer related debug logging in the View Agent” (HKLMàSYSTEMàCurrentControlSetàServicesàvmware-viewcomposer-gaàLogLevel=0)
Updating the VMware View template
The VDI template must be updated on a regular basis. The following steps must be taken when updating the template:
- Windows Update (Every month)
- Virus Scanner updates (Every week)
- Go to C:\WINDOWS and delete all the folders that start and end with a $ (except $hf_mig$) à After Windows Update
- Run Disk Cleanup.
- Defragment the C: drive.
- Delete VMware View Agent, reboot, and install it again
- Power Down the VM, and make a snapshot
And that's it. Do this once and you have a solid base for your VDI VMs.