Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

When i installed ubuntu in my x86 machine, I had to configure some memory as 'swap area'.

What is the use of this memory and what is the importance of this memory in linux file systems?

How can I determine the exact size of 'swap area' in a machine for the safe working of linux inside in it?

share|improve this question
add comment

6 Answers 6

up vote 6 down vote accepted

A very "untechnical" explanation:

Swap area is hard drive space that is reserved to act as extra RAM for when your computer needs more RAM than what is available. Note that when this happens your computer might slow down noticably.

The Ubuntu help website recommends that you have double the ammount of RAM as SWAP. So if you have 1GB of RAM, you should have 2GB SWAP, however your computer should work fine with less SWAP.

share|improve this answer
    
Swap area is hard drive space that acts as extra RAM. HOW? –  Renjith G Oct 15 '10 at 20:56
    
You tell your computer to use the SWAP partition ( some hard drive space reserved for this purpose ) when it needs more RAM space than what is installed on your system –  Stefan Oct 15 '10 at 21:02
    
I updated my answer to reflect this. –  Stefan Oct 15 '10 at 21:07
    
NO man. i mean how the said hard disk space acts like as a RAM ? –  Renjith G Oct 15 '10 at 21:08
    
no idea :) my quess is that the system reads and writes to the RAM, so now it just reads and writes to a area on the hard drive and that area is called swap... –  Stefan Oct 15 '10 at 21:13
show 3 more comments

The swap partition (or file) in linux is equivalent to the page file in Windows. It's used for offloading the RAM. If the RAM gets full, the OS can use the swap partition as extra RAM.

As for how to determine your swap size, the rule of thumb is (used to be) 2x the amount of RAM in your machine. So if you had 512MB of ram, you would have a 1GB swap partition. This rule is largely outdated though. So if you have more than say 2GB of ram, you don't really need 4GB of swap.

I normally make my swap size equal to the ram size + 10%. It has to be equal to the RAM size so that you can use suspend to disk features, and then + 10% for good measure.

share|improve this answer
add comment

The Ubuntu Swap FAQ provides some of the answers you ask for.

There are also a few posts on this very site, that already cover much of the topic:

share|improve this answer
add comment

Swap is a type of filesystem and is a virtual memory. Whenever your RAM is full, your operating system will look for further memory in your swap space. For this reason, you reserve some part of the hard disk to create a swap partition.

share|improve this answer
add comment

You probably mean you configured some space on your hard disk for swap.

Swap is part of memory management. It extends the virtual memory space you have, such that it can be more than your physical memory available, i.e. RAM. This allows then to swap pages of memory between RAM and harddisk, however, obviously it will decrease the performance when this happens.

This way applications can allocate more memory that you have as RAM, even it cannot all be used at the same time.

share|improve this answer
add comment

'swap area' is literally what it says, i.e. area with which memory on RAM is swapped to free up RAM space. This process is also known as thrashing.

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.