参考链接:http://superuser.com/questions/28414/moving-the-swapfiles-to-a-dedicated-partition-in-snow-leopard

这里注意的是,新的swap文件的路径必须存在。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
# backup the file
$ cd /System/Library/LaunchDaemons
$ sudo cp com.apple.dynamic_pager.plist{,_bak}

# convert the file to xml
$ sudo plutil -convert xml1 com.apple.dynamic_pager.plist

# modify the file
$ sudo vim com.apple.dynamic_pager.plist

<key>ProgramArguments</key>
<array>
    <string>/bin/bash</string>
    <string>-c</string>
    <string>/bin/wait4path /Volumes/Swap/ &amp;&amp;
/sbin/dynamic_pager -F /Volumes/Swap/.vm/swapfile</string>
</array> # replace /Volumes/Swap/.vm/swapfile as your path

# convert the file to binary
$ sudo plutil -convert binary1 com.apple.dynamic_pager.plist

重启就可以了。