790 likes | 844 Views
About the speaker. Consultant and trainer from The NetherlandsMVP - Virtual PCUsing Microsoft Virtual PC 2004For demos, presentations and coursewareFor hands-on labs at conferencesSeveral security labs / XP SP2 labsFor classes, studying and testingContact:E-mail: ronald@beekelaar.com. Agenda Topics.
E N D
1. WIN388Using Virtual PC 2004:Tips and Tricks Ronald BeekelaarBeekelaar Consultancy
2. About 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@beekelaar.com
3. AgendaTopics 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
4. AgendaNot so topics Not in presentation
Microsoft Virtual Server 2005
Comparison with other products
Such as: VMware Workstation
Upgrading from Virtual PC 5.2
5. AgendaPresentation 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
6. About 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 used:vm = virtual pc = image
7. How 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
8. How 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
9. How 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
10. How does Virtual PC work Architecture
11. How 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
12. How does Virtual PC work "Back doors"
13. How 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
14. How does Virtual PC workSpecial keys Host-key + any
Default host-key is <right>Alt
<right>Alt-Del = Send Ctrl-Alt-Del
<right>Alt-Enter = Full screen
<right>Alt-? ? = Prev / next VM
<right>Alt key = Uncapture mouse
Tip: After using <right>Alt-Enter (full-screen) multiple times, the keyboard may no longer respond
To resolve: press Ctrl key twice
15. NetworkingOverview 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
16. NetworkingThree configurations
17. NetworkingAdditional 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
18. DisksOverview 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
19. Virtual 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
20. Virtual 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
21. DisksTopics 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
22. DisksUndo 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
23. DisksThree disk modes
24. DisksCommit hard drive changes
Commit means:Merge vuh undo file with vhd file
25. DisksSaved 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
26. DisksDifferencing 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
27. DisksHow differencing disks works
28. Differencing 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)
29. The 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
30. The 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
31. The 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
32. The 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
33. The 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
34. The 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
35. Tech-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
36. Tech-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
37. Repeatable 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
38. Repeatable 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
39. Repeatable 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
40. TipsTopics Tips to optimize disk space
Tips to optimize performance
Tips for building VMs
Tips for deploying VMs
Tips for troubleshooting
41. Tips 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
42. Tips 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
43. Tips 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
44. Tips to optimize disk spaceDelete files and folders Not needed
Empty dllcache folder (-400 MB)
run sfc.exe /cachesize=1
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)
45. Tips 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)
46. Tips 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
47. Tips 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
48. Tips to optimize disk spaceWriting zero-filled files
49. Tips 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
50. Tips 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
51. Tips 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
52. Tips 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
53. Tips 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
54. Tips 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
55. Tips 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)
56. Tips to optimize disk spaceExample - steps at guest After installation OS+SPs 1408 MB
Example is Win2000 Server
Empty dllcache folder -250 MB
run sfc.exe /cachesize=1
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
57. Tips 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
58. Tips 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
59. Tips 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
60. Tips 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
61. Tips 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
62. Tips 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
63. Tips 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
64. Tips 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
65. Tips 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
66. Tips 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
67. Tips 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
68. Tips 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
69. Tips 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
70. Tips 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
71. Tips 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
72. Tips for building VMsMultiple VMs - avoid confusion For lab
Use background colors
Use topology graphics
Always use Undo-Always
73. Tips 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
74. Tips 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\<user>\Application 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\<user>\Application Data\Microsoft\Virtual PC\Options.xml
75. Tips 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
76. Tips 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
77. Tips 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
78. Useful 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/?linkid=2615769(with Virtual PC SP1)
Newsid.exe - assigns random SID to (delta) VMhttp://www.sysinternals.com/ntw2k/source/newsid.shtml