• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

CentOS / RHEL : How to create new LVM based swap partition

by admin

Let see an example of increasing existing swap space by adding new LVM based swap. The example here uses the disk /dev/sdc for creating a new volume group and swap volume under it. Since we are going to use this disk, any data, if exists on it, will be lost.

As root user perform the following tasks:
1. Add the disk /dev/sdc as the physical volume.

# pvcreate /dev/sdc

2. Create volume group named ‘swap_vg’ ( You may add the disk in an existing volume group if you have one. In the example here, I am creating a new volume group.)

# vgcreate swap_vg /dev/sdc

3. To create logical volume of size 20Gb, use below command.

# lvcreate -L 20G -n lvswap swap_vg

4. Formatting the device with the SWAP format.

# mkswap /dev/swap_vg/lvswap

5. Enable the extended logical volume swap.

# swapon -v /dev/swap_vg/lvswap

6. Add the following entry to the /etc/fstab file.

/dev/swap_vg/lvswap swap swap defaults 0 0

7. Verify the Swap space by ‘free’ command or ‘cat /proc/swaps’ command :

# free
# cat /proc/swaps

Filed Under: Linux

Some more articles you might also be interested in …

  1. Command ntpstat Shows unsynchronised (CentOS/RHEL)
  2. lvcreate/lvremove Failed with Error “Can’t remove merging snapshot logical volume”
  3. locate Command Examples in Linux
  4. How To Create/Remove and Mount a Stratis Filesystem in CentOS/RHEL 8
  5. How to find which specific ethernet device corresponds to a specific port on a multi-interface network card in CentOS/RHEL
  6. How to install/remove/query/update RPM packages in Linux (Cheat Sheet)
  7. Features of the “Btrfs” Filesystem
  8. How to Limit some User Memory Resources on CentOS/RHEL using cgroup
  9. jpegtran for image optimization
  10. CentOS/RHEL – vgs command reports error: “global/global_filter” unknown

You May Also Like

Primary Sidebar

Recent Posts

  • What are /dev/zero and /dev/null files in Linux
  • grpck command – Remove corrupt or duplicate entries in the /etc/group and /etc/gshadow files.
  • xxd command – Expressed in hexadecimal form
  • sesearch: command not found

© 2022 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright