Move your swap space onto a disk image

Dec 26, '01 10:24:23AM

Contributed by: Anonymous

hello everybody, I was reading a ResExcellence article about improving app run times (and minimising pageouts), but it required one to start up from the OS 9 disk (ugh!) and format the existing hard drive (ugh! ugh!). So I created an alternative method.

I have the information up here, but I'll copy and paste the steps here. Read the rest of the article for the step-by-step instructions.

[Editor's note: I have no idea if this works nor the implications of trying it. There are other tips posted here with info on moving swap to another hard drive, but this seemed interesting enough to merit posting as an independent alternative. As with anything like this, make sure you have a good backup before you start changing the system files!]

  1. Unmount all disk images.
  2. Create a 500MB disk image formatted with Mac OS Extended (in this example I will use the Desktop) and image name vm.
  3. Move the disk image to the root directory /
  4. chmod both the .dmg file and the disk image to 700 as a security measure (or any other value that would be relavant to your usage)
  5. Note the path name of the disk (mine is /dev/disk2s9)
  6. Get root access with su and enter: pico /etc/fstab
  7. Enter this: /dev/disk2s9 /vm.dmg hfs rw 1 2 (NOTE: you should change this to suit your device)
  8. With root access open /etc/rc with pico /etc/rc (see footnote)
  9. Scroll down a bit and locate the line which starts with swapdir=/private/var/vm
  10. Replace the line with swapdir=/Volumes/vm/vm
  11. Reboot the computer.
Of course, there will be a disk image icon on your desktop, which would waste unnecessary space (or look plain ugly). If you have the Developer Tools installed, the disk can be hidden. So, following steps from Mac OS X Hints, do this: sudo /Developer/Tools/SetFile -a V /Volumes/vm/ and (if you want) sudo /Developer/Tools/SetFile -a V /wm.dmg (this information from a previous Mac OS X Hints hint).

Does it work? Well, it does. Pageouts are less (but not zero), and iTunes starts within three bounces the first time round on my iBook 333MHz (which is a miracle). Subsequent times iTunes launches in one or two bounces. System Prefs is launched from 8 to 3. IE launches in three bounces, from five. Terminal launches in 8 from 13 bounces.

Enjoy.

Comments (13)


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