Title: WIN388 Using Virtual PC 2004: Tips and Tricks
1WIN388Using Virtual PC 2004Tips and Tricks
- Ronald BeekelaarBeekelaar Consultancy
2About the speaker
- Consultant and trainer from The Netherlands
- MVP - Virtual PC
- Using Microsoft Virtual PC 2004
- For demos, presentations and courseware
- For hands-on labs at conferences
- Several security labs / XP SP2 labs
- For classes, studying and testing
- Contact
- E-mail ronald_at_beekelaar.com
3AgendaTopics
- How does Virtual PC work
- Architecture
- Networking
- Disks
- Hands-on labs at TechEd 2004 Amsterdam
- Tips
- Tips to optimize disk space
- Tips to optimize performance
- Tips for building VMs
- Tips for deploying VMs
4AgendaNot so topics
- Not in presentation
- Microsoft Virtual Server 2005
- Comparison with other products
- Such as VMware Workstation
- Upgrading from Virtual PC 5.2
5AgendaPresentation disclaimer
- Disclaimer
- Many tips are undocumented or unsupported
- Many examples are unsupportedby Microsoft
Product Support Services (PSS) - Such as running Win2003 in Virtual PC
- Not necessarily "best" practices
- Mostly things I use myself
- EULA
- Always need to follow product activation rules
- Always need to adhere to product licensing rule
6About virtual machines (VM)
- Software running on Windows (host)to create
virtual computers - Allows multiple operating systems and their
applications to run in transportable virtual
machines - Each virtual machine (guest)is equivalent to a
PC anda list of hardware devices - Terms usedvm virtual pc image
7How does Virtual PC workOverview
- PC hardware emulation in a window
- Change configuration through GUI
- Configuration stored in .vmc file (XML)and
options.xml file - Guest OS doesn't "know"
- Only need to install VM Additions in guest
type"integer"256
...
2
unt
8How does Virtual PC workHardware components
- BIOS
- AMI (plus APM 1.2 and ACPI)
- Network adapter
- DEC / Intel 21140 Based PCI Faster Ethernet
- Supported by the RIS rbfg.exe disk
- Sound
- Creative Labs Sound Blaster 16
- Memory
- Max 3.6 GB
- CPU
- Sees only one processor
9How does Virtual PC workArchitecture
- Virtual
- Virtual PC application on top of host OS
- Access
- CPU and memory directly
- Rest through host OS drivers
- VM port ? host port
- VM SB16 ? host sound driver
- ...
- VM diskette ? host diskette or .vfd file on host
(1.44 MB) - VM CD-rom ? host CD-rom or .iso file on host
- VM disk ? .vhd file on host
- VM network ? host network or between VMs
10How does Virtual PC work Architecture
Virtual PC
Software
Hardware
Diskfile
11How does Virtual PC workVirtual Machine Additions
- Provides
- Performance improvements
- CPU - at 96-97 of host
- Network - at 70-90 of host
- Disk - at 40-70 of host
- Arbitrary screen resizing
- "Back-doors"
- Time sync
- Clipboard sync
- Shared folders
- Drag-n-drop
12How does Virtual PC work "Back doors"
VM Additions
Virtual PC
Software
Virtual pc.exe
Hardware
13How does Virtual PC workVirtual Machine Additions
- When is VM Additions working
- At startup, look at icon
- Start (or restart) service if needed
- Look atAction/Properties/Advanced
14How does Virtual PC workSpecial keys
- Host-key any
- Default host-key is Alt
- Alt-Del Send Ctrl-Alt-Del
- Alt-Enter Full screen
- Alt-? ? Prev / next VM
- Alt key Uncapture mouse
- Tip After using Alt-Enter (full-screen)
multiple times, the keyboard may no longer
respond - To resolve press Ctrl key twice
15NetworkingOverview
- Uses a virtual switchand virtual network
adapters (max 4)and virtual "virtual machines" - Three configurations (per adapter)
- Shared Networking (NAT)
- Connect to host adapter
- Local only
16NetworkingThree configurations
Sharednetworking(NAT)
Connect to adapter
Local only
.1-.253
10.4.1.1
Virtual PC.exe
10.1.2.4
10.1.2.4
10.1.2.4
10.1.2.4
C\ ipconfig /all IP Configuration MAC Address
00-03-FF-... IP Address 192.168.131.65
Subnet Mask 255.255.255.0 Gateway
192.168.131.254 DHCP Server 192.168.131.254
DNS Server 10.6.180.53 Lease 17 yr, 4
day
C\ ipconfig /all IP Configuration MAC Address
00-03-FF-... IP Address 10.1.2.7 Subnet
Mask 255.255.255.0 Gateway 10.1.2.1
DHCP Server 10.1.2.30 DNS Server
10.6.180.53 Lease 7 days
C\ ipconfig /all IP Configuration MAC Address
00-03-FF-... IP Address 10.4.1.1 Subnet
Mask 255.255.255.0 Gateway - DHCP
Server - DNS Server - Lease -
17NetworkingAdditional information
- Shared networking (NAT)
- DNS address is copied from host computer
- Default gateway is 192.168.131.254
- Multiple VMs using NAT on some host computer
cannot communicate - To create seperate networks with multiple VMs
- 1 Install Microsoft Loopback Adapter(s)
- 2 Ensure Virtual Machine Network Services is
enabled - 3 Connect VM to Loopback adapter
18DisksOverview
- Hard disks
- IDE (max 3x) - no SCSI
- Types
- Virtual disk (dynamically expanding)
- Stored in .vhd file on host
- Fixed size disk
- Differencing disk
- Stores changes from .vhd
- Linked to hard disk
19Virtual DisksDisk files
- VM disks stored in files on host
- "Normal" disk .vhd
- Differencing disk .vhd (.vhdd)
- Undo disk .vud
- Saved state file .vsv
- Note I added custom elements,which are not in
Virtual PC - Pie chart icons are custom
- .vhdd extension is custom
20Virtual DisksFile locations
- .vhd disk file
- In folder you specifyin settings
- .vhdd disk file
- In folder you specifyin settings
- .vud disk file
- In vmc-file folder
- .vsv disk file
- In vmc-file folder
21DisksTopics
- Undo disks
- Three disk modes
- Persistent / undo-ask / undo-always
- Saved state
- Differencing disks
- Several uses
- Save disk space / Quick testing /Phased
distribution / Sequential delta VMs - Repeatable Restore
- At Tech-Ed 2004 Amsterdam hands-on labs
22DisksUndo disks
- Disks images can be made undoable
- Specify folder to store undoable file per VM
- Stored in .vuh files ( )
- All "writes" are done to .vuh file, not to .vhd
file - Setting for all disks in a VM
23DisksThree disk modes
Start up
Running
Close
Running
Persistent
Undo-Ask
Undo-Always
.vhd file
.vsv file
.vud file
24DisksCommit hard drive changes
- Commit meansMerge vuh undo file with vhd
file
25DisksSaved state
- Store current "state" of running VM in a file,
and close VM window - Goal to continue later at this exact spot
- Stored in .vsv files ( )
- Contains current memory and window settings
26DisksDifferencing disks
- Write changes not to main vhd disk,but to other
disk file - Create a new difference disk in Virtual Disk
Wizard - Plus point to parent vhd disk
- Stored in .vhdd files ( )
- Is actually the same as an .vuh undo disk
- Creates delta VMs
- Delta VMs is not an official term,I made it up
27DisksHow differencing disks works
1
2
4
Read only
3
File-a.doc
File-b.doc
File-d.doc
28Differencing DisksTips
- Never change the parent vhd disk.It will break
all delta VMs! - Make the parent vhd disk read-only
- When creating multiple delta VMs,make sure they
are "unique" - Computer name (rename)
- Computer SID (Sysprep or other SID tool)
- IP address (DHCP)
- MAC address (automatic)
29The case for differencing disks Overview
- Differencing disks have many purposes
- 1 Smaller size on host
- Miami.vhdd.zip 12 MB
- 2 Quick testing
- 3 Phased distribution
- Only offer delta VM for download
- 4 Sequential delta VMs
- Fool proof demo or lab modules
30The case for differencing disks1- Smaller size
on host
- Use less space on host
- Miami.vhdd 410 MB
- Works well withNTFS compression 26 MB
- Works excellent withZIP 12 MB
31The case for differencing disks 2 - Quick testing
- Quickly create temporary VMs
- Steps
- 1 Create difference disk for existing vhd file
- 2 Start up VM using the new vhdd file
- 3 (Test, test, test...)
- 4 Shut down VM
- Keep vhdd file for later, or delete now
- Costs less mental concentrationthan using
Undo-Ask
32The case for differencing disks 3 - Phased
distribution
- Only offer delta VMs for download
- Steps
- 1 Provide one or more "perfect" Windows XP or
Windows Server 2003 master VMs - 2 Offer delta VMs for downloadthat use the
master VMs - 3 'Relink' the delta VMsto the parent (master) VM
33The case for differencing disks 4 - Sequential
delta VMs
- Fool proof demo or lab modules
- Use a separate (growing) delta VM to starteach
demo or lab module - Demo
- Use for series of 'fool proof' demo steps
- Lab
- Use to continue course at any lab
- Use for 'student proof' lab configuration
34The case for differencing disks 4 - Sequential
delta VMs
- Steps
- 1 Create difference disk
- 2 Start up on VM
- 3 Do next demo or lab
- 4 Shut down VM
- 5 Copy and rename difference disk
- 6 Go to step 2
- 7 For each diffence disk, create a separate VM
- Demo or lab can now be started fromany module,
or completed sequentially
35Tech-Ed 2004 Amsterdam Self-paced hands-on labs
- Setup
- Host computers
- 2 GB memory
- 171 labs on 270 host computers
- Two user accounts
- Admin - full administrative access
- HOL User - locked down user
- Windows XP SP2 and Virtual PC 2004 lock down
- Set up
- Use Admin account to deploy VMs for HOL User
- Register VMs
- Set options in Options.xml
36Tech-Ed 2004 Amsterdam Self-paced hands-on labs
- Lab Menu
- Lab Menu
- List each labon host computer
- Start multiple VMs- in order- with delays in
between - Use Repeatable Restore
- To avoid long VM boot times
- To avoid password confusion
37Repeatable Restore General
- Always restore at same point (saved state)
- Not a feature of Virtual PC 2004
- But can be done
- Copy the same initial save state files before
each startup - Virtual PC deletes save state files are startup
38Repeatable Restore Setup
- Setup
- 1 Enable Undo disk
- 2 Start VM
- 3 Configure desired state (log on, etc)
- 4 Close VM and Save State
- 5 Disable Close dialog box
39Repeatable Restore Use
- Use
- 1 Start VM by using script
- Make copy of initial save state files
- Start VM
- Brings up VM in a few seconds
- Which removes one copy of save state files
- 2 Use started VM
- 3 Close VM
- No Close dialog box displayed
40TipsTopics
- Tips to optimize disk space
- Tips to optimize performance
- Tips for building VMs
- Tips for deploying VMs
- Tips for troubleshooting
41Tips to optimize disk spaceOverview
- Best tip Understand disks
- Four relevant sizes
- a. In VM maximum disk capacity
- Not so relevant to optimizing disk space
- b. In VM used disk size
- Stored in vhd-file
- c. On host current size of vhd-file
- Contains b. contains deleted files
- d. On network size of zipped vhd-file
- Based on "patterns" in vhd-file
42Tips to optimize disk spacea. In VM maximum
disk capacity
- You cannot enlarge the maximum disk capacity of a
vhd-file - Just pick a large size up to 16 GB
- I always pick 4000 MB
43Tips to optimize disk spaceb. In VM used disk
size
- Delete files that are not used
- Files left over from installation
- Files only needed during installation
- Files that are always created anew at startup or
when needed - Files that are "cache" representations
- Files that are backup copies
- Files that are not applicable in the VM
44Tips to optimize disk spaceDelete files and
folders
- Not needed
- Empty dllcache folder (-400 MB)
- run sfc.exe /cachesize1
- restart guest (if needed)
- run sfc.exe /purgecache
- Empty ServicePackFiles\i386 folderand
NtServicePackUninstall folder - from windows (-280 / - 250 MB)
- Delete drivers.cab / SPx.cab
- from windows\Driver Cache\i386 (-60 MB)
45Tips to optimize disk spaceDelete files and
folders
- Left over from installation
- Virtual Machine additions
- del windows\installer\nnnnn.msi (-14 MB)
- Ensure you delete the correct msi-file
- Exchange 2003
- rd /s temp\SITnnn folder 3x (-53 MB)
- del c\Exchange Server Progress Log (-2 MB)
- NewSID 4.03
- rd /s windows\system32\config\Newsid Backup(-13
MB)
46Tips to optimize disk spaceDelete files and
folders
- Rebuilt when needed
- rd /s windows\system32\wbem\AutoRecover(-7 MB)
- del windows\inf\.pnf (-25 MB)del
windows\inf\infcache.1 (-1 MB) - del windows\prefetch\. (-5 MB)
- Note - why not to do this
- This may cost performance
- These files may be stored in each difference
disk, when deleted from parent disk
47Tips to optimize disk spacec. On host current
size of vhd-file
- Sparse-file
- Starts with size "0"
- Writes in 2 MB blocks
- Zero-filled files do not use space
- Examples
- res1.dat, res2.dat (10 MB each)
- pagefile.sys (hundreds MB)
- So don't worry about a large paging file
48Tips to optimize disk spaceWriting zero-filled
files
49Tips to optimize disk spaceHow to create an
empty paging file
- 1 Use Control Panel/System to configure no paging
file - 2 Restart the VM
- Existing pagefile.sys is deleted
- 3 Use Control Panel/System to configure a
"normal" paging file - New pagefile.sys is completely empty (almost)
- Tip develop VM with high RAM setting(512 MB)
to minimize pagefile.sys usage
50Tips to optimize disk spacec. On host current
size of vhd-file
- Deleted files do still use space
- To solve
- Create and delete a zero-filled file that
overwrites all the previously deleted space
("clean-up") - Move all the non-zero blocks ("compact")
- Can use the Precompact.iso tool
51Tips to optimize disk spaceSteps - clean up and
compact
- 1 Start up without Undo disks
- In VM - clean up
- 2 Defragment disk
- Possibly defragment twice
- 3 Zero-fill all unallocated sectors
- Use Precompact.iso
- With Virtual PC 2004 SP1
- 4 Shut down VM
52Tips to optimize disk spaceSteps - clean up and
compact
- On host - compact
- 5 Use Virtual Disk Wizard to compactthe disk
image file - Check disk size andNTFS compresseddisk size to
estimate"space" in vhd-file
53Tips to optimize disk spaced. On network size
of zipped vhd-file
- Delete files that are "compressed"
- intro.wmv, title.wma
- from windows\system32\oobe\images (-4 MB)
- msgr3en.dll, nls302en.lex
- from windows\srchasst (-8 MB)
- XP music.wma
- from Documents and Settings\All
Users\Documents\My Music (-4 MB) - XP windows\help\tour folder (-27 MB)
- Will give Windows File Protection (WFP) message
54Tips to optimize disk spaced. On network size
of zipped vhd-file
- Do not do
- zip files inside VM !
- This makes the vhd-file 25 smaller,but the
resulting zipped vhd-file (zip of zip) is much
larger
55Tips to optimize disk spaceGeneral tips
- Remember
- In a sparse vhd file, every "write" to a new
location costs 2 MB - Files with only zeros are "free"
- Tips
- Develop VM with lots of RAM to keeppagefile.sys
unused (is only zeros) - Do not use or disable "smart" disk activities
- Dynamic disks (Win2000)
- System Restore (Win XP)
- Shadow Copies (Win2003)
56Tips to optimize disk spaceExample - steps at
guest
- After installation OSSPs 1408 MB
- Example is Win2000 Server
- Empty dllcache folder -250 MB
- run sfc.exe /cachesize1
- restart guest (if needed)
- run sfc.exe /purgecache
- Empty ServicePackFiles folder -196 MB
- from windir
- Delete drivers.cab / SPx.cab -55 MB
- from windir\Driver Cache\i386
- Empty temp folder -14 MB
57Tips to optimize disk spaceExample - steps at
guest
- Turn off XP System Restore -150 MB
- Control Panel/System/System Restore
- Especially important to prevent disk growth later
(!) - In hidden, forbidden \System Volume Information
folder - Defragment disk (in guest) (prepare)
- Allows much better shrinking in next step
- Compact disk (on host) (reclaim)
- Use Virtual Disk Wizard
- Reclaims zero space - 10
- Subtotal (after guest steps) 473 MB
58Tips to optimize disk spaceExample - steps at
host
- Subtotal (after guest steps) 473 MB
- At host
- NTFS compress vhd file - 43
- No performance hit at guest measured
- Total (after host steps) 269 MB
- Original footprint was 1408 MB
59Tips to optimize disk spaceOffline storage of VM
disks
- Zip vhd file for storage - 60
- Subtotal (after guest steps) 473 MB
- Total (zip-file size) 185 MB
- On one CD-ROM
- Easily fits multiple zipped VMs
- Especially if delta VMs are used
60Tips to optimize performanceNumber 1 tip
- Number 1 tip Install Virtual Machine Additions
- Another number 1 tip
- Run on a fast host disk - greatest bottleneck
- Do not run from network
- or redirected My Documents
- And another number 1 tip
- Enable run at maximum speed
61Tips to optimize performanceOther tips on host
- Defragment host disk
- Assign lots of memory to VM
- On notebook NTFS compress disk files
- CPU is "faster" than disk access
- Exempt from anti-virus checking
- Virtual PC.exe or vhd (vhdd)/vud/vsv extensions
62Tips to optimize performanceWindows Server 2003
guests
- Set display hardware acceleration to Full !
- Default is lower setting
- Causes slow mouse and display
- At Control Panel/Display/Settings
tab/Advanced/Troubleshooting - Note Leave the Visual Effects enabled
- They hardly effect overall performance
63Tips to optimize performanceWindows Server 2003
guests
- Set DVD ATAPI device to PIO Only mode
- Initial DMA mode causes 10 second delay when
opening My Computer - Switches to PIO Only mode automatically after 6x
delay, but use of Undo disks may prevent this - See Microsoft KB 817472
- At Device Manager/IDE ATA-ATAPI
controllers/Secondary IDE Channel/Advanced
Settings/Device 0
64Tips for building VMsGeneral tips
- Always configure Virtual PC to run at maximum
speed - Install OS in 40 minutes, versus 8 hours
- Use bootable ISO CD-image to install OS
- 1 Start VM
- 2 Use Action/Pause to pause VM
- 3 Use CD/Capture ISO image to use ISO file
- 4 Use Action/Reset to boot from CD
- Always install Virtual Machine Additions after
installation of OS
65Tips for building VMsCustomize environment
- Add verbs to .vmc extension
- Edit - Notepad.exe "1"
- Register - Virtual PC.exe -registervm "1"
- Open (Virtual PC.exe -startvm "1") already
exists - Add shortcut
- Notepad.exe options.xml
66Tips for building VMsInstall sound in Win2003 VM
- Virtual PC Sound Blaster 16 is not supported by
Windows Server 2003 anymore - 1 Copy wdma_ctl.inf and ctlsb16.sys from Windows
XP to a folder - 2 In device manager,select Sound Blaster 16and
click Update Driver - 3 Browse to the folder,and install driver
67Tips for building VMsCopy files to VMs
- Several methods
- Use Shared Folders (drag folder to icon)
- Files at z\ in VM - I only use this
- Use drag-n-drop from host to VM
- Files at desktop or folder in VM
- Burn quick ISO image (drag iso-file to icon)
- Files at d\ (CD-ROM) in VM
- Use networking (drive mapping)
- Need network configuration
- Cannot use Local Only networking
68Tips for building VMsSecurity
- Use Local Only networking to avoid any contact
with outside network - Patch VMs as if they are real machines on the
network - ICF / Windows Firewall does not protect
- Use NAT to haveprotected access
69Tips for building VMsMultiple VMs - difference
disks
- Unique per VM
- Computer name rename computer
- Computer SID run Sysprep or SID changers
- I use Sysinternal's Newsid v4.03
- IP address manually or use DHCP
- MAC address automatically different
70Tips for building VMsMultiple VMs - undo disks
- Careful with product activation
- Disable computer domain password change
- At VM - DC
- or at VM - member computer
- Active Directory replication
- if multiple DCs and undoable,do not shut down
and start up only one - Restart VM is okay - does not "undo" changes
Key hklm\s\ccs\s\Netlogon\Parameters
RefusePasswordChange 1 (reg_dword) DC never
accepts pw change
Key hklm\s\ccs\s\Netlogon\Parameters
DisablePasswordChange 1 (reg_dword) Computer
never changes pw
71Tips for building VMsMultiple VMs - time sync
- VPC Additions syncs time with host
- Does NOT take the time zone in account
- Only syncs the "system tray" time
- Ensure that all VMs use the sametime zone in a
domain scenario
72Tips for building VMsMultiple VMs - avoid
confusion
- For lab
- Use background colors
- Use topology graphics
- Always use Undo-Always
73Tips for building VMsCleanup
- Do not use Start/Run, but use cmd.exe to start
other programs while building - Keeps Run dialog list empty
- Empty Recycle Bin
- May even remove from desktop
- Clean up Start Menu
- Disable screen saver
74Tips for deploying VMsInstalling VMs
- Installing Virtual PC interrupts network
connection to host - Unattended install possible (see online help)
- Register VMs by creating shortcuts to vmc-files
- In folderC\Documents and Settings\\Applica
tion Data\Microsoft\Virtual PC\Virtual Machines - For other user as well
- Shortcuts are case-sensitive (!)
- .vmc-extension has to be lowercase ?
- Note Options.xml file is atC\Documents and
Settings\\Application Data\Microsoft\Virtua
l PC\Options.xml
75Tips for deploying VMsConfigure VMs
- Options.xml
- "Hide" Virtual PC console by moving off-screen
- Closing Virtual PC console, closes all running
VMs - file.vmc (per VM)
- Disable VM window Close button
- Use Action/Close to close VM window instead
Options.xml /preferences/window/console/left_pos
ition 4000
Sydney.vmc /preferences/command_line/override/di
sable_close true
76Tips for deploying VMsHow to restrict use
- Restrict use for lab users
- Set VM BIOS password
- At startup, press Del to enter AMI BIOS
- Set permissions on files and folders
- Disable parts of user interface
Registry hklm\Software\Microsoft\Virtual
PC\5.0\Security\Locks 0x02B (dword)
77Tips for deploying VMsMultiple VMs - start up
- When using a script to start multiple VMs
- Use delays in between to avoid too much
concurrent host disk activity
78Useful links
- Drivers
- DOS network adapter driver (dc21x4.dos)
http//developer.intel.com/design/network
/drivers/sla_ndis2.htm - Tools
- Precompact.iso - zero fills unallocated
sectorshttp//go.microsoft.com/?linkid2615769(w
ith Virtual PC SP1) - Newsid.exe - assigns random SID to (delta)
VMhttp//www.sysinternals.com/ntw2k/source/newsid
.shtml