I'm planning to install Ubuntu 9.04 version. How much space should I dedicate for swap partition. I remember setting it to double the RAM size when I installed long back. At that time my RAM was 256 MB. So I had set the swap partition to 512 MB.
|
feedback
|
|
I would say a good rule of thumb is indeed just as was mentioned above. 2 times the physical memory. Something to consider here, while it is possible to use a smaller swap partition, and it will suffice under most normal circumstances, if you want this system to be rock solid stable, I would indeed follow the 8 GB recommendation. In fact I recommend 2 * RAM + 1 MB so that there is absolutely room to swap out 2 entire copies of memory. This avoids the "shell game" scenario which can have negative performance repercussions. What this will do for you is guarantee a level of resiliency should you encounter an extraordinary event with your system. I've seen scenarios where applications behave badly in unattended environments and before you know it, your system starts slowing down to a crawl. Depending on what you are doing, you might even be able to dispense with the swap file entirely. The extra space for the OS is handy when running many applications at once. However if you only intend to run a few processes, do not intend to interact with the GUI disabling the swap file might be appropriate. But if you are going to have a swap file I always use the sizing formula below.
I also recommend putting your swap file on a seperate disk whenver possible as this will increase performance as the OS can swap in and out at the same time as read/writes from the data disk. I hope this is helpful. | ||||
feedback
|
|
According to the Ubuntu SwapFAQ here the calculation is 2*MB of RAM. So in this case 8GB. Realistically however you should not need more then 2GB. | |||||||||||||
feedback
|
|
Linux can operate quite happily with no swap if you have enough RAM for everything you ask it to do, though it is still a good idea to have some swap as it can sometimes gain better performance when close to filling memory by pushing some not-recently-used stuff out to disk freeing up RAM to use as cache/buffer for currently active IO operations. Also, having some swap, no matter how much RAM you have, does allow a little extra safety net should an app misbehave and need more RAM than usual, or you choose to do something unusual that needs a lot of memory. In general I don't agree with 2xRAM on modern machines. If you have enough going on to end up with 8Gb worth of pages to swapped out to disk then your system is likely to have ground to a completely unusable speed by that point anyway. Even 1xRAM can be overkill in many cases IMO. Remember that you can add swap space in the form of a file at any time, so you can add more swap later if you find you need to. for example, to add an extra GB of swap:
and to remove it (once no longer needed):
(remember though that swapping to files is a little slower than direct to to a partition or logical volume as you have filesystem overhead and greater potential for fragmentation to consider) Hibernation, i.e. on laptops/netbooks, may complicate things a little as IIRC Linux stores memory state in the swap space, so you definitely need more then your RAM size as swap if you plan to use hibernation (and I don't know if that needs to be partition/volume based swap or if file based can be used - it will certainly need to be something mentioned in These points may all be moot though. If you have terabytes of disk storage, allocating 8Gb to swap is likely to be very little hardship! | |||
|
feedback
|
|
Is it still necessary to reserve a partition for swapping? I thought nowadays this also works on a file on the system partition. And then I suppose you can easily change the size if you would insert more memory or if you think you don't need that much swap space. Edit: Here's how that can be done (starting from linux 2.6 kernel). | |||||||
feedback
|
|
first of all, if you want to use hibernation etc, you'll need a swap partition at least the size of your RAM. secondly, remember that RAM is sized in multiples of 2 and not multiples of 10, so declaring 1GB of space for 2 sticks 512MiB of RAM (each read also: http://en.wikipedia.org/wiki/Binary_prefix and so, for four GB of RAM your swap needs to be at least as this is pretty big, it probaly should be enough for all your needs | |||
feedback
|
