The device is usually of the following form:
The size-in-blocks parameter is the desired size of the file system, in blocks. This information is determined automatically by mkswap if it is omitted. Block counts are rounded down so that the total size is an integer multiple of the machine's page size. Only block counts in the range MINCOUNT..MAXCOUNT are allowed. If the block count exceeds the MAXCOUNT, it is truncated to that value and a warning message is issued.
The MINCOUNT and MAXCOUNT values for a swap area are:
For example, on a machine with 4kB pages (e.g., x86), we get:
As each block is 1kB large, the swap area in this example could have a size that is anywhere in the range from 40kB up to 127.6875MB.
If you don't know the page size that your machine uses, you may be able to look it up with "cat /proc/cpuinfo".
The reason for the limit on MAXCOUNT is that a single page is used to hold the swap bitmap at the start of the swap area, where each bit represents a single page. The reason for the -10, is that the signature is "SWAP-SPACE" -- 10 characters.
To setup a swap file, it is necessary to create that file before running mkswap . A sequence of commands similar to the following is reasonable for this purpose:
Note that a swap file must not contain any holes (so, using cp(1) to create the file is not acceptable).