Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
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
add comment

5 Answers

up vote 6 down vote accepted

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

eh, 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).

share|improve this answer
add comment

No suspend to disk.

share|improve this answer
add comment

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.

share|improve this answer
3  
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
add comment

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...).

share|improve this answer
    
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
add comment

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:

http://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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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