It is often seen that some Linux Chinese versions have such a description in the installation manual: The Swap space cannot exceed 128 MB. Why is there such a saying? Before explaining the history of the number "M", I would like to give a question: there is no m limit at all! The current limit is 2 GB!
Swap space is paging. The size of each page is the same as that of the Memory Page, facilitating data exchange between Swap space and memory. In the earlier version of Linux, the first page of the Swap space is used as a "Bit ing" Bit map for all the Swap space pages ). This means that each bit on the first page corresponds to a page of Swap space. If this parameter is set to 1, Swap is available on this page. If it is set to 0, this page is a bad block and cannot be used.
In this case, the first Swap ing bit should be 0, because the first page of Swap is a ing page. In addition, the last 10 ing bits are also occupied, indicating that the original version of Swap is Swap_space, and the current version is swapspace2 ).
If the size of one page is s, the Swap implementation method can manage "8 * (s-10)-1" Swap pages. For i386 systems, if s = 4096, the total space size is 133890048. If 1 MB = 2 ^ 20 Byte, the size is exactly 128 M.
To manage the Swap space in this way, it is necessary to prevent bad blocks in the Swap space. If the system checks that Swap has bad blocks, 0 is marked on the corresponding bit ing, indicating that this page is unavailable. In this way, the system generates errors instead of Bad blocks when using Swap.
Currently, system designers believe that:
1. The hard disk is of good quality and there are few bad disks.
2. Even if there are not many, you only need to list the Bad blocks, instead of creating a ing for each page.
3. If there are many bad blocks, this hard disk should not be used as the Swap space. Therefore, in Linux, the bitmap method is removed, and the M limit is also removed. Direct access with address, limited to 2G.