mkswap

mkswap

Purpose

Create a swap space for Linux.

Syntax

mkswap [options] device_or_file numblocks

Options

-c checks the device for bad blocks before creating the swap space.

-f forces creation of swap space even if there are errors, such as the requested size being greater than space available on the device.

-P NNN uses NNN as the page size for the swap space.

-vN (where N is 0 or 1) creates an old-style swap space if N is 0; if N is 1, creates a new-style swap space.

Description

The mkswap command creates a swap space for use by the Linux kernel. If you are creating swap space in a disk partition, specify the partition's device name (such as /dev/hda2) as the second argument to mkswap. If you want to use a file as swap space, create the file with a command such as dd if=/dev/zero of=swapfile bs=1024 count=16384. Then, type mkswap swapfile 16384 to create the swap space. You have to use the command to activate a swap space.