- Create new partition using
fdisk /dev/sda
with neededswap
size - Change change partition type as LVM by partition code
8e
usingt
option infdisk
- Save changes using
w
option - Reboot CentOS7
- Create PV using
pvcreate /dev/sdaX
. 'X' will be newly created partition number. - Get VG name using
vgdisplay
- Extend VG size using
vgextend centos /dev/sdaX
- After extending VG size create Logical Volume using
lvcreate centos -n swap -L 4G
. Here, 'centos' in VG name and 'swap' is LV name mkswap /dev/centos/swap
. Here, '/dev/centos/swap' is LV path- Add swap partition details in
vim /etc/fstab
/dev/centos/swap swap swap defaults 0 0
- Execut
swapon -va
- Check swap size using
free -h
command.