I remember for choice of swap partition, we should use (swap > 2xRAM) at least.Of course it deprecated , because max of computer's ram is very high. kernel support it.

My question: i remember each partition of swap just support 2G maximum, it means if you have 2G ram you should create 2 partition of 2G swap. Did kernel solve it ? it mean can i create 4G swap for one partition?

  • Think: What happens to your system, if it starts to swap more than 2GB? Apart from that - can can create as many swap-partitions as you like. The priority-mount-option will tell the system to use it parallel or sequential. – Nils Mar 2 '13 at 21:31

Either you have a long memory or you've been reading obsolete documents. There used to be a 2GB swap size limit (on most 32-bit platforms), but this has not been the case for years. The limitation was removed at some point in the 2.2 kernel series.

The maximum useful size of a swap area depends on the architecture and the kernel version. It is roughly 2GiB on i386, PPC, m68k, ARM, 1GiB on sparc, 512MiB on mips, 128GiB on alpha and 3TiB on sparc64. For kernels after 2.3.3 there is no such limitation.


Swap is an area for "overflow" if something doesn't fit in RAM. You want not to use it ever (except for dire circumstances, or very unusual workloads) because disk is many, many times slower than RAM. So what you should do is to find out how variable your memory use is, configure memory so that only unlikely peak use doesn't fit, and configure swap with space for said peaks. In the above, the workload, what you consider "unlikely" enough to pay the price in performance, and how much breathing space to leave for extreme peaks is a delicate balancing act. So the standard rule of thumb of swap = twice RAM is total nonsense. On the other hand, disk is cheap, and unless you have hard data to the contrary, twice RAM will do fine ;-)

  • 1
    ...and that "rule of thumb" is really old: From times where 1 MB RAM was much and disk-IO was faster than direct RAM-throughput. – Nils Mar 2 '13 at 21:33
  • 1
    @Nils Please, refresh my memory. Since disk I/O goes through RAM, at what point has persistent storage (disk) ever been faster than volatile storage (RAM)? – a CVn Aug 1 '14 at 15:51
  • @Michael The possible transfer rate from disk exceeded that of the internal RAM throughput, but yes, in fact that was in result as fast as ram.... – Nils Aug 3 '14 at 6:21
  • 1
    @Nils In my mind, it's pretty hard for disk I/O (shuffling data between disk and RAM) to ever be faster than RAM. – a CVn Aug 3 '14 at 12:50

Regarding Village's Bounty, all I can find is an archived mailing list post from August, 2011 stating that the preferred default before kernel commit r225076 was 32 GB, and up to 32 Slices for a Total of 1 TB of Ram (32^2 = 1024) After r225076 the limit per slice was removed, but the thread goes on to say that the practical limit should still be considered 1 TB, due to the limitation of size of a 32-bit integer. If you continue to read the thread, the commit as of August 23, 2011 changed the Size per Slice to 256 GB.

See The Nabble Archived Thread

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.