How big should the swap space partition be? No single number works for all installations, unfortunately. Generally, because the swap space is used as an extension of physical RAM, the more RAM you have, the less swap space is required. Add the amount of swap space and the amount of RAM together to get the amount of RAM Linux will use. For example, if you have 8M of RAM on your machine's motherboard and a 16M swap space partition, Linux will behave as though you had 24M RAM.
Linux uses the swap space by moving pages of physical RAM to the swap space when it doesn't need them, and moving them back again when it needs the memory pages. Why not make a very large swap space and let Linux think it's in heaven? The swap space is much slower in access time than RAM, and there is a point at which the size of the swap space starts to act against your Linux system's efficiency instead of for it. In addition, most versions of Linux have an upper limit of 16M for each swap partition. Those versions of Linux will, however, let you partition more than 16M to a swap space, but it will only use the first 16M. If needed, though, you can create multiple swap partitions. Up to eight swap partitions can exist, each up to 16M in size. The latest versions of Linux allow swap partitions larger than 16M, but it is wise to keep that size as a guide.
You may not even need swap space if you have lots of RAM. For example, if you have 16M of physical RAM and don't intend to do any application development or run X, you probably won't make much use of the swap space because Linux can fit everything it needs in the 16M. (You still should have a small swap space, just in case.) If you are running X, developing applications, or running memory-hog applications like databases, swap space is crucial even if you have lots of physical RAM. Even 16M RAM is not enough for X, so you need swap space.
A good rule is to create a swap space with the maximum size limit of 16M. Unless you have a very small capacity hard disk, a swap space of this size won't be a major drain on your resources, and it gives Linux plenty of space with which to work. If you don't want to allocate this much space, a good rule is to have a total of 16M RAM (swap space plus physical RAM). Don't eliminate the swap space completely, though, even if you have a lot of RAM. At a minimum, set up a 4M swap space. Running out of RAM can cause Linux to lock up or crash.
Once a swap space partition has been created, it is just like any other partition on the hard drive. If you want to change its size, you have to remove the existing partition and create a new one, although the space must be contiguous on the hard drive (which can be difficult to do if you have used all the space the drive offers for other partitions).
Was this article helpful?
Read how to maintain and repair any desktop and laptop computer. This Ebook has articles with photos and videos that show detailed step by step pc repair and maintenance procedures. There are many links to online videos that explain how you can build, maintain, speed up, clean, and repair your computer yourself. Put the money that you were going to pay the PC Tech in your own pocket.