Disadvantages of not having a swap partition
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?
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.
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.
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).
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.