Swap Partition increase centos

Step By Step Increase Existing Swap Partition Using Disk Partition

Step By Step Increase Swap Partition is basically used for increasing the Server performance when it’s running out of memory. This should be more than half of RAM available on the machine.

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

fdisk -l

Check Out : How To Clear Cache In Linux

Step 2 : Check overall Swap Partition size before increasing.

free -m

Step 3 : Check swap available partition

swapon -s

Now Create a disk partition using LVM

fdisk /dev/sdc

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 a 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 physical volume using /dev/sdc1

pvcreate /dev/sdc1

Now create volume group using the /dev/sdc1

vgcreate vg /dev/sdc1

Create Logical Volume using 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

partprobe /dev/sdc

Step 5 : Now Make swap partition using below command

mkswap /dev/mapper/vg-lv

You need to apply it on Swap

swapon /dev/mapper/vg-lv

Now verify the Swap partition will be increased.

free -m

Check Out : How To Install New Relic Infrastructure Agent In Linux

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.

Sponsored

LEAVE A REPLY

Please enter your comment!
Please enter your name here

seven − 7 =