swapon Command
swapon –show
Check /proc/swaps File
cat /proc/swaps
How to Create a Swap Partition
1. Run the fdisk command for the disk you want to partition:
sudo fdisk [disk_path]
Replace [disk_path] with your disk identifier.
2. Type p and press Enter for an overview of the disk.
The output provides information about the available disk space for a new partition. If the last partition ends before the last sector of the hard drive, there is enough space to create a new partition. The output above shows the entire disk space is available for creating a new partition.
3. Type n and press Enter to create a new partition. For partition type, enter p and press Enter.
4. Set the partition number (or keep the default number 1) and press Enter to confirm.
5. Enter the first available sector for the new partition and press Enter. You can also keep the default one offered.
6. Set the last available sector for the partition. You can specify the partition size in KiB, MiB, or GiB units. We will create a swap partition of 1GiB, so the command is:
+1G
7. Press p to verify the partition creation and confirm with Enter.
8. By default, the partition type is 83, while 82 is a partition type identifier for swap space.
Type t and press Enter to change the partition type. Change the value to 82 and press Enter.
9. Verify the change with p and confirm with Enter.
10. fdisk doesn’t make any changes to the disk before confirmation. To proceed with the changes, type w, and press Enter.