Increase Existing Swap Partition Using Disk Partition

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

fdisk -l

 resize swap partition

Check Out: How To Clear Cache In Linux

Step 2: Check the overall Swap Partition size before increasing.

free -m

increase swap space

Step 3: Check swap available partition

swapon -s

increase swap space linux

Now Create a disk partition using LVM

fdisk /dev/sdc

swap file parition

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.

how to increase existing swap partition

Check partition created using ‘p‘ and save the configuration with ‘w‘.

Step By Step Increase

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

pvcreate /dev/sdc1

Now create volume group using the /dev/sdc1

vgcreate vg /dev/sdc1

how to create swap partition in linux after installation

Create Logical Volume using the volume group

lvcreate -L +1.5G -n lv vg

how to create swap partition in linux

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. linux swap partition in linux space resize increase

Share on:

I'm the founder of Curious Viral. I hope this blog will provide you complete information about Linux Technology & I would like to share my technical knowledge with you which I have learned during this period.

Other Posts You May Like...

Leave a comment