My computer has more than 64KB of RAM (8GB), if I run out of memory I want things to crash so I know I'm out of RAM so I'll buy some instead of say wandering why my computer is running slowly when I can just spend another $40 for another 8GB of RAM.

I'm running Kubuntu in VirtualBox. I'm not sure if there is any way to permanently disable the swap file after the installation has finished.

As with previous Linux installs I've found that the newer GUI installers do NOT provide an option to have a single partition without a swap forcing me to use the old DOS/Console styled installers which do. If I have to reinstall from scratch (not a huge ordeal for me) are there multiple installers or does the regular Kubuntu installer provide a manner to install without a swap file?

  • I'm absolutely sure I want to do this, I have not run a pagefile in years in both XP and other Linux distros I've tried and enjoy my systems being responsive.

  • I'm semi-capable in the console though please do not ask me to type a hundred lines to do a simple copy/paste or text edit, I'm interested in Linux for production not a hobby.

  • I'll be happy to both accept and up-vote whatever answer works as well as clarify anything.

  • FWIW, the installer will let you go ahead without swap if you do the partitioning manually and just don't have any partitions of type swap. (It'll warn, but you can continue.) – Ulrich Schwarz Jun 27 '12 at 20:08
  • Thanks, I'm awaiting a minor answer to figure out how to save an edited text file because of root permissions before I can accept or up-vote. Simple stuff to veterans... – John Jun 27 '12 at 20:09
  • Having a page file doesn't slow your system down, your basic premise is mistaken. – EightBitTony Jun 27 '12 at 20:24
  • A pagefile is a second copy of files on the hard drive, the files already exist therefore the hard drive (slowest between HD/RAM/CPU) is wasting time making the user wait to make a copy of a file. It's an irrelevant remnant from the 70s/80s when RAM was expensive. My computer should only do what I tell it to do, if I run out of RAM then I want to know so I will buy more. If it's something that I'm no longer using I'll close the application manually. – John Jun 27 '12 at 20:38
  • 1
    A page file (or swap area) is not a second copy of files on disk. You seem to misunderstand what virtual memory is about and how it is handled. In any case, I would advise monitoring swap usage instead of waiting for processes to crash. – jlliagre Jun 27 '12 at 22:02

Just like every other distro.

swapoff -a

Then edit /etc/fstab and remove references to swap.

  • Console says I'm not a super user even after using sudo. – John Jun 27 '12 at 19:10
  • sudo works with one command at a time (slight oversimplification). First you say sudo swapoff -a, then you say sudo $EDITOR /etc/fstab, or maybe sudoedit /etc/fstab. If you don't like vi, set your preferred editor with EDITOR=/usr/bin/whatever before you edit /etc/fstab. – Alexios Jun 27 '12 at 19:21
  • sudoedit /etc/fstab worked, was able to comment out the last line however how do I save? Obviously a keyboard combination and I haven't seen this type of console editor for years. – John Jun 27 '12 at 19:28
  • @John - so what is your editor? Escape, then :wq will do the job on vi. – Nils Jun 27 '12 at 20:55
  • Kubuntu opens up GNU nano. I looked up their FAQ and I might as well had been reading a manual for how to put together a partial accelerator. >__> – John Jun 28 '12 at 0:40

This isn't an answer; I wanted to comment but my non-answer-type-thing wouldn't quite fit in the comment box, so here it is. Feel free to ignore/downvote — and yes, I know you're sure you don't want swap.

POSIX/Linux Swap isn't like Windows pagefiles, and Linux overcommits memory. That means that you may have 8 gigs of RAM, and the OS will happily allocate you 64 GB if you like it (and are running on a 64-bit architecture). Everything will be fine and dandy until you fill up one to many pages of that block of ‘memory’ and the Linux OOM Killer wakes up.

The OOM Killer is like the Kraken. When it wakes up, it's going to have a sacrificial process for lunch, and there's nothing you can do to stop it. There's also nothing you can do to influence the choice of process. It's usually a big process but not necessarily the culprit. If this process is useful to you, tough. The OOM Killer doesn't care, and Murphy's Law isn't on your side. I've known it to compromise live servers by killing important processes.

Overcommitting is done by design, and the OOM Killer is one way to solve the obvious problem of what happens when some process calls the kernel's ‘64 gigs? Suuure’ bluff. Many people consider it an inconvenient little wart, and we like to keep it sedated as long as possible.

If $40 is an acceptable upgrade price for you, by all means, get another 8 GB of RAM. Add a little bit of swap too, though. Just a few gigs will do. It's not going to compromise the speed of your computer, and you can adjust how much Linux will loathe dipping into the swap. With 8GB of RAM, you might see a few megs in the swap and that's all. Crank it all the way up if you want! Having the swap means that you'll get a little bit of warning before you start losing processes.

As an example, my computer has 4GB of RAM and it's only using 350K of swap.

Besides, if you installed Ubuntu, you already have a swap partition. It's a pity to let the space go to waste.

This has been discussed a lot in various places, including here: is swap an anachronism? It's an interesting read.


To disable the swap after the install, you can edit the /etc/fstab file and comment out the line that enables swap.

  • Not possible to write to the file? – John Jun 27 '12 at 19:12
  • You need to be root. – Jon Lin Jun 27 '12 at 19:18
  • I typed "sudo passwd" and then was able to set the root password (doesn't make sense though okay). I was able to disable the swap for this session. How do I open the file as root via the GUI? – John Jun 27 '12 at 19:26

Console commands due to the lack of a GUI option...

1.) Open console.

2.) Type the following command...

sudo swapoff -a

3.) Enter your root password.

4.) Type the following command...

sudo nano /etc/fstab

5.) Comment out the swap line (seems to be the last, will say "swap" on it.

6.) Press CTRL+x to save if using nano and confirm the file by pressing 'y'.

Was told that the caret ^ signifies the CTRL (Control) key. Exiting will prompt the file to be saved.

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.