I recently installed Ubuntu 10.04 on my laptop. Due to space constraint of the SSD, I did not set a swap partition for the OS, and I have 1.5GB of RAM.

There's a warning during installation, but I think it's not a big deal since everything went smoothly.

For the long term, would there be any drawbacks of not having a swap partition?

  • 2
    Gparted will be happy to carve a couple gig of of your root drive, and do it with ease and aplomb. – msw Jun 7 '10 at 0:26

I think if I am to write you an answer to the question I must first explain the whole swapfile thing a little bit here. Pardon me for my long-windedness.

A swapfile/swap-partition, similar to the pagefile in windows, is harddisk space dedicated to facilitate the better use of memory. There are two uses of the swap space.

  1. When there is not ENOUGH memory for all applications - in the case where this happen to a system without swapspace, it will cause failure to allocate memory for new application requesting new memory pages - and this usually result in termination of the program.

  2. When some memory pages (memory is divided into ‘pages’) is used some time ago, but is no longer used now, it would be transferred on the swapfile and the remaining memory can be used to do something else which could be more useful (e.g. even caching!) - when this happen in a system without swapspace, this will result in idle pages being staying in memory. This is nothing too serious though, as we have pretty large amount of memory these days.

And then, so now we have the uses of the swapfile/swap partition listed, how much is usually advisible? - that depends on the function of the machine. If it is a desktop machine, set it to 1-1.5x the memory. If it is a server machine, do the same, but note the swap use, if it is heavily used, upgrade the memory.

As others have pointed out, gparted can help you carve out several gigs of space from your ext2/ext3 partition, but you can as well use a swapfile:

dd if=/dev/zero of=/swapfile bs=1024 count=1048576
mkswap /swapfile
swapon /swapfile

You should have

swapfile none swap sw 0 0

on fstab to ensure it being used on each reboot

And one more thing: If you don’t mind to have swapspace but do want to minimize the use unless your memory is really stretched out, you can change the “swappiness” of the kernel by changing /proc/sys/vm/swappiness (values, 0-100; default, 60).

  • There can be uses for swap other than what you've stated, such as a swap partition being used to automatically store a crash dump file. Also, the 1-1.5x memory size is not a universally accepted value. In theory, a computer with more memory would need less memory for swap, because it had X RAM used up and needed Y more RAM, it might be able to fit that extra memory into available RAM instead of the swap. – TOOGAM Feb 6 '15 at 3:04
  • @TOOGAM it was in 2010, when people use stuff like 2-4GB of ram in their desktop. – bubu Feb 6 '15 at 12:14

No suspend to disk.


If you ever run out of memory, then unpredictable behavior can happen to your programs. Sometimes the kernel will start dropping memory at random places. The kernel will start dropping low priority processes.

No virtual memory can spell big trouble, especially if it's going to start dropping memory from kill important documents that have low-priority that are being worked on.

  • 4
    This would happen regardless of whether or not you had swap. – Ignacio Vazquez-Abrams Jun 6 '10 at 23:18
  • 2
    Actually, the kernel will not "start dropping memory at random places". Rather it will do what has to be done and start killing off processes deemed "less important" until the situation improves. This is done by the "OOM killer". See e.g. linux-mm.org/OOM_Killer – sleske Jun 6 '10 at 23:43
  • I stand corrected. – Nitrodist Jun 7 '10 at 0:09

After installation, check your memory usage when running memory-intensive operations or simply opening 'large' apps, like Openoffice.org, decompressing files and such. If you see that the total memory used is almost 1.5 GB, then it's probably a good idea to have a swap partition or swap file, just in case you conveniently run something that uses a lot of memory and Ubuntu starts dropping important memory, and maybe even parts of the kernel (not good, really not good...).

  • I'm curious, is it even possible to make linux drop parts of its kernel in order to free memory for running processes? – Igor Zinov'yev Jun 7 '10 at 14:25
  • Probably not, but you know what I mean... – Hello71 Jun 7 '10 at 21:09
  • AFAIK, the Linux kernel itself always stays in memory. It's loaded as first part of the boot sequence and stays; the memory is never freed or even swapped out. You can, however, load and unload modules, and that memory will be freed (I believe), but that's typically only a few dozen kb per module. The kernel also maintains various internal data structures & buffers, it may be able to free some of them (not sure though). – sleske Jun 8 '10 at 10:28

Not a complete answer, but here is a story of one thing that really attacked me, even when I was thinking I had every possible downside under control:

https://stackoverflow.com/questions/4567972/error-executing-aapt-all-of-the-sudden In summary, some tools run from really big Java processes/applications will not be able to run always. Most regular users will not run into this however.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.