Software & Apps Linux Do You Need A Swap Partition? Will setting up swap space on your hard drive help your computer? Share Pin Email Print noLimit46 / Getty Images Linux Switching from Windows By Gary Newell Writer Gary Newell was a freelance contributor, application developer, and software tester with 20+ years in IT, working on Linux, UNIX, and Windows. our editorial process Gary Newell Updated February 04, 2020 77 77 people found this article helpful A question that is commonly asked when installing Linux is "Do I need a swap partition?" Memory is a bit like a shopping center car park. At the beginning of the day, the car park will be empty and there will be lots of spaces available. As people start arriving more and more spaces are used up and eventually the car park will be full. At this point, there are a couple of things that can happen. You can either stop any more cars entering the car park until spaces become available or you force some of the cars to leave thereby releasing spaces. In computing terms, when you first start using your computer, you should have most of your memory available. The only memory being used will be from processes required by the operating system. Every time you load an application a new process will start and a set amount of memory will be set aside for the application. Every time you load a new application, less memory will be available to run that program and eventually you will get to the point whereby there isn't enough left to run that application. What Does Linux Do When There Isn't Enough Memory Left? It starts killing off processes. This isn't something you really want to happen. Whilst there is a scoring mechanism for choosing which processes to kill, you are basically leaving the decision up to your operating system and taking it out of your own hands. Westend61 / Getty Images Linux will only start killing off processes when virtual memory runs out. What is virtual memory? Virtual memory is the amount of physical RAM + any disk space set aside for paging purposes (swap). Think of a swap partition as an overflow car park. When all of the main car parking spaces are full the overflow car park can be used for additional space. There is, of course, a downside to using an overflow car park. Generally the overflow car park is further away from the actual shopping center and so drivers and passengers have to walk further to the shops which is time-consuming. You can create a swap partition which will be used by Linux to store idle processes when the physical RAM is getting low. The swap partition is basically disk space set aside on your hard drive. (Much like an overflow car park). It is obviously much quicker accessing RAM than files stored on your hard drive. If you find that you are constantly running out of memory and your hard drive is whirring it is likely that you are excessively using swap space. How Badly Do You Need a Swap Partition? If you have a computer with a small amount of memory in the first place, then it is highly recommended. As a test, we set up a virtual machine with 1 gigabyte of RAM and no swap partition and installed Peppermint Linux, which uses the LXDE desktop, and overall, it has a low memory footprint. Peppermint Linux comes with Chromium pre-installed, and every time you open a Chromium tab, a decent amount of memory is used. We opened a tab and navigated to linux.lifewire.com and then opened a second tab and did the same. We kept repeating this process until, eventually, the memory ran out. The image above shows what happened next. Chromium displays a message stating that the tab has stopped working and this is probably due to lack of memory. Then, we set up a new virtual machine with 1 gigabyte of RAM and an 8-gigabyte swap partition. We were able to open tab after tab after tab and although the physical RAM had run low, the swap space started to be used and we were able to continue opening tabs. Matthew Field / www.photography.mattfield.com Clearly, if you have a machine with 1 gigabyte of RAM you are more likely to require a swap partition than if you have a machine with 16 gigabytes of RAM. It is highly likely that you will never use the swap space on a machine with 8 gigabytes of RAM or more, unless you do some serious number crunching or video editing. It is, however, always recommended to have a swap partition. Disk space is cheap. Set some of it aside as an overdraft for when you are running low on memory. If you find that your computer is always low on memory and that you are constantly using swap space it might be time to think about upgrading the memory on your computer. If you have already installed Linux and you didn't set up a swap partition, all is not lost. It is possible instead to create a swap file which basically achieves the same goal. Can I Set Aside Space on My SSD for Swap Space? You can set aside space on an SSD for swap space, and in theory, it will be much quicker to access that partition than on a traditional hard drive. SSDs do have a limited lifespan and can only handle a certain number of reads and writes. To put things into perspective, that number is actually very high and your SSD will probably outlast the life of your computer. Andrii Atanov / Getty Images Remember, swap space is supposed to be an overflow buffer and not used consistently. As mentioned before, if you find that you are constantly using the swap partition, consider upgrading the memory.