MKSWAP(8)

MKSWAP(8)

mkpasswd Home Page System Administration Index mount


NAME
       mkswap - set up a Linux swap area

SYNOPSIS
       mkswap [ -c ] device [size-in-blocks]

DESCRIPTION
       mkswap sets up a Linux swap area on a device or in a file.

       The device is usually of the following form:
              /dev/hda[1-8]
              /dev/hdb[1-8]
              /dev/sda[1-8]
              /dev/sdb[1-8]

       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 mul-
       tiple 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:
              MINCOUNT = 10 * PAGE_SIZE / 1024
              MAXCOUNT = (PAGE_SIZE - 10) * 8 * PAGE_SIZE / 1024

       For  example,  on a machine with 4kB pages (e.g., x86), we
       get:
              MINCOUNT = 10 * 4096 / 1024 = 40
              MAXCOUNT = (4096 - 10) * 8 * 4096 / 1024 = 130752

       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:
              # dd if=/dev/zero of=swapfile bs=1024 count=8192
              # mkswap swapfile 8192
              # sync
              # swapon swapfile

       Note  that  a  swap  file  must not contain any holes (so,
       using cp(1) to create the file is not acceptable).

OPTIONS
       -c     Check the device for bad blocks before creating the
              file  system.   If  any  are  found,  the  count is
              printed.  This option is meant to be used for  swap
              partitions only, and should not be used for regular
              files!  To make sure that regular files do not con-
              tain  bad  blocks,  the partition that contains the
              regular file should have been created with mkfs -c.

SEE ALSO
       fsck(8) mkfs(8) fdisk(8) 

AUTHOR
       Linus Torvalds torvalds@cs.helsinki.fi

mkpasswd Home Page System Administration Index mount