Parallels Performance Tip #3: Don't use a dedicated Mac OS X swap partition

Sorry for the long gap between tips. Holidays, work, etc.. have kept me busy.

This is the thrid of several tips I want to write up with regards to squeezing every last bit of performance out of
Parallels Desktop for the Mac. All information below is based on the current beta of Parallels Desktop for Mac, RC2

In my last tip, Parallels Performance Tip #2, I recommended moving your windows vm swap file to a dedicated swap partition within your VM. To understand why this provides speed improvements, think of your desk as a hard drive. Now, imagine you have a cluttered pile of papers scattered all over your desk. Those are all of the files on your hard drive. Now, imagine you have an sectioned off piece of your desk that has your most important file. You know where that section is. You don’t have to search through your entire desk to find it. That’s your swap file. By sectioning off a specific piece of your desk for that file, retrieving and using that file is faster than having to search through your entire desk.

That, in a nutshell, is the benefit of a dedicated partition for your swap file. By moving your swap file to a dedicated partition and away from your other, typically fragmented, files, you’re telling the OS exactly where to find the file. It doesn’t have to go searching through your entire HD to find it. In most circumstances, this provides better swap performance than just having your swap file lying around your hard drive.

However, i said in most cases. For typical day to day OS usage, creating this dedicated swap partition is great. At most you’ll need a 2 GB partition. On the other hand, when you’re working with very large files, you’ll quickly find out that 2GB will not be enough.

Which brings us to what this tip has to do with Parallels: Do not use a dedicated Mac OS X swap partition unless it’s sizable. By sizable, I mean at least .5-1x the size of your VM. Parallels is a memory hog, obviously. Remember, Parallels runs inside Mac OS X, which means the program itself will use Mac OS X’s virtual memory. So, when you load up a 30GB virtual machine, if Mac OS X doesn’t have enough virtual memory to handle it, you’ll be sorry. Performance of both OS X and Parallels will degrade to the point of being unusable. Unless you have VERY small vm, you’re better off sticking with the default virtual memory location of OS X.

However, for those brave souls who want to try, creating a dedicated OS X swap partition is fairly easy. Note: This will require messing with a startup script. Be careful, never delete anything, and always backup your originals.

1. If you have a desktop with more than one physical hard drive, just repartition one of your physical hard drives and skip to step 7. For laptop users and desktop users with only one physical hard drive, the steps are a little more time consuming. First, you’ll need a external firewire 400 or USB 2.0 hard drive.

2. Download Carbon Copy Cloner & install it. You’ll then need to clone your internal hard drive, as such:

Picture 1-11

The most important step is to make sure that the resulting clone it bootable. You do this be clicking on ‘Preferences’, and selecting the check box that says ‘Make bootable’, under the ‘Target Disk Options’ group:

Picture 2-3

3. Once the clone is complete, you’ll need to reboot your laptop. While your computer is restarting, hold down the ‘Alt-Option’ key to make your Mac give you the option of which hard drive to boot from. If you don’t see your external hard drive, verify the options you selected in step 2. Select your external HD, and hit the little arrow that pops up to continue to boot. Once OS X has started up, you’ll be able to verify that OS X booted from your external drive because a) your boot time will be slow, even for a USB 2.0 hard drive and b) your external drive will be the first volume mounted on your desktop. Typically, “Macintosh HD” is the first volume mounted.

4. Once OS X loads, you’re ready to partition your hard drive.


Ok, ready? Load up Disk Utility. Select your internal hard drive. Under Volume Scheme, select 2 Partitions. You’ll be able to select the size, name, and file system format for each partition. You should probably keep the name “Macintosh HD” as your main partition’s name. For your swap Partition, I usually pick “MacSwap”, but then again, I’m strange. Click the “Partition” button.

5. Once the partitioning is complete, it’s time to load up Carbon Copy Cloner again and copy our data back to our internal hard drive. Select source and target accordingly. Also, make sure to select the ‘Mark target disk bootable” option, as shown in step 2.

6. Once cloning is complete, reboot and let your mac load up normally.

7. Now, the way to change the location of where OS X puts your swap file is easy. Simply open up Terminal and load up the file /etc/rc in your favorite text editor. Note, you’ll have to use the sudo command, since rc is a protected system file. For example, if I wanted to load up the file with vi, I would do this:

cd /etc

sudo vi rc

Then type in my admin password. Once rc is opened, search for the word ‘swapdir’: You should see a line that says “swapdir=/private/var/vm”. Make a copy of that line, then put a # in front of the original to comment it out. Now, in the copy, change the “/private/var” part to “/Volumes/MacSwap”, substituting MacSwap for whatever you named your swap partition in Step 4 above. Now, save your changes.

8. Reboot. Once your computer comes back up, open up the /Volumes/MacSwap/vm directory, and you should see one or more swapfiles.

That’s it, you’re done. If you ever want to go back to your original setup, simply work the above steps in reverse.

Now, I know there are non-destructive ways to resize OS X partitions. However, they are fairly new and I haven’t tried them yet. Besides, if you’re resizing your partitions, you’re going to be creating backups anyway. Why not follow the steps above and not run the risk of jacking something up?


Related Posts:

* Parallels Performance Tip #1: Don’t use a External USB HD to hold your VM

* Parallels Performance Tip #2: Top 5 Ways to Optimize Windows XP