Learn More About Swap Space
Posted by Kevin Purdy at 2:40 AM on December 7, 2007

Swap space, the hard drive portion used as temporary memory by Linux systems, is often one of the first stumbling blocks for anyone trying out their first installation. Luckily, Linux.com has posted a helpful guide to how swap space works, how to tweak it, and how much to set aside. The writer's basic advice is that modern desktop systems should have double their physical memory available (although commenters don't recommend going beyond 2 GB), servers should use about half their memory, and older desktops should use as much as they can spare. Linux users, how much have you set aside for swap space, and why? Share your setup methods in the comments.

Comments (AU Comments · US Comments)
There are currently no AU comments for this post.
eeefresh
Posted 2:12 PM 6/12/07
I think I designated 512 MB of swap, but my PC has 2 GB already, so I don't think its ever accessed the swap partition.
Its been a while since I installed Ubuntu, but is it mandatory to set up a swap file? The next time I do a clean install, I may avoid the wasted swap space, if possible.
eeefresh
fatalbush
Posted 1:48 PM 6/12/07
Lots of hearsay on here. none of this would stand up in court.
I heard that when I was running Ubuntu 6 on an old crappy laptop, I used 512mb. That's what I heard at least.
fatalbush
2-7offsuit
Posted 12:25 PM 6/12/07
I've heard that there can be benefits to using a swap partition with osx. Can anyone comment on that? Is it worth it? It seems like an easy way to screw up the entire system if not done correctly.
2-7offsuit
randy
Posted 12:20 PM 6/12/07
I have a newER computer at home (dual-core Athlon64, 2GB of ram) running Gutsy (64 of course) and I setup ~512MB of swap. I've always read that anything past 512 is pretty much useless and to be honest, the swap on that machine is never used. Unless you're running memory intensive applications or have less than 512MB or physical ram, there's no need to have double-your-ram sized swap. Swap is slow. If you think you need more swap, you really need more ram.
On my server, swap is 512MB as well, but, it's a virtual machine limited to 256MB ram where swapping happens whenever I do a `gem install ...` Ruby likes memory... and lots of it.
randy
AnthoMacP
Posted 11:43 AM 6/12/07
I'm using an older 2004 Dell laptop to run ubuntu and i've got 512MB RAM and my swap is around 650MB and it seems to work well for me, I never have the system freeze and my applications run perfectly, in fact in terms of memory usage i've never used more than 60% of the swap at one time. I do it this way because for me every 100MB counts, so rather than setting it to 1GB and having an extra 450MB lost on my very limited internal space (Ubuntu partition is only 13GB, the rest of my 80 GB is my NTFS that stores my music so i can access it in both windows and ubuntu), I set it to the relatively low 650 but have never had problems. I was always told that you should stay between 500 and 1.5GB unless you have like 4GB of ram, at that point apparently it doesn't matter much.
AnthoMacP
reswob
Posted 11:36 AM 6/12/07
I have to confess I just let Ubuntu auto-configure my swap space. But thanks for the link.
reswob
cv
Posted 5:27 PM 6/12/07
@2-7offsuit:
For typical Mac users, I don't think a separate swap partition is going to provide much benefit. The system creates a swapfile at boot time; additional swap files are created as necessary. I rarely see more than the default 64MB swap on my system since my machine almost never pages.
A few folks running servers or doing certain types of work might benefit by moving swap to a different physical disk, but yeah, you could easily mess up your system if you did this incorrectly.
It's interesting to note that most of the online articles are several years old, which might lead one to believe that recent versions of OS X are better capable of managing memory (physical or virtual) than their predecessors.
You're far better off maxing out your system RAM before you diddle with swap.
cv
dangral
Posted 5:07 PM 6/12/07
The SWAP partition is needed and utilized by the OS in both Linux and Unix.
On a desktop system you shouldnt need more than 2x the physical RAM, up to about 1 GB total. This is assuming that you have enough physical RAM to handle the application load.
On servers, the swap partition can be used as a dump device in case of a failure and you want the swap space to be at least equal to the amount of physical RAM so that all the memory can be dumped to disk.
dangral
kodemage
Posted 6:11 PM 6/12/07
Swap is always useful, modern hard drives are so large that everyone can afford to have a nice large amount of swap. Those of you that say you don't use swap just aren't looking at the right times. I've got 2gb ram in my computer and I'm always maxing out the RAM usage and I get to 70%+ of swap file usage regularly. (Swap is 2gb) My running programs generally include Firefox, Miro, kTorrent, Amarok and maybe a couple of file browser windows, so I'm not using swap at that point. When I fire up the gimp or a game client (A Tale in the Desert) I get significant swap file usage.
Regards,
-Benjamin
kodemage
Green_Star
Posted 8:39 AM 7/12/07
My laptop has 512MB ram, and I have same amount of swap . So far I have no problems while using machine, but most of the times it fails when I try to hibernate machine saying not enough free swap. Swap will be useful when you using heavy applications, i also observed my swap was well used when i am running vmware os, and switching between guest and host.
Green_Star
kc2idf
Posted 8:21 AM 7/12/07
Workstation: 512MiB physical; 1GiB swap. Machine is an EPIA MII-12000
Wife's workstation: 512MiB physical; 1GiB swap. Machine is a 1.8GHz Sempron
HTPC: 512MiB physical; 2GiB swap. Machine is an EPIA MII-12000
House server: 384MiB physical; 2GiB swap. Machine is a 525MHz K6-2
Reasons:
The two workstations don't have that heavy of a workload. the HTPC spends a lot of time and RAM doing audio and video transcodes, and the server has the extra swap to allow some headroom for SQL queries.
kc2idf
KSMarksPsych
Posted 7:25 AM 7/12/07
The laptop I'm running on has 2 GB of RAM. I was clueless the first time I installed Ubuntu. It was a triple boot setup and I had no idea how to create the whole partition in a partition thing. I didn't have a swap partition at all, and I was fine.
When I actually found someone with the patience to walk me through everything, I found out how to have more than four partitions. So now I have a 4 GB swap partition. There's also a partition for my home directory as well as one each for Ubuntu, Fedora and Vista. I have a FAT32 data partition as well.
KSMarksPsych
swalve
Posted 6:59 PM 7/12/07
I'm not a fan of a separate swap partition, I'd rather a swap files. Why make the disk seek back and forth.
And always err to larger rather than smaller. Better to have 1gb of space sit unused than to have repartition.
swalve