Saturday, March 1, 2014

Disable or Not Swap on Your M(H)ac(k)intosh

Why would you want to do that?! Well, simple, today, RAM does not cost a thing, 8GB or 16GB are plenty for most applications, and there still is the option to go to 32GB. Virtual memory, it seems, is not that important any longer.

Most of the recent Macintosh, or Hackintoshs respectively, have the operating system on an SSD, for quick boot-up times. I believe real Macintosh computers employ SSDs only nowadays, but I am not sure...
We all know, that the easiest way to wear down your SSD is, to use it as a swap (virtual memory) device.

Given that your computer is supplied with sufficient RAM for your tasks, you may want to try this:
and disable swap all together.
Presently, with my most recent build (16GB), I am actually trying this.

Hackintosh computers usually employ a regular HDD for mass-storage (or scratch), next to the SSD boot drive. For those boxes, one may consider using the magnetic HDD for swapping. This is a bit more complicated, but still doable:
  • boot your Hackintosh into Single user mode using "-s" (no quotation marks)
  • mount your HDD, using something like (depending on your setup, disk1s2 is my HDD, mounted on the mount point /Volumes/HOME/):
    mount -t hfs /dev/disk1s2 /Volumes/HOME
  • now lets make a hidden "vm"-directory:
    mkdir /Volumes/HOME/.vm
  • link the new "vm" directory to the expected place:
    ln -s /var/vm /Volumes/HOME/.vm
    you may also link "/private" if you want:
    ln -s /private/var/vm /Volumes/HOME/.vm
  • for good measures it created empty files (probably not necessary):
    touch /Volumes/HOME/.vm/swapfile0
    touch /Volumes/HOME/.vm/swapfile1since those were the files found first...
  • to enable swap, I entered:
    launchctl load -F /System/Library/LaunchDeamons/
When you're done with that, you just want to make sure all data are written using the command sync. Now, just type reboot.

A from now, my system uses swap (virtual memory) on the magnetic disk, leaving the SSD alone.

Of course, running swap of the HDD might be possible w/o switching off swap in the first place. I have not tried this, but I am certain that (in Single User mode) creating the hidden directory first, copying the swapfiles to it, deleting the previous /var/vm location and finally linking the hidden directory to /var/vm will do the exact same thing.

No comments:

Post a Comment