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