Tips for Linux Newbies: Understanding Swap Space

One of the first things new Linux users often get confused about is the need to create a disk partition for swap space. After all, neither Windows nor Mac OS X make you do any such thing, what’s the deal with Linux? And what is swap space anyway? To answer those questions and more (like […]

penguin.jpgOne of the first things new Linux users often get confused about is the need to create a disk partition for swap space. After all, neither Windows nor Mac OS X make you do any such thing, what's the deal with Linux? And what is swap space anyway?

To answer those questions and more (like how much space should I give my swap disk?) check out the excellent and thorough write up over at Linux.com.

As for what swap space is, here's the explanation from Linux.com:

Linux divides its physical RAM (random access memory) into chucks of memory called pages. Swapping is the process whereby a page of memory is copied to the preconfigured space on the hard disk, called swap space, to free up that page of memory. The combined sizes of the physical memory and the swap space is the amount of virtual memory available.

And to answer that first question, actually, both Mac and Windows do use swap space, they just use swap files rather than a partitioned off part of the disk. Linux can also use swap files, though in my experience you'll get better performance out of a dedicated swap partition.

One question not really addressed in this piece is the age old debate about where your swap partition should live. Many people argue that the swap partition should be the first partition on the disk to improve seek time, others say it doesn't matter. In terms of real world performance, I currently have my swap partition last on the disk and I'm still quite happy with Ubuntu's performance.

As for how much swap space to use, a good rule of thumb suggested in the article is twice the amount of RAM in your system unless that number is greater than 2 GB. The consensus seems to be that more than 2 GB is overkill for a desktop system.

[via Lifehacker]

See Also: