Forrest logo
tool overview
On this page you find all important commands for the CLI tool mkswap. If the command you are looking for is missing please ask our AI.

mkswap

The "mkswap" command line tool is used in Linux and Unix systems to create a swap space. A swap space is a portion of a hard disk that is used as virtual memory when the physical memory (RAM) of a computer is full.

By utilizing "mkswap," you can initialize a block device or a regular file to be used as swap space. Typically, block devices like hard drives or solid-state drives are used for swap space, but any regular file can also be employed.

This tool formats the specified block device or file as a swap area, preparing it for use within the system. The command assigns a label or UUID (Universally Unique Identifier) to the swap space, which is used for identification.

Once the swap space is created using "mkswap," it can be activated using the "swapon" command, making it available for system use. Additionally, the "swapoff" command is used to disable and remove the swap space if it is no longer needed.

The "mkswap" command offers various options, such as specifying the version of the swap format, setting the label or UUID, or displaying detailed information about the swap space. It is an essential tool for managing virtual memory in Linux and Unix systems, allowing efficient memory management and preventing system crashes due to excessive memory usage.

List of commands for mkswap:

  • mkswap:tldr:3f73c mkswap: Check a partition for bad blocks before creating the swap area.
    $ sudo mkswap -c ${-dev-sdb7}
    try on your machine
    explain this command
  • mkswap:tldr:45dc6 mkswap: Setup a given partition as swap area.
    $ sudo mkswap ${-dev-sdb7}
    try on your machine
    explain this command
  • mkswap:tldr:7b68d mkswap: Specify a label for the file (to allow `swapon` to use the label).
    $ sudo mkswap -L ${swap1} ${filename}
    try on your machine
    explain this command
tool overview