Solution : How To Create / Remove swap partition in Linux ?
Swap memory is required when system requires more memory than is physically available, the kernel swaps out less used pages and gives memory to the current process that needs the memory immediately.So a page of memory is copied to the preconfigured space on the hard disk. Disk speed are much slower compared to memory speed. Swaping pages gives more space for current application in the memory (RAM) and make application run faster.
In some scenarios system admin need to increase swap space. Below command helps you to expand the existing swap space
Step 1
Check if you have enough space on disk to create new partition for swap
Step 2
Create new partition using tool like fdisk
#fdisk /dev/cciss/c0d0
Make the new partition as swap. Change toggle id to 82 (for swap).
Step 3
Run mkswap command on the newly created swap partition
#mkswap /dev/cciss/c0d0p9
Setting up swapspace version 1, size = 6004416 kB
Step 4
Run swapon commad to enable swap space
#swapon /dev/cciss/c0d0p9
Step 5
Verify the newly added swap space using below commands
#cat /proc/swap
or
#swapon -s
Step 6
Add newly created swap partition to fstab file. It should look as below
/dev/cciss/c0d0p9 swap swap defaults 0 0
Somebody was asking me how to create / remove swap partiton for lvm. Below command helps for that. Assuming swap partiton was created on lvm partition.
Follow the below steps to increase the Swap for LVM
# swapoff -v /dev/rootvg/swapvol
# lvm lvresize /dev/rootvg/swapvol -L +8G (increase from 8 GB to 16 GB)
# mkswap /dev/rootvg/swapvol
# swapon -va
Follow the below steps to delete/ remove the Swap partition for LVM
Step 1
swapoff -v /dev/VolGroup00/LogVol01
Step 2
Then you need to delete the swap partition entirely
#lvremove /dev/VolGroup00/LogVol01
Step 3
Remove the following entry from your /etc/fstab file.
/dev/VolGroup00/LogVol01 swap swap defaults 0 0
Category: Linux Administration


Zach ,
Thanks for the info. I was looking swap partition on LVM and info you have provided was useful to me. Keep posting.