"swap" partition

It has been very often that my 1GB free goes to zero just by using applications and then the whole OS begins to hang, becoming slow.

So I just want to make sure there's enough disk space for temp files and figured making a partition for it might be a good idea.

So, is it a good idea? How can I make this partition? Should it be /tmp or something?

Is there such a standard value so I can set up a "swap" partition for things like sleep file and those things?

Background
I don't want to make it / and set a different for data, because apps and system are mostly unpredictable. I don't want to have TOO much space reserved and not being used, because my whole hard disk is already small enough.

I think this should be default on the Mac OS, and it should create a file or something for all its needs on creating temp files or whatever it does there. So I'll probably use this solution regardless of future hard drives I will get.

But if you must know, I've got a small hard disk and I will have to stick with this 160 GB for couple months. I've halved it to a bak partition, where I set the Time Machine. Actually, 90 GB for TM. So I got 70 for everything else. About 40 GB goes to music, which is not backed up.

That leaves about 30 GB for everything on my mac, including system files, applications, everything.

macbook pro, Mac OS X (10.6.2), <3 *nix

Posted on Feb 10, 2010 2:31 PM

Reply
20 replies

Feb 11, 2010 12:32 PM in response to The hatter

Thanks again every one. Specially the micromat link from *Charles E. Flynn* and reinforced by *The hatter*. I've already noticed I'd have to re-educate myself on this mater.

*R C-R* you took outdated phrases out of context. Please don't do that. But maybe you do know what you're talking about and, in that case, I'd enjoy learning more about how the OS behaves and why there's no solution for this.

I just won't ask anymore here because there's already a good link for more info that I'll read first and because I think your answer to my "new" question was a good closure to this thread.

Feb 15, 2010 6:49 AM in response to Cawas

Cawas wrote:
*R C-R* you took outdated phrases out of context. Please don't do that. But maybe you do know what you're talking about and, in that case, I'd enjoy learning more about how the OS behaves and why there's no solution for this.


I did not intend to take anything out of context & apologize if it seems that I did. It was hard for me to understand some of your comments; I replied to them as best as I could.

Apple extensively documents the key behaviors of the OS at the developer web site. A good place to start is http://developer.apple.com/mac/library/navigation/index.html, the index page of the Mac OS X Reference Library. The info is intended mostly for developers but the technology overviews in particular contain a lot that should be of interest to anyone curious about how the OS works.

At this point, I'm not sure exactly what you are looking for, but I think the general topic of memory allocation in OS X & specifically how it uses virtual memory will be of interest. I suggest reading the first chapter of Mac Dev Center: Memory Usage Performance Guidelines: Introduction to Memory Usage Performance Guidelines ("Memory Management in Mac OS X") for its discussion of swap files, process memory spaces, etc.

It won't explain everything, but it should explain why the OS does not reserve a specific amount of disk space for swap files.

Feb 15, 2010 8:28 AM in response to The hatter

The hatter wrote:
Storage systems with quota can limit how much of a volume can be used and avoid potential risk, and warn or alert the user. But such a feature has never been added or implemented in Mac Extended.


File system quotas work by putting a limit on the amount of available storage space that can be allocated by specific users. When the limit is reached, either the OS just warns the user that the limit has been reached (a soft limit) or does not allow any further operations by that user that would create files (a hard limit).

OS X does attempt to warn users when disk space is running too low for safe operation, but it does not do this on a per user basis. This is probably in part because unlike most UNIX based operating systems, it does not normally use a preallocated swap partition for virtual memory. Since VM is free to use all of the available space on the startup volume if necessary, & running out of VM space is the greatest potential threat to safe operation that must be avoided, it is the total amount of available free space that is critical, not how much of it is allocated to each user.

More to the point, imposing either a soft or hard limit on the root user makes no sense: a soft limit would just cause the OS to notify itself that it had reached some arbitrary limit & a hard one would cause the OS to lock up, unable to create any files needed to continue. The same is basically true for the other non-human users that provide essential OS services.

At best, quota limits could prevent individual human users from using all of the available space, but it is still the total used by all of them that is significant. Per user limits do not address this particularly well, nor do they make the most efficient use of the startup volume's space or eliminate the risk of running out of VM space.

Feb 15, 2010 1:02 PM in response to R C-R

R C-R wrote:
I did not intend to take anything out of context & apologize if it seems that I did. It was hard for me to understand some of your comments; I replied to them as best as I could.


Wow, I did not see that coming! Cool! And excuse me for writing like an *** - I even thought I was doing it less boldly than I thought you did first. :P

I am hard to understand indeed. Most times I really try not to be.

At this point I'm just looking to get better informed and trying to re-educate my use of the machine. I think some time in the past, from the 90s when using DOS 6.2 up to somewhere, I've created this habit of filling every bit of my HD with data because it was never really a problem.

Maybe if I had a different approach, or start cultivating one, in which I should leave as much free space as possible, I will avoid most issues from now on. Although I don't see this as a good thing from a developer-user viewpoint - the software should be able to avoid this issues, and not leave for the user to worry - I think for life in general it is a good thing to cut off the crap.

Thanks again for helping out, dude!

Feb 15, 2010 1:47 PM in response to Bart1977

I just got around to reading the superuser.com links. A couple of observations about that, hopefully relevant to this topic:

1. Note that creating a dedicated swap (& other) partitions was done to get small performance gains. But as explained in the comment of "Diago" in the second link, this can be realized only if the partitions are on different drives. Putting all the partitions on the same drive actually decreases performance because the drive has to do much longer seeks to switch between partitions.

2. Another comment by "UooU" suggests the dedicated swap partition should be three to four times the size of the installed RAM so for example, for 2 GB of physical memory, a 6 to 8 GB partition should suffice. This is yet another rule of thumb, not a precise number. The required swap file space actually can increase almost without limit, although it would be very unusual for it to grow so large that this generous allocation would not be adequate.

Either of the above should be enough to convince the OP that this is not worth trying without plenty of HD space to spare, ideally on several different drives each connected to the Mac's fast internal SATA bus unless degraded performance is not an issue.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

"swap" partition

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.