The mkswap command is used to create a swap area on a device or a file. It is a portion of a disk that is used as virtual memory when RAM is full. When system needs more memory then inactive or less frequently accessed memory pages in RAM are moved to swap space.
- About mkswap: To set up a Linux swap area
- It comes from “util-linux-ng-2.17.2” package.
- Configuration Files:
- Path: /sbin/mkswap
Examples:
1. To make the swap
$ mkswap /dev/sdf |
2. To check the device (if it is a block device) for bad blocks
$ mkswap -c /dev/sdf |
3. To Force – go ahead even if the command is stupid.
$ mkswap -f /def/sdf |
4. To Specify the page size to use
$ mkswap -p PAGESIZE |
5. To specify a label, to allow swapon by label
$ mkswap -L LABEL |
6. To specify the swap space version
$ mkswap -v0 $ mkswap -v1 |
7. To specify the UUID to use
$ mkswap -U UUID |
Related Commands: fdisk, swapon
mkswap command not found
When you receive a message that “mkswap command not found”, then you need to check if the “” package is installed or not. Please follow below steps to install the same.
OS Version | Command to install |
RedHat / CentOS | yum instal util-linux |
Debian / Ubuntu | apt install util-linux |