This document describes process to add additional swap space in RHEL 7.
1.First partition your newly added disk
[root@LinuxAcademy dev]# gdisk /dev/xvdf
GPT fdisk (gdisk) version 0.8.10
Partition table scan:
MBR: not present
BSD: not present
APM: not present
GPT: not present
Creating new GPT entries.
Command (? for help): n
Partition number (1-128, default 1):
First sector (34-41943006, default = 2048) or {+-}size{KMGTP}:
Last sector (2048-41943006, default = 41943006) or {+-}size{KMGTP}:
Current type is ‘Linux filesystem’
Hex code or GUID (L to show codes, Enter = 8300): 8e00
Changed type of partition to ‘Linux LVM’
Command (? for help): w
Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!
Do you want to proceed? (Y/N): y
OK; writing new GUID partition table (GPT) to /dev/xvdf.
The operation has completed successfully.
2.Please create physical volume group and logical volume group.
[root@LinuxAcademy dev]# pvdisplay
[root@LinuxAcademy dev]# vgcreate battlestar /dev/xvdf1
Physical volume “/dev/xvdf1” successfully created
Volume group “battlestar” successfully created
[root@LinuxAcademy dev]# lvcreate -n swap -L 2G battlestar
Logical volume “swap” created.
4.Please create swap file system now.
[root@LinuxAcademy dev]# mkswap /dev/battlestar/swap
mkswap: /dev/battlestar/swap: warning: don’t erase bootbits sectors
on whole disk. Use -f to force.
Setting up swapspace version 1, size = 2097148 KiB
no label, UUID=ffb912cb-a280-41ca-9558-d2cc70447469
swapon /dev/battlestar/swap
5.Please check free memory now
free -m
6.Please add below entry in fstab for auto mount after restart.
vi /etc/fstab
/dev/battlestar/swap swap swap 0 0
7.Check swap space now.
swapon -a
swapon -s