Move The OS X Swapfile On Intel-Powered Macs
There’s been a lot of discussion over the years about the need for a separate swap partition or disk on OS X machines. I don’t have much to add to the debate, only to say that, as long as I can remember, minimizing fragmentation on hard disks has been one simple way of improving and maintaining system performance. As I mentioned in my article on FileVault, fragmentation on OS X disks is increased by the presence of large files, and therefore, my machines keep swapfiles and the sleepimage on a separate partition.
Recently, I was forced to upgrade my PowerBook, and when my MacBook arrived, I discovered that my preferred method of moving the swapfile offered by Professor Dave Bayer no longer worked. The culprit: the new GUID partition table. Prof. Bayer’s method relies on the commandline tool “pdisk” to handle and distinguish partitions. I modified his script to use “gpt” instead to handle the GUID partitioned MacBook.
I offer my modified version of his script to those adventurous folks who want to risk installing it, but I can not stress enough the fact that using this can cause inextricable damage to an OS X installation, and should only be attempted by people who have made complete, verified backups of their installations and are experts with the inner workings of the OS X operating system. Though this modified script has been tested quite a bit, I have only one machine on which to test it, and therefore can _not_ make _any_ guarantees of it. Use it at your own risk. I bear no liability should you mess up your machine.
– This script is only compatible with Intel-based Macs
– This script has only been tested under OS X 10.4.9. Compatibility with other versions is unknown.
I ask that if you have success or failure using the modified script that you please comment here so that I can learn with which systems it is compatible and can correct any remaining issues.
Please see the superb documentation Prof. Bayer has provided on his site for further information about the original script.