Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

10.5: Move swap files to another partition under 10.5 System 10.5
Here's a simple way to move your swap partition under Leopard that appears to work for both Intel and PowerPC based Macs. Edit the file com.apple.dynamic_pager.plist, located in /System/Library/LaunchDaemons. Replace the /var/vm path with the full path to your swap partition. In my case, the entire plist ends up looking like this: Save and reboot, then check your new swap location is being used with this command:
ps -wax | grep dynamic_pager -m1
Finally, you probably want to clear out any old swapfiles from /var/vm:
sudo rm -rf /var/vm/swapfile*
As mentioned this works on PowerPC and Intel Macs, and it also works after reboot or shutdown/restart. However, if your swap partition can't be found, there is no fall back -- Leopard will start up without swap, and may get unstable if you continue to use it in that state. There's a more verbose version of this tip in this forum thread, with some extra discussion regarding the sizing of the swap files.
    •    
  • Currently 2.50 / 5
  You rated: 1 / 5 (6 votes cast)
 
[23,250 views]  

10.5: Move swap files to another partition under 10.5 | 7 comments | Create New Account
Click here to return to the '10.5: Move swap files to another partition under 10.5' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.5: Move swap files to another partition under 10.5
Authored by: jyu on Dec 05, '07 02:56:37PM

I don't think people should bother with this unless they have 2nd hard drive. If you only have one hard drive, you're wasting your time. It's pure physics. There is only arm in one drive to move around. It doesn't gain any speed boost to put swap files on another partition.



[ Reply to This | # ]
10.5: Move swap files to another partition under 10.5
Authored by: adrinux on Dec 05, '07 03:21:51PM

Well to quote myself from the mentioned forum thread:

The benefit of moving swap to a different disk partition has been debated before, so please keep your comments useful, we really don't need yet another 'why bother' comment thread :P
Guess I should have added that to the tip too ;)

You're absolutely right of course. My swap partition is on a different disk however. Moving swap doesn't lead to a leap in performance even then. There is one issue moving swap to a different disk cures for me: iTunes stops playing music briefly when large swap files get written, my poor old G4 can't create swap files and read an mp3 from disk at the same time, there is only one head on the drive as you say...

I see a clear but small benefit from moving swap to a different partition (which is on a different disk if we're being pedantic) on my setup. YMMV.



[ Reply to This | # ]
10.5: Move swap files to another partition under 10.5
Authored by: aardvarko on Dec 10, '07 09:25:28AM

what happens if the kernel hasn't mounted the swap disk by the time VM is initialized? Boots without? Defers swapfile creation?



[ Reply to This | # ]
10.5: Move swap files to another partition under 10.5
Authored by: TigerKR on Dec 05, '07 09:20:40PM

Firstly, having a dedicated (contiguous free space) partition for swap on the fastest part of the hard drive is beneficial even in a single HDD configuration. Anytime a file is fragmented, it will take longer to read from / write to. Anytime a file (or fragments of a file) are located on the slower parts of the drive, they will take longer to read from / write to. The more the swap is used, the more this effect becomes pronounced. The less the swap is used, the less this effect becomes pronounced.

For the vast majority of people, this isn't really much of a concern. For those for which it is a concern, the answer is to get more RAM, so that they swap less. But for the small minority who constantly hit their swapfiles even though though they have gigabites of RAM, this is helpful. Of course, putting the swapfile on a different drive is better. Heck, its even more betterer ( :) ) if you can put it on a different bus completely.

But, sometimes that's not an option. Like for instance if you're on a laptop, which has a slow HDD to begin with, a typically lower RAM cap, and typically less expansion possibility.



[ Reply to This | # ]
10.5: Move swap files to another partition under 10.5
Authored by: chabig on Dec 05, '07 09:57:16PM

You're kidding yourself if you think you can get the drive controller to put your data onto any particular place on the disk.



[ Reply to This | # ]
10.5: Move swap files to another partition under 10.5
Authored by: TigerKR on Dec 10, '07 09:26:56PM

Partitioning a drive is not a joke.

If you partition a drive into multiple partitions, whichever partitions do not contain the OS are going to be void of any files until you put some there. When you partition a drive, the first partitions are the fastest parts of the drive.

Perhaps you have never partitioned a drive before. And if you have not, then you probably don't need/want to. So please excuse us, while we continue our conversation because we need/want to.



[ Reply to This | # ]
Warning - may not work
Authored by: E_James on Feb 25, '08 10:17:56AM
These instructions will not work if your 'Swap' partition has not mounted by the time the dynamic pager is launched. In my experience, this happens most (if not all) of the time. The failure is hard to spot, because it looks like it is working properly: You will see your swapfiles in /Volumes/Swap/.vm as expected. The problem is that the system creates its own dummy partition called 'Swap'. If you look at your mounted volumes in /Volumes, you will see both 'Swap' and 'Swap 1'. 'Swap 1' is the partition that you created, and it will not contain the swapfiles. The dummy partition that the system has created actually represents a folder on your boot partition.

Having said all of that, there is a solution, and this tip was an excellent starting point. A description of my solution can be found in this forum thread.

Essentially, it uses the com.apple.dynamic_pager.plist file to launch a shell script which waits for your 'Swap' partition to mount before allowing the dynamic_pager to initialize.

[ Reply to This | # ]