• 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. xeyes: command not found
  2. mknod Command Examples in Linux
  3. Shell/Bash Script to Find Prime Numbers in Linux
  4. How to Run a Script When USB Devices Is Attached or Removed Using UDEV
  5. How to Install apt-utils with apt-get?
  6. How to Set CPU Affinity for SYSTEMD Process in CentOS/RHEL 7
  7. How to Configure Remote Rsyslog To Accept TLS and Non-TLS in CentOS/RHEL
  8. CentOS / RHEL 7 : Booting process
  9. ping: command not found
  10. ufw Command Examples in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • qm Command Examples in Linux
  • qm wait Command Examples in Linux
  • qm start Command Examples in Linux
  • qm snapshot Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright