Increase Existing Swap Partition is basically used for increasing the Server performance when it’s running out of memory. This should be more than half of the RAM available on the machine. We can increase and resize swap partition space in Linux.
Increase Existing Swap Partition Using Disk Partition:
Swap Partition helps us to improve our Server Performance when you’re not able to upgrade the RAM physically. We can increase the Swap Partition using the Disk Space available on the machine.
Check Out: How To Disable Selinux In Linux
You have options here:
1. Create a new swap partition
2. Create a new swap file
3. Extend swap on an existing LVM2 logical volume.
It is recommended that you extend an existing logical volume.
Step 1: Check
I have added the extra 2gb size of disk /dev/sdc
Check Out: How To Clear Cache In Linux
Step 2: Check the overall Swap Partition size before increasing.
Step 3: Check swap available partition
Now Create a disk partition using LVM
Check Out: GET Command Not Found In Linux
Enter ‘n‘ to create a new partition. I will use the full 2 GB to create a disk partition for Swap memory.
Check partition created using ‘p‘ and save the configuration with ‘w‘.
we have created a disk partition for Swap and Now we will create an lvm partition for the same.
Step 4: I’m increasing Swap Memory size using LVM partition. You can simply increase it by creating a disk.
Check Out: Install Memcached In Linux
First, we will create a physical volume using /dev/sdc1
Now create volume group using the /dev/sdc1
vgcreate vg /dev/sdc1
Create Logical Volume using the volume group
lvcreate -L +1.5G -n lv vg
After created lvm partition for swap, run the below command
Check Out: Mount ISO Image Linux In Vmware
Step 5: Now Make swap partition using below command
You need to apply it on Swap
Now verify the Swap partition will be increased.
Step 6: Finally make an entry in vim /etc/fstab to make it permanent.
/dev/mapper/vg-lv swap swap defaults 0 0
You’re done. linux swap partition in linux space resize increase