Resize Swap Space in RHEL/CentOS 6 & 7


Your swap partition might need to resize over time. Below are the steps;

Disable Swap

[root@server ~]# swapoff -v /dev/rootdg/swap
swapoff /dev/rootdg/swap

Resize Swap (resize to 30GB)

[root@server ~]# lvextend -L30G /dev/rootdg/swap
Size of logical volume rootdg/swap changed from 2.00 GiB (64 extents) to 30.00 GiB (960 extents).
Logical volume rootdg/swap successfully resized.

Sets up a Linux Swap Area on a Device

[root@server ~]# mkswap /dev/rootdg/swap
mkswap: /dev/rootdg/swap: warning: wiping old swap signature.
Setting up swapspace version 1, size = 31457276 KiB
no label, UUID=b94fbb5e-3916-4422-b024-4e0efc9424ab

Enable Swap

[root@server ~]# swapon -a

Verify the Swap

[root@server ~]# cat /proc/swaps
Filename	Type		Size		Used	Priority
/dev/dm-1	partition	31457276	0	10



This entry was posted in Linux, RedHat and tagged , , , , , , . Bookmark the permalink.