unix

How do I rename an LVM logical volume on my Linux server?

To rename a logical volume, you can perform the following steps:

In this example we will rename APPS to TOMCAT.

1. First list the LVs on your server
# /sbin/lvs

The resulting output will look like this:

LV VG Attr LSize Origin Snap% Move Log Copy% Convert
APPS VGROOT -wi-ao 100.00g
ROOT VGROOT -wi-ao 10.00g
TMP VGROOT -wi-ao 10.00g
VAR VGROOT -wi-ao 10.00g

2. Next find out where the LV is mounted using the df command.
# df -h

/dev/mapper/VGROOT-APPS
100G 200M 100G 1% /apps

3. Ensure that the filesystem is not in use (lsof /apps) and then unmount it.
# umount /apps

4. Rename APPS TOMCAT
# lvrename APPS TOMCAT

You will get a response back like this:

Renamed “APPS” to “TOMCAT” in volume group “VGROOT”

5. Run lvs to confirm that the LV has been renamed.
# lvs

5. Remount the filesystem
# mount /dev/VGROOT/TOMCAT /apps

6. Check the filesystem to ensure it’s mounted properly
# df -h /apps

7. Update the /etc/fstab to reflect the new LV name.
/dev/mapper/VGROOT-TOMCAT /apps ext4 defaults 0 0

Click to comment

Leave a Reply

Your email address will not be published. Required fields are marked *

To Top