The mkswap command converts a file or partition into a swap area. The syntax is mkswap [OPTIONS] [DEVICE|FILE] [SIZE].
Option explanations:# mkswap /dev/sdb2 ←Convert a partition to swap # # dd if=/dev/zero of=/mnt/512MiB_swap bs=512M count=1 ←Create a 512M file using dd # mkswap /mnt/512MiB_swap ←Convert the file to swap Setting up swapspace version 1, size = 524284 KiB no label, UUID=a1b69b66-0822-4fb7-b345-6bca7f7d2e5b # file /mnt/512MiB_swap ←Verify if the file is formatted as a swap file /mnt/512MiB_swap: Linux/i386 swap file (new style), version 1 (4K pages), size 131071 pages, no label, UUID=a1b69b66-0822-4fb7-b345-6bca7f7d2e5b |
For more examples and explanations of mkswap operations, you can refer to the provided link.