The Death of the Swap Partition?

The Death of Swap?

Firstly, my initial disclaimer is that while there will be technical information in this article, it is also based on opinion and personal experience and therefore if anything, it is a personal account of the usefulness or lack thereof of a swap partition and thoughts, ideas and assertions are welcome.

When I first started using Linux many years ago (maybe 6 now), one its distinct unique qualities was the use of a Swap partition. Initially, I didn’t ask too many questions as I was eager to leave behind the OS that had caused me frustration over the past years. As time went on and I gained more experiences with Linux, I continually would use a swap partition on any new installs and would be asked by anyone for whom I created a set up about the reason for creating this swap partition.

In basic terms I was always told that the purpose of the swap partition was mainly to allow the system access to more memory if your RAM was used up. Therefore, this was useful on systems with low amounts of memory or on machines where there would be a lot of RAM usage thus causing it to be fully used and therefore require additional memory which swap would provide.

Even with older machines or ones lacking RAM, I observed that swap was barely used. Typically on systems with at least 1GB of RAM, I never see any swap used. I suppose this could happen if there was a great deal of memory usage due to intense audio, video, compiling or some other kind of processing.

Newer machines will often have 2 CPU cores and at least 1GB of ram and usually I recommend that at least 2GB of RAM is a decent amount for a newer machine. Considering the processing power and inexpensive nature of adding more RAM, what happens to swap? Swap once had a purpose on older machines but now it seems that it is not only becoming unnecessary but also a burden perhaps?

Swap can have some negative affects as well. With the size of new hard drives these days using up 512mb or 1GB or swap space is certainly not an issue but if you like to use all Primary Partitions like me, then all of a sudden out of the gate you are down 1 of 4 Primary Partitions used on a hard drive (I’ve heard there are ways around this but I am not including using third party software to create more Primary Partitions). So, for example, you are building a custom machine where you want several Primary partitions for a particular reason such as:

swap

/boot (to store your kernel and boot settings)

/ (your root filesystem)

/home (a separate home partition to keep your personal files on their own or even to share it with another distro installed on the same machine)

/var (separate log files or perhaps used for package building)

/usr (holds the majority of your application executables and global application settings in /usr/share)

/opt (could be used for applications you compile youself placed in a different directory other than /usr/ to keep them separated)

Clearly, partitioning is a personal choice and the decision is based upon your specific usage. However; if you use a swap partition, all of a sudden you are losing 1 primary partition. So, unless you create logical or extended partitions, it could be that one of your planned partitions is negated.

Swap Partition Pros:

May help speed up older machines lacking memory

May help speed up machines that require an industrial amount of processing (high tech audio, video or compiling) while performing other tasks

Makes your install ‘feel’ more like nix :)

Swap Partition Cons:

Uses up space and a primary partition

Disk Thrashing over time can damage your hard drive

Accessing the hard drive to use virtual memory is slower than RAM

Alternatives:

If you don’t want or need to use a swap partition, you can instead use a swap file. I am not going to post any links on how to do this right now, but if you do a web search for it, you can find lots of examples.

Although I do not plan on changing any of my current long running configurations as my swap partitions are typically the first partition in my table, I do not plan on using them anymore on any new systems - especially any that I plan on which I have multiboot configurations. I have one now where I can share the swap partition, but more than once I have wished that I did not create the swap partition in the first place. To me, there does not seem to be a need to use such a thing on a dual core machine with 4GB of RAM, better yet, it seems like a waste of a primary partition.

Leave a Reply

Powered by WP Hashcash