5. Tips, Tricks, and general questions.

Filed By: Robert Moir

5. Tips, Tricks, and general questions.

5.1. How do I share files between the guest and host systems?

Well if the guest system supports it, you can use the Virtual PC additions to enable VPC's easy file sharing. If VPC additions are not supported, or if you want to do a bit more than just share files with just the host, then  you can use the same methods that you would use between two physical networked machines «. For a Unix based operating system sharing with Windows machines this might include using a FTP server or setting up samba.

5.2. Can I overclock the Virtual PC's Processor?

In a word, No. The virtual PC uses the physical processor, it doesn't emulate it's own one. And even if it did, you wouldn't see a performance improvement from doing this.

5.3. Longhorn sucks on VPC 2004

The installation takes a very long time, yes. And the display will look terrible and the system will run extremely slowly until you install the VPC additions. Then it will get a lot better. Longhorn also does not currently ship with a driver for the soundcard that VPC 2004 emulates, but you can install the Windows XP driver. It's worth remembering that the current public build of Longhorn is pre-beta and as such is nothing like production quality code; it is going to run poorly no matter what you do with it, this isn't a VPC problem.

After Longhorn's install you must install the VPC additions and activate it in order to get anything like a remotely acceptable performance level.

5.4. What files are used by Virtual PC 2004 to store Virtual Machine details?

.vhd files are used to hold the hard disk images, and .vmc files are used to hold configuration information. .vmc files are XML files, and if you have a problem with a virtual machine configuration you may be able to open them with a decent text editor, preferably one that understands XML formatting for readability's sake, and edit the config files directly. This is obviously not a great idea in general but if you have to do it then you can. .vhd files are not editable in this way.

If you decide to edit the .vmc file in this way be sure to take a copy first before you dive in or you could end up making the problem worse, not better.

5.5. What is the support for USB devices like?

Virtual PC 2004 doesn't emulate a USB hub/controller so you cannot install USB devices directly into a Virtual PC«. It will work just fine with USB keyboard and mice installed on the host machine and you can access things like USB storage drives via the shared folders facility in VPC additions.

5.6. What are the different kinds of virtual disk all about?

Virtual disks are where Virtual PC guest computers store the contents of their "hard" disk. VPC 2004 supports four different types of virtual disk, and to get the best from your virtual PC it helps to have some understanding of the different types of disk and when you should choose one over another.

Dynamically Expanding disks are the most commonly used type of virtual disk. These are designed to grow as needed from a small initial size up to a maximum size that you set during drive creation. This is probably a good choice to select while setting up a virtual PC if you don't know what else to pick instead as it will only use the space it needs on your physical hard disk and will hopefully grow with your needs within the limits you set.

Fixed size disks are set at the maximum size you specify from the start, regardless of disk use requirements. I tend to find these perform slightly better in server situations as you don't waste resources on expanding the size of the virtual disk file all the time.

Differencing is an interesting idea. This allows you to create a base image (for example, a basic install of Windows 2000) and create several child disk images which record only the difference between themselves and the base image. This might be useful when you want to create several images of an operating system setup the same way each time with just a minor difference (such as web browser version or OS service pack installed) as it makes it easy to be sure each of the images are identical except for your intended differences and it may also conserve disk space.

If you use differencing, consider write protecting the base image as any changes to this will make the differenced drives based on it unusable, and you'll lose the information contained upon them.

Linked to a hard disk. This creates a virtual hard disk that links directly to a physical hard disk. There are certain restrictions on this option which are covered in the help, and I'm not going to talk about it in detail as its a potentially dangerous option and I believe everyone needs to read the related help files and make a choice on this one for themselves.

5.7. Can you create multiple virtual partitions in a guest OS?

Yes, each virtual disk works like a real one in that you can specify multiple partitions on the disk. You can also have up to three virtual disks.

5.8. Can you specify which file systems sit on these partitions?

Yes, while the host system really needs to be using NTFS for performance and security, the virtual disks will not know or care about this. If you want FAT for a Windows 9x system or dos, no problem. HPFS for OS2? Ok! NTFS? Well obviously ;-). NFS for FreeBSD... Bring it on!

5.9. How good is the virtual networking? Could you set up DFS, for example, on one VPC and access it from another?

Yes you can. In this respect, a network of virtual machines will work exactly the same as a network of physical machines.

5.10. Ok, but what about something like RIS. Can you set up RIS in one session and then pull a build from another session? And if you do, will your physical hard drive melt down while trying to keep up?

Yes, RIS will work just fine. Again, behaving as it would on a network of real machines. In fact, you could even have a RIS image used by your virtual machines which you store on a "physical" production RIS server if you wished.

One "gotcha" for RIS on a VPC network is the usual RIS problem with not playing nicely with multiple DHCP servers on a network. Remember that the virtual machines will be able to see your "real" network, including any DHCP servers on that. Also remember machines on your "Physical" network will also be able to see a DHCP server you setup on a virtual machine that you've configured to practice RIS on your virtual network. Nothing here of course you can't plan around but you do need to be aware of it. Preferably before your helpdesk staff visit your desk with a baseball bat to discuss the finer points of not putting rouge DHCP servers on a LAN.

Another "Gotcha" but a very minor one is that the emulated VPC network card does not support PXE booting. You'll need to generate a PXE boot floppy to use VPC clients as RIS clients.

As for performance, if you specify a fixed size rather than a dynamically expanding one for the target virtual disks, and put the source disk on a different physical disk/spindle from the targets then performance won't suck as much as you think.

5.11. How can I shrink the size of my virtual hard disk partitions?

[Answer by SJ with some edits suggested in the forums by Pachelbel - thanks to you both]

