By default, Mac OS X uses a swap file (for virtual memory) which is installed on the same drive as your operating system. For best performance, the swap file would ideally be located on the fastest drive in your machine, which may or may not be the same disk as your OS. Unfortunately, there's no built-in GUI for changing a swap drive location.
A few days ago, there was a help request on swapping on another hard drive and subsequent comments that figured out how this could be done. I asked if patpro, one of the users involved, would mind writing a step-by-step instruction set on how to transfer swap. Read the rest of this article to see what he had to say ... well worth the time if you have a spare, fast hard drive in your system!
patpro writes: "Well, I'd be glad to help you with that, but in fact, Sven had a lot to do with my success as well:)). He pointed out some important aspects of the boot process (mount especially)."
With that said, here are patpro and Sven's instructions on relocating your swap file.
NOTE: This hint now reflects the additional functionality submitted by John in the comments
A few days ago, there was a help request on swapping on another hard drive and subsequent comments that figured out how this could be done. I asked if patpro, one of the users involved, would mind writing a step-by-step instruction set on how to transfer swap. Read the rest of this article to see what he had to say ... well worth the time if you have a spare, fast hard drive in your system!
patpro writes: "Well, I'd be glad to help you with that, but in fact, Sven had a lot to do with my success as well:)). He pointed out some important aspects of the boot process (mount especially)."
With that said, here are patpro and Sven's instructions on relocating your swap file.
NOTE: This hint now reflects the additional functionality submitted by John in the comments
- Launch a terminal session.
- Backup the rc file into the current directory, which should be ~/ for the current user:
cp /etc/rc .
- Print a partition map, which shows every device mounted on your system, by using df:
df
- In the df output, choose your favorite disk/partition and remember its reference. Each row will look something like this:
/dev/disk0s9 3134688 1970568 1164120 62% /apps
There will be one line for each volume in your system. - During the boot process, mounting a disk other than local file system (MacOS X system drive) appears to occur after swap initialization. So now we're going to edit /ect/rc so that our preferred swap disk is mounted before swap initializes. To do this, we need to become root, transfer to the directory, and edit the file:
su root
cd /etc/
pico rc - In the rc file, replace this
swapdir=/private/var/vm
with this
# 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*
fiswapdir=/disk-name/path_to_swap_directory
BE CAREFUL: If your preferred disk is NOT hfs you MUST provide the mount command with it's correct file format (mount -t ufs, for example). So the 'mount' line must follow this framework:
# Make sure the swapfile exists,
# first check existence
# if not first make sure disk is mounted
if [ ! -d ${swapdir} ]; then
ConsoleMessage "mounting directories"
mount -t hfs /dev/disk**** /disk-name
mount -uw /
fi
# Make sure the swapfile exists,
# if not, create directory since disk should be mounted
if [ ! -d ${swapdir} ]; then
ConsoleMessage "Creating default swap directory"
mkdir -p -m 755 ${swapdir}
chown root:wheel ${swapdir}
else
rm -rf ${swapdir}/swap*
fimount -t (disk file format) /dev/(disk-reference) /(disk-name)
- Save the file and quit with CTRL-X, Y, and ENTER.
- Reboot
•
[56,724 views]

