Swap
Contents
Usage
Turn off swap
swapoff --all --verbose
Turn of swap
swapon --all --verbose
Create a swap partition
see fdisk
Enable swap partion
Check that the swap is not used yet
free -m
Set up a swap area. In this case for the create swap partition sda2. Use fdisk -l
to list all partitions and find the right one.
mkswap /dev/sda2
swapon /dev/sda2
Save the UUID the command outputs or use blkid
to print the UUIDs of all partitions. Add in the file /etc/fstab the line
# <file system> <mount point> <type> <options> <dump> ::<pass>
UUID=<uuid> none swap sw 0 0
Check usage status
Check swap is used
$ swapon --show
NAME TYPE SIZE USED PRIO
/dev/sdb3 partition 20G 0B -1
$ cat /proc/swaps
Filename Type Size Used Priority
/dev/sa2 partition 681574 0 -1
Tips
Switch swap partion
- Create a new swap partition and enable it
- Turn off the swap
- Delete the entry of the old swap partiton from /etc/fstab and delete the old swap partition
- Enable the swap