Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
All the desktop systems I manage and play with never use the disk swap space i partitioned for it. My home computer has 1024mb ram...and again never uses its swap space. I use disk space and would like to have that 2 gigs i have under swap. How much swap do I really need, if any?
I have plenty of RAM also but I still have 768MB for swap. You probably don't need it but it's nice to have. Should you run out of RAM for some reason, having swap for the kernel to page to saves it dumping other stuff which it will then need to read later and slow things down. I also have 520GB of disk space so having a little bit for swap doesn't hurt at all. You certainly don't need 2GB though if you have 1GB of RAM. If you're that desperate for the space, cut it down to 512MB or even 256MB, but if it were me I'd still keep it.
Thanks for the help. Say for example, I used up all ram space and didn't have any swap...what's the worst that can happen? Or, in other words, what would happen if your kernel needed to use swap but you didn't have it? Just disk swaps taking more time, but no real harm?
swap is not really just extra RAM the way people think of it or like it was in 1980's
the kernel uses swap to hold application data that is not already on disk
stuff like libraries and the applications themselves are already on disk and can just get reread
but unique data that is generated on the fly goes in the swap que imediatly when it is created so it can be swap out in a hurry if needed. This includes stack and heap data for running proccesses and these pages are called anonymouse mappings because they don't corespond to things that can be read from disk. Is there still a swap que when there is no swap ? certainly the kernel will be confused because it is designed at it's core to use swap.
the kernel can just eject clean pages that are backed be disk no problem. The kernel generally does a pretty good job of flushing these pages when they get dirty so they stay clean and ejection can be real fast. annonymouse pages on the other hand can oly be clean and ejected when they have been flushes to swap cause no other disk file exists for them. Swap is their disk files by design.
If you don't have swap the kernel vm page allocation system is unballanced and cannot function properly.
the kernel will constantly be doing more work possibly thrashing pages or doing extra disk writes to figure out how to get clean memory.
in my opinion this will cause you machine to run slower as the kernel struggles to keep more pages clean even if swap is not ever used but i'm not sure.
and i think without swap if an app gets out of controll alocating memory your system might freeze rather than be able to recover
What about systems that use Linux in an "embedded" application where there is no real disc, just a flash drive to boot from/get things started and plenty of RAM to hold evrything once the embedded app is up and running?