10.5: Move swap files to another partition under 10.5

Dec 05, '07 07:30:02AM

Contributed by: adrinux

Here's a simple way to move your swap partition under Leopard that appears to work for both Intel and PowerPC based Macs. Edit the file com.apple.dynamic_pager.plist, located in /System/Library/LaunchDaemons. Replace the /var/vm path with the full path to your swap partition. In my case, the entire plist ends up looking like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
                <key>Label</key>
                <string>com.apple.dynamic_pager</string>
                <key>ProgramArguments</key>
                <array>
                     <string>/sbin/dynamic_pager</string>
                     <string>-F</string>
                     <string>/Volumes/Swap/.vm/swapfile</string>
                </array>
                <key>OnDemand</key>
                <false/>
</dict>
</plist>
Save and reboot, then check your new swap location is being used with this command:
ps -wax | grep dynamic_pager -m1
Finally, you probably want to clear out any old swapfiles from /var/vm:
sudo rm -rf /var/vm/swapfile*
As mentioned this works on PowerPC and Intel Macs, and it also works after reboot or shutdown/restart. However, if your swap partition can't be found, there is no fall back -- Leopard will start up without swap, and may get unstable if you continue to use it in that state. There's a more verbose version of this tip in this forum thread, with some extra discussion regarding the sizing of the swap files.

Comments (7)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20071121070305908