Successfully reported this slideshow.

Intrack14dec tips tricks_clean


Published on

Published in: Education, Technology
  • Be the first to comment

  • Be the first to like this

Intrack14dec tips tricks_clean

  1. 1. WIN388Using Virtual PC 2004:Tips and TricksRonald BeekelaarBeekelaar Consultancy
  2. 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:
  3. 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. 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. 5. AgendaPresentation disclaimer Disclaimer Many tips are undocumented or unsupported Many examples are unsupported by 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. 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 and a list of hardware devices Terms used: vm = virtual pc = image
  7. 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 <hardware> <memory> <ram_size type="integer">256</ram_size> </memory> ... <pci_bus> <ethernet_adapter> <controller_count type="integer">2</controller_count> </ethernet_adapter> </pci_bus> </hardware> Guest OS doesnt "know" Only need to install VM Additions in guest
  8. 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. 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. 10. How does Virtual PC workArchitecture config in vmc-file Sound Diskette CPU Mem Disk CD/DVD Network Ports USB Software Virtual PC VMM VPC host VPC host host host driver driver driver driver Hardware .vfd CPU0 CPU1 Disk .iso file
  11. 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. 12. How does Virtual PC work"Back doors" VM Additions D:data Z: Software Virtual PC Virtual pc.exe Hardware Time Clip %temp% Drag sync board & drop
  13. 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 at Action/Properties/Advanced
  14. 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. 15. NetworkingOverview Uses a virtual switch and virtual network adapters (max 4) and virtual "virtual machines" Three configurations (per adapter) Shared Networking (NAT) Connect to host adapter Local only
  16. 16. Networking Three configurations Shared Connect to Local networking adapter only .1-.253 (NAT) DHCP/NAT Other VM Other VM local local .254 Virtual PC.exe host external> ipconfig /all C:> ipconfig /all C:> ipconfig /allIP Configuration IP Configuration IP Configuration MAC Address : 00-03-FF-... MAC Address : 00-03-FF-... MAC Address : 00-03-FF-... IP Address : IP Address : IP Address : Subnet Mask : Subnet Mask : Subnet Mask : Gateway : Gateway : Gateway : - DHCP Server : DHCP Server : DHCP Server : - DNS Server : DNS Server : DNS Server : - Lease : 17 yr, 4 day Lease : 7 days Lease : -
  17. 17. NetworkingAdditional information Shared networking (NAT) DNS address is copied from host computer Default gateway is 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. 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. 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. 20. Virtual DisksFile locations .vhd disk file In folder you specify in settings .vhdd disk file In folder you specify in settings .vud disk file In vmc-file folder .vsv disk file In vmc-file folder
  21. 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. 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. 23. Disks Three disk modes Start up Running Close Running VMPersistent host 1-Save state 2-Turn off and save/CommitUndo-Ask 2-Turn off and save Start up 3-Turn off and deleteUndo-Always = .vhd file = .vsv file = .vud file
  24. 24. DisksCommit hard drive changes Commit means: Merge vuh undo file with vhd file
  25. 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 Running Saved Restore (= Start up) Memory contents Window settings
  26. 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. 27. DisksHow differencing disks works Virtual PC Read Write Create Delete File-d.doc 3 1 2 3 4 Grow File-c.doc 1 2 3 4 1 2 3 4 1 2 3 4 Read only File-a.doc File-b.doc File-d.doc
  28. 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. 29. The case for differencing disksOverview Differencing disks have many purposes 1 Smaller size on host 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. 30. The case for differencing disks1- Smaller size on host Use less space on host Miami.vhdd: 410 MB Works well with NTFS compression: 26 MB Works excellent with ZIP: 12 MB
  31. 31. The case for differencing disks2 - 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 concentration than using Undo-Ask
  32. 32. The case for differencing disks3 - 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 download that use the master VMs 3 Relink the delta VMs to the parent (master) VM
  33. 33. The case for differencing disks4 - Sequential delta VMs Fool proof demo or lab modules Use a separate (growing) delta VM to start each 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. 34. The case for differencing disks4 - Sequential delta VMs Lab module 1 Steps Lab module 2a 1 Create difference disk Lab module 2b Lab module 3 2 Start up on VM Lab module 4 3 Do next demo or lab Lab module 5 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 from any module, or completed sequentially
  35. 35. Tech-Ed 2004 AmsterdamSelf-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. 36. Tech-Ed 2004 AmsterdamSelf-paced hands-on labs - Lab Menu Lab Menu List each lab on 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. 37. Repeatable RestoreGeneral 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. 38. Repeatable RestoreSetup 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. 39. Repeatable RestoreUse 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. 40. TipsTopics Tips to optimize disk space Tips to optimize performance Tips for building VMs Tips for deploying VMs Tips for troubleshooting
  41. 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. 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. 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. 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 ServicePackFilesi386 folder and $NtServicePackUninstall$ folder from windows (-280 / - 250 MB) Delete / from windowsDriver Cachei386 (-60 MB)
  45. 45. Tips to optimize disk spaceDelete files and folders Left over from installation Virtual Machine additions del windowsinstallernnnnn.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 windowssystem32configNewsid Backup (-13 MB)
  46. 46. Tips to optimize disk spaceDelete files and folders Rebuilt when needed rd /s windowssystem32wbemAutoRecover (-7 MB) del windowsinf*.pnf (-25 MB) del windowsinfinfcache.1 (-1 MB) del windowsprefetch*.* (-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. 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 dont worry about a large paging file
  48. 48. Tips to optimize disk spaceWriting zero-filled files Virtual PC Write Write Read 000 000 000 000 000 000 000 000 000 000 1 2 3 4 1 2 3 4 5 000 000 000 1112 000 000 000 000 000 ... 000 000 1 2 3 4 1 4 File-a.doc Pagefile.sys
  49. 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. 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. 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. 52. Tips to optimize disk spaceSteps - clean up and compact On host - compact: 5 Use Virtual Disk Wizard to compact the disk image file Check disk size and NTFS compressed disk size to estimate "space" in vhd-file
  53. 53. Tips to optimize disk spaced. On network: size of zipped vhd-file Delete files that are "compressed" intro.wmv, title.wma from windowssystem32oobeimages (-4 MB) msgr3en.dll, nls302en.lex from windowssrchasst (-8 MB) XP: music.wma from Documents and SettingsAll Users DocumentsMy Music (-4 MB) XP: windowshelptour folder (-27 MB) Will give Windows File Protection (WFP) message
  54. 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. 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 keep pagefile.sys unused (is only zeros) Do not use or disable "smart" disk activities Dynamic disks (Win2000+) System Restore (Win XP) Shadow Copies (Win2003)
  56. 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 / -55 MB from %windir%Driver Cachei386 Empty %temp% folder -14 MB
  57. 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. 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. 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. 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. 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. 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. 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. 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. 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. 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 16 and click Update Driver 3 Browse to the folder, and install driver
  67. 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. 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 have Connect to adapter protected access Other VM local host ICF external
  69. 69. Tips for building VMsMultiple VMs - difference disks Unique per VM Computer name : rename computer Computer SID : run Sysprep or SID changers I use Sysinternals Newsid v4.03 IP address : manually or use DHCP MAC address : automatically different
  70. 70. Tips for building VMsMultiple VMs - undo disks Careful with product activation Disable computer domain password change At VM - DC # Key: hklmsccssNetlogonParameters RefusePasswordChange = 1 (reg_dword) # DC never accepts pw change or at VM - member computer # Key: hklmsccssNetlogonParameters DisablePasswordChange = 1 (reg_dword) # Computer never changes pw 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. 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 same time zone in a domain scenario
  72. 72. Tips for building VMsMultiple VMs - avoid confusion For lab Use background colors Use topology graphics Always use Undo-Always
  73. 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. 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 folder C:Documents and Settings<user>Application Data MicrosoftVirtual PCVirtual Machines For other user as well Shortcuts are case-sensitive (!) .vmc-extension has to be lowercase ? Note: Options.xml file is at C:Documents and Settings<user>Application Data MicrosoftVirtual PCOptions.xml
  75. 75. Tips for deploying VMsConfigure VMs Options.xml "Hide" Virtual PC console by moving off-screen # Options.xml /preferences/window/console/left_position = 4000 Closing Virtual PC console, closes all running VMs file.vmc (per VM) Disable VM window Close button # Sydney.vmc /preferences/command_line/override/disable_close = true Use Action/Close to close VM window instead
  76. 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 # Registry hklmSoftwareMicrosoftVirtual PC5.0SecurityLocks = 0x02B (dword)
  77. 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 Host VM VM Host VM VM
  78. 78. Useful links Drivers DOS network adapter driver (dc21x4.dos) /drivers/sla_ndis2.htm Tools Precompact.iso - zero fills unallocated sectors (with Virtual PC SP1) Newsid.exe - assigns random SID to (delta) VM