The mkswap command is used to create swap space on a storage partition. It is typically used when you wish to move swap space to a different partition than the one that was created during system installation. For example, you might want to save space on a low-capacity boot drive.

It provides options to perform various tasks.

Option Used To
-c Verify that the device is free from bad sectors before mounting the swap space.
-p Set the page size to be used by the mkswap command. A page is a chunk of memory that is copied to the storage device during the swap process.
-L {label} Activate the swap space using labels applied to partitions or file systems.

mkswap Command Examples

1. To make the swap:

2. To check the device (if it is a block device) for bad blocks:

3. To Force – go ahead even if the command is stupid:

4. To Specify the page size to use:

5. To specify a label, to allow swapon by label:

6. To specify the swap space version:

# mkswap -v0
# mkswap -v1 

7. To specify the UUID to use: