HOWTO - swap partition for OS X


CAUTION! This involves reformatting your disk so be careful and back up your data. If this fries your HD then don't complain to me. You have been warned...

OS X uses dynamic paging (that horrible system that's in Windows95/98/ME) so a fragmented disk makes for very slow performance. With only 128MB RAM on my iMacDV (1999) and a 4GB HD, I run into this problem a lot.

Because OS X is also Unix, you can use a much more efficient paging system, One that's been around as long as Unix. Of course, it's a swap partition.

Unless you have a program like FWB harddisk toolkit, you'll have to re-initialize your HD to add a swap partition but it's definitely worth it.

After seting up a swap partition, I ran almost every app I could find in OS X and the system was still responsive. Normally after running 3 or 4 apps, my system gets a major case of HD chugging.

How to add a swap partition to OS X:
1. BACKUP YOUR DATA (This should be obvious)
2. Create partitions
I chose to have 1 HFS+ and 1 swap
OS 9's Drive Setup and OS X's Disk Utility (Run from the install CD) can both create swap partitions.
For Drive setup, create a partition of type Unix Swap
For Disk Utility, create a Unix partition and give it the name swap
*note I created my partitions with the graphical utility on the LinuxPPC 2000 Install CD. I know Drive Setup can create Unix swap partitions but I haven't tested if Disk Utility does it properly. For the technically minded, the swap partition must be of type Apple_UNIX_SVR2 and have the label "swap"
3. Initialize your HFS/HFS+ partitions.
I don't think this is nesecary if you use Drive Setup or Disk Utility. It was for me because LinuxPPC doesn't know how to format HFS+.
4. Install OS X (and OS 9 if you want it)
5. Bring up terminal
6. Become root
type "sudo csh" and then enter your password (this loads a shell as root without having to specifically enable the root account)
7. Edit the /etc/rc file
find the swap section
comment out all of it.
add the line "mount -vat swap"
- means mount all swap partitions in /etc/fstab
8. run pdisk /dev/disk? -dump
? is the disk number of your hd (probably 0)
record the number next to the swap partition
9. Edit or create /etc/fstab (it probably doesn't exist)
add a line like "/dev/disk?s?? none swap sw 0 0"
- ? is your disk.
- ?? is the number of the swap partition.
10. reboot.

I chose 200MB of swap but you might want more or less depending on how many programs you run.

If you keep running out of memory, you can re-enable dynamic paging (the bit in the /etc/rc file).

Unfortunately there's no way I can find to see if OS X is actually using the swap partition (other than opening heaps of apps and seeing if the HD chugs). the "top" command seems to report bogus values for VM (It said I had 1.5GB of VM but it should have reported 328MB)

Another advantage of this is that if you dual boot OS X and another Unix, you can share swap partitions.

If you don't understand what I was talking about, you probably shouldn't be trying this.

Link :)


After running without dynamic paging for a day, I have realized that Mac OS X lacks a "swapon" command.

This is what lets the OS use the swap partition as VM.

If anyone tried this then I apologise.


Link :(


yada yada yada ya
Originally posted by a1291762
After running without dynamic paging for a day, I have realized that Mac OS X lacks a "swapon" command.
I'm determined to make this work. As per

Apple states:

The swapon() call is not supported; macx_swapon() is the equivalent call from the Mach pager
This looks like a function or procedure to be called by a program, and not a program itself. Does anyone know what/how/if this can be used to enable swap space? It's obvious, as per that the physical command (among many others) was omitted from Darwin.


yada yada yada ya
Browsing the web has proven to be partially fruitless in terms of whether someone has figured out a swapon equiv. But, there is a suggest at:

Which is better than the default setup of OSX. The article shows how to move your swap file to a different drive. Since I'm on a powerbook, I'll probably just move it to the parittion I made for the A/UX Swap space.

Just thought folks may want to know about an alternative :)


I like the subject line.

Type: pstat -s

"swamode not implemented yet" (or something like that).

Does it cheese you off, that we have UNIX.....but only bits of it.

In some UNIX(s) swap is in /tmp (Solaris), it would have been a neat move to go that way, as mounting the filesystem /tmp can automatically bung swap there also. Maybe its implemented but we don't know it yet.

Why did APPLE go back to BSD when they had a
SYSTEM V (AUX) years ago? Which is where the "Apple_UNIX_SVR2" naming came from.

All a little strange.


It appears as if the program /sbin/dynamic_pager is the one which sets up swap. It looks like it runs constantly, a ps shows it running on my system right now:

dynamic_pager -H 40000000 -L 160000000 -S 80000000 -F /priv...

It's started from /etc/rc, and has the following argument list:

usage: dynamic_pager [-F filename] [-L low water alert trigger] [-H high water alert trigger] [-S file size] [-P priority]

and it looks like the default is /private/var/vm/swapfile0


yada yada yada ya
Originally posted by blb
usage: dynamic_pager [-F filename] [-L low water alert trigger] [-H high water alert trigger] [-S file size] [-P priority]

and it looks like the default is /private/var/vm/swapfile0
Unfortuantely it doesn't support swap partitions. It's rather stupid of Apple, really, to not at least include the support, even if it's off by default. It's not like they had to figure out how to it, I mean they're using NetBSD as their reference platform so they have access to all the code needed . . . sheez.