Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
MKSWAP(8)		   Linux Programmer's Manual		     MKSWAP(8)

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 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  is-
       sued.

       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 rep-
       resents	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  run-
       ning  mkswap .  A sequence of commands similar to the following is rea-
       sonable 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  contain
	      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)

Linux 1.0			8 February 1995			     MKSWAP(8)

Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=mkswap&manpath=Red+Hat+4.2>

home | help