In my previous article I show you how you can safely remove your swap on Linux. As you know Swap is used when the amount of Random Access Memory (RAM) is full. Swap space is a portion of a hard disk drive (HDD) that is used for virtual memory.
In this article I will show you how to create Logical Volume (LV) for swap.
Create Logical Volume for Swap
Follow the below steps to create logical volume for swap.
1. First of all create the logical volume called “swap”
# lvcreate vg1 -n swap -L 6G
2. Format the new swap space.
# mkswap /dev/vg1/swap
3. Edit your /etc/fstab file and add the following entry.
# vim /etc/fstab /dev/vg1/swap swap swap defaults 0 0
4. Now enable the swap using below command.
# swapon -va
Swap successfully created.