NOTE: See (also) a corrected/improved answer in the question itself.
Following solution worked for me:
Open a terminal and backup com.apple.dynamic_pager.plist which you're going to change in a second:
$ cd /System/Library/LaunchDaemons
$ sudo cp com.apple.dynamic_pager.plist{,_bak}
convert binary plist to xml:
$ sudo plutil -convert xml1 com.apple.dynamic_pager.plist
and open it with your favorite text editor
$ sudo vim com.apple.dynamic_pager.plist
it'll look something like this:
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3 <plist version="1.0">
4 <dict>
5 <key>EnableTransactions</key>
6 <true/>
7 <key>HopefullyExitsLast</key>
8 <true/>
9 <key>Label</key>
10 <string>com.apple.dynamic_pager</string>
11 <key>OnDemand</key>
12 <false/>
13 <key>ProgramArguments</key>
14 <array>
15 <string>/sbin/dynamic_pager</string>
16 <string>-F</string>
17 <string>/private/var/vm/swapfile</string>
18 </array>
19 </dict>
20 </plist>
In line 17 modify /private/var/vm/swapfile (e.g. /Volumes/partition2/swapfile), save and close your editor (":x" will do both in vim).
convert the plist file back to binary:
$ sudo plutil -convert binary1 com.apple.dynamic_pager.plist
After rebooting your Mac you should find the swapfiles in the directory you specified.
If you run into any problems you can restore the backup you created in the first step with:
$ cd /System/Library/LaunchDaemons
$ sudo cp com.apple.dynamic_pager.plist{_bak,}
Best Answer
Copy your home directory to the new location/partition. The go in the
System Preferences
->Accounts
, right-click on your user icon and selectAdvanced Options
. There you can set theHome Directory
to the new path.