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

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • VCS
  • Interview Questions
  • Database
    • 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. export Command Examples in Linux
  2. jupytext Command Examples
  3. “git-grep” Command Examples
  4. mount.cifs: command not found
  5. ntpq Command Examples in Linux
  6. dnsrecon: command not found
  7. pvck Command Examples in Linux
  8. “glab mr merge” Command Examples
  9. Difference between the Java heap and native C heap
  10. vim: command not found

You May Also Like

Primary Sidebar

Recent Posts

  • Vanilla OS 2 Released: A New Era for Linux Enthusiasts
  • mk Command Examples
  • mixxx Command Examples
  • mix Command Examples

© 2025 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright