Install Mkswap On A Debian, Ubuntu, Alpine, Arch, Kali, CentOS, Fedora, Raspbian And MacOS

Install Mkswap On A Debian, Ubuntu, Alpine, Arch, Kali, CentOS, Fedora, Raspbian And MacOS

mkswap

Sets up a Linux swap area on a device or in a file.

Maintainer: LaMont Jones


Section: utils

Install mkswap

  • Debian apt-get install util-linux Click to copy
  • Ubuntu apt-get install util-linux Click to copy
  • Alpine OS apk add util-linux Click to copy
  • Arch Linux pacman -S util-linux Click to copy
  • Kali Linux apt-get install util-linux Click to copy
  • CentOS yum install util-linux Click to copy
  • Fedora dnf install util-linux Click to copy
  • Raspbian apt-get install util-linux Click to copy
  • macOS brew install util-linux Click to copy

Sets up a Linux swap area on a device or in a file.

How to use mkswap?

Below are few example commands for mkswap that you can use in the terminal.

Setup a given partition as swap area:
sudo mkswap /dev/sdb7Click to copy
Use a given file as swap area:
sudo mkswap path/to/fileClick to copy
Check a partition for bad blocks before creating the swap area:
sudo mkswap -c /dev/sdb7Click to copy
Specify a label for the file (to allow `swapon` to use the label):
sudo mkswap -L swap1 path/to/fileClick to copy
To install the latest version of mkswap in your favorite operating system just copy the mkswap installation command from above and paste it into terminal. It will download and install the latest version of mkswap 2026 package in your OS.