1. Backup any critical data in the guest OS.
2. Download Eraser, (http://www.tolvanen.com/eraser/) and install it in the guest OS. Alternative disk 'zeroing' software can also be used.
3. Defragment the guest OS hard drive.
4. Run Eraser in the guest OS.
5. Click Edit, then Preferences, then Erasing
6. Select Unused Disk Space
7. Select New
8. Enter the description Blank
9. Click Add
10. Create a 3-byte pattern of zeros
11. Click Save
12. Select Blank under Unused disk space
13. Click OK.
14. Click File, then New Task
15. Select Unused space on drive
16. Select Local Hard Drives
17. Click OK
18. Select Task, then Run on the previously created task
19. Wait for completion
20. Close the report
21. Exit Eraser and shutdown the guest PC.
22. Use Virtual Disk Wizard on the Host PC to reclaim lost space. Click File, then Virtual Disk Wizard.
23. Click Next to start the wizard.
24. Select Examine or modify existing disk and click Next.
25. Click Browse to locate the disk image, double-click the image file and click Next to continue.
26. Select Compact the Disk image and click Next.
27. Virtual PC allows the use of a secondary file to compact the disk. It's a good idea to have the image file be compacted to a new file and then verified to prevent data loss or corruption of the original image file. Select New File, browse or enter a new location, click Next to continue.
28. Click Finish to start the process.
When finished, click Close.

5.11.b. That seems like a lot of work just to shrink a hard drive. Haven't you got anything easier?

[Answer by most of the regulars in 'Microsoft.Public.VirtualPC']

Fair point. Another method that can work is to use Ghost or a similar product inside your guest machine to copy your hard drive image to a new virtual hard drive, and then mount that as your new main hard drive for that virtual machine.

5.11.c. Is that really the best you have? Surely Microsoft don't expect us to do all that?

[Pachelbel from the forums suggested a few edits to make this answer even better - thank you!]

With the introduction of Virtual PC 2004 Service Pack 1, Microsoft have introduced a "pre-compactor" tool which runs on Windows guests and carries out the zeroing out of unused sectors for you, making the process much simpler.

Steps 1 through 6 are to be completed inside the guest machine. Steps 7 to 14. are to be completed on the host machine, via the virtual PC console. Take a backup of the guest machine BEFORE starting any work of this kind!

  1. Log on to the Guest machine session you wish to compact and run a defrag before you start.
  2. Load the Pre-compactor
    Go to CD Menu, then Capture ISO Image.
    Browse to the Virtual Disk Pre-compactor CD image 'Virtual Disk Precompactor.iso'. (The default location is C:\program files\Microsoft Virtual PC\Virtual Machine Additions). Select it, Click OPEN.
  3. If Autoplay is enabled in the guest, the pre-compactor will autorun.
    (If Autorun isn't enabled, browse to the CD in the guest and double-click 'precompact.exe to run it)
  4. A dialogue will appear stating "Would you like to prepare the Virtual hard disk(s) for compaction?" - answer YES.
  5. Wait for the pre-compactor to do its thing in the Guest.
  6. When the pre-compactor completes it will tell you to shut down the virtual machine and use the virtual disk wizard to complete the disk compacting. Follow its advice by shutting down the guest machine completely.
  7. From the File menu on the virtual pc console select 'Virtual Disk Wizard'
  8. Click NEXT at the Wizard's welcome screen.
  9. Select 'Edit an existing virtual disk', then click NEXT.
  10. Browse to find the virtual hard disk (.vhd file) you pre-compacted in steps 1-6. Select it and click OPEN.
  11. Click NEXT
  12. Select 'Compact it' under the list of options for the virtual hard disk. Then click NEXT.
  13. You can either replace the existing file or create a new .vhd file. Up to you. Make your choice, specifying a new name & location if you want a new .vhd file. Then click NEXT.
  14. You should be at the final screen in the wizard. Click BACK to go back and review your selections or Finish to start compacting your virtual hard disk.

5.12. How can I create a .vhd file from a disk drive (regardless of what OS is already on it?) For instance in Linux I might create an image of my drive by doing something like: dd of=/tmp/drive.img if=/dev/hda which would copy all partitions into an image file, and I could mount that file via a loopback mount just like a real drive.

If you want to create an image of another virtual machine, the simplest way to do it is to copy the vhd to another location, and use the virtual machine wizard to create a new virtual machine and tell it you have an image you'd like to use already, when it asks about drives.

But I think you are talking about imaging "real" computers and using the images in a virtual machine. I don't know what the internal format of a vhd file looks like, but I believe its a proprietary image format developed by Connectix back in the day and no doubt extended by MS a little for this release. I don't think it will work directly with any other file imaging system I'm afraid, at least not without a bit of reverse engineering on the part of someone considerably smarter than me.

As for the XML file, this describes the settings of a virtual machine, e.g. allocated memory, hardware, and suchlike, there is nothing critical about it when moving a virtual PC image around, this is the file thats created by the new virtual machine wizard to describe the settings you chose throughout the wizard, and a couple of other baseline bits and pieces.

The only way I know of doing an image is with programs like Ghost and those others that work the same way. (when I say ghost below, I'm referring to any other program that works the same way as well.)

1. make your "Ghost" image of a disk out to CD as normal.
2. create a new virtual machine, boot from the ghost floppy or CD or whatever.
3. Restore the ghost image from the CD.
4. Resolve hardware issues; remember you've gone from one set of hardware on your real machine to a different set of hardware on the emulaled virtual machine.

Not very elegant but it works.

Jim Guyton has also added some notes to the forum on creating an image directly from a disk from within a unix environment. His notes are based on using Panther (aka Mac OS X 10.3) but as well as being useful to anyone running VPC in that environment, they may also be a good starting point for anyone wanting to do something similar in other unix-like environments.

[Answer by Jim Guyton]

I just did this ... what seems to work for me (pc disk is 'rdisk0', be careful of course):

1) create an empty 'fixed sized' virtual pc disk that's *bigger* than you need ('foo')
2) fill it with (for example) 'dd if=/dev/rdisk0 of=foo/BaseDrive.vhd conv=notrunc'
3) use it in virtual pc
4) restore to disk with 'dd if=foo/BaseDrive.vhd of=/dev/rdisk0'

You can be a bit more careful by using 'bs' and 'count' appropriately in the dd commands or just let it error out when it hits the end of your actual disk.

The above is obvious if you create an empty (unformated) fixed size disk image and then use 'hexdump -C' on what's been created ... you'll find a full disk image of zeros followed by a vpc control block at the end.

Worked for me, your milage may vary ...

5.13. I'm having a problem with networking several Virtual Machines together. They work individually talking to the host, but as soon as I start more than one up, I have networking problems.

This can often be caused by problems with the MAC address used in the .vmc file that holds each virtual machine's properties. If you attempt to duplicate virtual machines by copying the .vhd AND .vmc files then you will have this problem.

To avoid the problem, simply copy the .vhd file to create multiple systems, and create a new .vmc file for each instance by using the "New Virtual Machine" wizard and telling it you have an already existing .vhd file.

If you already have the problem and don't wish to re-create all your virtual machine settings, you can edit the .vmc file with a text editor and either edit the mac addresses to be unique on each virtual machine, or you can delete the mac address and a new one will hopefully be created when you next run that virtual machine.

[Answer taken from contributions from Steve Jain, epayne, sstrange]

... more to come soon.

Top