I have been using a swap file on a separate partition for almost a year now. I've actually tried a couple of the supplied implementations provided here at Mac OSX Hints. HOWEVER!! There is a bug in all the implementations I've tried, and I *believe* I've FINALLY found a fix! Note that I am dealing with a swap on a separate partition, not separate disk.
The Bug
If you ever force reboot (CTRL-CMD-POWER) OSX, your swap partition ends up mounted AFTER virtual memory starts. This means you now have "/Volumes/Swap" actually on your main partition running your virtual memory swap files, and a separate, useless partitition "/Volumes/Swap 1" just sitting there.
There is a "by-hand" way of fixing this, requiring some fudging and an additional reboot. But I've FINALLY found an automatic solution. Read the rest of the article for both the "by hand" and "automatic" solutions...
First, let me tell you the "by-hand" solution, in case you fall in the "faint of heart" or "just plain careful" category.
NOTE: In all examples I assume you've called your swap partitition Swap, for the swap device (obtained via "df") I use /dev/disk0s11. You will need to run df1 to find yours and replace my references with your actual device path.
Fix 1 (Easy)
It should not matter what method you used to create your swap partition, this should work on all of those provided. Quit all applications except the terminal. Now in the terminal, do your thing:
% ls /VolumesReboot your system via the Apple Menu. Quick!!!
Ganymede Swap Swap 1
% sudo rm -rf /Volumes/Swap
% sudo mv "/Volumes/Swap 1" /Volumes/Swap
% dfMy Swap partition is /dev/disk0s11. Whatever you get from df, use that in the next step.
/dev/disk0s10 55743576 25548296 30195280 45% /Volumes/Ganymede
/dev/disk0s11 6550752 176968 6373784 2% /Volumes/Swap
/dev/disk0s11 /Volumes/Swap hfs rw 1 2(3) You need to edit /etc/rc. Here is the original section on Swap (Virtual Memory):
...We simply want to add a few things to the above code segment, and also change the single line naming the swapdir:
ConsoleMessage "Starting virtual memory"
swapdir=/private/var/vm
# Make sure the swapfile exists
if [ ! -d ${swapdir} ]; then
ConsoleMessage "Creating default swap directory"
mount -uw /
mkdir -p -m 755 ${swapdir}
chown root:wheel ${swapdir}
else
rm -rf ${swapdir}/swap*
fi
...
...Note that everything below the new "swapdir=..." line is the original /etc/rc code section.
ConsoleMessage "Starting virtual memory"
# BEGIN CHANGE
#
# Make sure Swap is not mounted in case of hard reboot
# Then remove the directories if they exists
#
umount -v /Volumes/Swap*
if [ -d /Volumes/Swap ]; then
ConsoleMessage "*** DELETING extant Swap directory(s) ***"
mount -uw /
rm -rf /Volumes/Swap*
fi
#
# This fscks the disks and mounts them correctly
#
/sbin/autodiskmount
# HERE IS THE OTHER LINE TO CHANGE, so the swap file goes
# on your swap volume.
swapdir=/Volumes/Swap/private/var/vm
# END CHANGE
# Make sure the swapfile exists
if [ ! -d ${swapdir} ]; then
ConsoleMessage "Creating default swap directory"
mount -uw /
mkdir -p -m 755 ${swapdir}
chown root:wheel ${swapdir}
else
rm -rf ${swapdir}/swap*
fi
...
Mac OS X Hints
http://hints.macworld.com/article.php?story=20020603090352408