LVM: Reduce SWAP size by removing a Logical Volume

LVM: Reduce SWAP size by removing a Logical Volume

# Tested on RHEL 5, 6 & 7

# Check current swap volume(s) and its size

root@<server>:/#> cat /etc/fstab | grep swap
/dev/rvg/swaplv         swap                    swap    defaults        0 0
/dev/rvg/newswaplv      swap                    swap    defaults        0 0


root@<server>:/#> free -m
             total       used       free     shared    buffers     cached
Mem:         11239        392      10846          0        102        120
-/+ buffers/cache:        169      11069
Swap:        15039          0      15039                                       <----


root@<server>:/#> cat /proc/swaps
Filename                                Type            Size    Used    Priority
/dev/mapper/rvg-swaplv                  partition       14352376        0       -1
/dev/mapper/rvg-newswaplv               partition       1048568 0       -2




# We will reduce swap space by removing /dev/mapper/rvg-newswaplv Logical Volume

# Disable swapping on selected LV

root@<server>:/#> swapoff /dev/rvg/newswaplv



# Check new size and partitions being used by swap

root@<server>:/#> free
             total       used       free     shared    buffers     cached
Mem:      11508864     401412   11107452          0     104992     123432
-/+ buffers/cache:     172988   11335876
Swap:     14352376          0   14352376                                       <----


root@<server>:/#> cat /proc/swaps
Filename                                Type            Size       Used    Priority
/dev/mapper/rvg-swaplv                  partition       14352376        0       -1



# Remove following line from /etc/fstab to prevent system from mounting removed LV

/dev/rvg/newswaplv         swap                    swap    defaults        0 0



# If necessary, completely remove Logical Volume

# root@<server>:/#> lvremove /dev/rvg/newswaplv
# Do you really want to remove active logical volume newswaplv? [y/n]: y
# Logical volume "newswaplv" successfully removed
0 (0)
Article Rating (No Votes)
Rate this article
Attachments
There are no attachments for this article.
Comments
There are no comments for this article. Be the first to post a comment.
Full Name
Email Address
Security Code Security Code
Related Articles RSS Feed
RHCS6: Create a new Logical Volume / Global Filesystem 2 (GFS2)
Viewed 2154 times since Sun, Jun 3, 2018
Red Hat 8 How to Set Up Automatic Updates for CentOS 8
Viewed 3587 times since Fri, Sep 25, 2020
UUIDs and Linux: Everything you ever need to know [Update]
Viewed 4867 times since Tue, Jul 17, 2018
CentOS / RHEL 7 : Configuring an NFS server and NFS client Linux NFS
Viewed 16287 times since Fri, Feb 21, 2020
Installing and Configuring an OCFS2 Clustered File System
Viewed 5775 times since Sat, Jun 2, 2018
An easier way to manage disk decryption at boot with Red Hat Enterprise Linux 7.5 using NBDE
Viewed 7366 times since Mon, Aug 6, 2018
RHCS: Configure an active/backup pacemaker cluster
Viewed 8871 times since Sun, Jun 3, 2018
linux aix Killing a process and all of its descendants
Viewed 3666 times since Tue, May 5, 2020
HowTo: The Ultimate Logrotate Command Tutorial with 10 Examples
Viewed 5034 times since Fri, Nov 30, 2018
ubuntu How to reset lost root password on Ubuntu 16.04 Xenial Xerus Linux
Viewed 8156 times since Tue, Dec 8, 2020