chaning swap space on linux

Chang, Hee Sung
Oct 20, 2020
  1. adding new disk space or resizing swap partition
  2. swap off

[root@testsvr ~]# swapon — show

NAME TYPE SIZE USED PRIO

/dev/sdb1 partition 16G 0B -1

[root@testsvr ~]# swapoff /dev/sdb1

[root@testsvr ~]# swapon — show

[root@testsvr ~]#

3. creating new swap partition

[root@testsvr ~]# fdisk /dev/sdb

Command (m for help): p

Command (m for help): d

Selected partition 1

Partition 1 is deleted

Command (m for help): p

Command (m for help): n

Command (m for help): t

Selected partition 1

Hex code (type L to list all codes): 82

Changed type of partition ‘Linux’ to ‘Linux swap / Solaris’

Command (m for help): w

4. creating new swap on linux os

[root@testsvr ~]# mkswap /dev/sdb1

mkswap: /dev/sdb1: warning: wiping old swap signature.

Setting up swapspace version 1, size = 33553404 KiB

no label, UUID=c81510a8-b78a-449e-a214-ee5b46ccec23

5. activating and checking new swap

[root@testsvr ~]# swapon /dev/sdb1

[root@testsvr ~]# swapon — show

NAME TYPE SIZE USED PRIO

/dev/sdb1 partition 32G 0B -1

6. changing /etc/fstab (new UUID)

[root@testsvr ~]# ls -l /dev/disk/by-uuid/

lrwxrwxrwx. 1 root root 10 Jan 29 2020 c81510a8-b78a-449e-a214-ee5b46ccec23 -> ../../sdb1

[root@testsvr ~]# vi /etc/fstab

UUID=c81510a8-b78a-449e-a214-ee5b46ccec23 swap swap defaults 0 0

7. reboot and checking swap status

[root@testsvr ~]# swapon --show

NAME TYPE SIZE USED PRIO

/dev/sdb1 partition 32G 0B -1

--

--