Disadvantages of not having a swap partition

All we need is an easy explanation of the problem, so here it is.

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?

How to solve :

I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.

Method 1

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

Method 2

No suspend to disk.

Method 3

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.

Method 4

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

Method 5

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:

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.

Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply