LVM: Rename root VG/LV

LVM: Rename root VG/LV

# Tested on RHEL 6 & 7

# Carry out planned modifications: renaming the existing Volume Group and/or renaming
# the Logical Volume(s). I just wanted to change the name of all LVs belonging to rootvg:

  LV   VG     Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  home rootvg -wi-ao---- 512.00m
  opt  rootvg -wi-ao----   1.00g
  root rootvg -wi-ao----   1.00g
  swap rootvg -wi-ao----   1.00g
  tmp  rootvg -wi-ao----   1.00g
  usr  rootvg -wi-ao----   1.00g
  var  rootvg -wi-ao----   1.00g

lvrename /dev/rootvg/home  lv_home
lvrename /dev/rootvg/opt lv_opt
lvrename /dev/rootvg/usr  lv_usr
lvrename /dev/rootvg/var  lv_var

# Update /etc/fstab with the new names

vi /etc/fstab

   /dev/mapper/rootvg-lv_root                  /       ext4   defaults   1 1
   /dev/mapper/rootvg-lv_swap                  swap    swap   defaults   0 0

# and then...

# RHEL 6 -----------------------------------------------------------------------------------

# Update VG/LV names in /boot/grub/grub.conf

vi /boot/grub/grub.conf
   kernel /vmlinuz-2.6.32-358.el6.i686 ro root=/dev/mapper/rootvg-lv_root rd_NO_LUKS [...]

shutdown -r now

# RHEL 7 -----------------------------------------------------------------------------------

# Update VG/LV names in /etc/default/grub

vi /etc/default/grub
   GRUB_CMDLINE_LINUX="crashkernel=auto rhgb quiet"

# Then reboot the system to rescue mode (I used a RHEL 7 rescue cd, option "find Linux
# installation and mount under /mnt/sysimage") and rebuild grub2 using following procedure:

# vgchange -ay rootvg
# mount /dev/sda1 /mnt/sysimage/boot
# mount /dev/rootvg/lv_usr /mnt/sysimage/usr

chroot /mnt/sysimage
grub2-mkconfig -o /boot/grub2/grub2.cfg

shutdown -r now
0 (0)
Article Rating (No Votes)
Rate this article
There are no attachments for this article.
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
Linux - How to get network speed and statistic of ethernet adapter in Linux
Viewed 908 times since Fri, Jun 8, 2018
Secure Remote Logging to Central Log Server Using RSYSLOG on CentOS 6 / CentOS 7 and stunnel
Viewed 1117 times since Sun, Dec 6, 2020
RHEL: iSCSI target/initiator configuration on RHEL6
Viewed 5937 times since Sat, Jun 2, 2018
Get UUID of Hard Disks [Update]
Viewed 1179 times since Tue, Jul 17, 2018
RHCS: Install a two-node basic cluster
Viewed 7824 times since Sun, Jun 3, 2018
RHEL : How to deal with “CLOSE_WAIT” and “TIME_WAIT” connection
Viewed 14007 times since Thu, Feb 14, 2019
RHCS6: ’fencing’ basics
Viewed 1186 times since Sun, Jun 3, 2018
Linux Screen
Viewed 1135 times since Sat, Jun 2, 2018
ZPOOL: Create a new zpool for zfs filesystems
Viewed 1122 times since Sun, Jun 3, 2018
debian How to check Debian CVE status using python script
Viewed 1187 times since Sun, Sep 23, 2018