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:

lvs
  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 rd.lvm.lv=rootvg/lv_root rd.lvm.lv=rootvg/lv_swap rd.lvm.lv=rootvg/lv_usr 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


exit
shutdown -r now
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
ZFS: Snapshots and clones on zfs filesystems
Viewed 3004 times since Sun, Jun 3, 2018
How to manage Linux password expiry with the chage command
Viewed 11116 times since Tue, Sep 11, 2018
Find All Large Files On A Linux System
Viewed 2073 times since Mon, Oct 29, 2018
RHEL: How to rebuild and/or patch a RPM package
Viewed 8537 times since Sat, Jun 2, 2018
Szybkie sprawdzenie zewnętrznego adresu IP i hosta
Viewed 3291 times since Thu, May 24, 2018
How To: Linux Hard Disk Encryption With LUKS [ cryptsetup Command ]
Viewed 7239 times since Fri, Jul 13, 2018
RHCS6: Create a new Logical Volume / Global Filesystem 2 (GFS2)
Viewed 2155 times since Sun, Jun 3, 2018
RHEL: Crash kernel dumps configuration and analysis on RHEL 7
Viewed 6988 times since Sat, Jun 2, 2018
IPTABLES linux
Viewed 16933 times since Sat, Jun 2, 2018
How setting the TZ environment variable avoids thousands of system calls
Viewed 9903 times since Mon, May 21, 2018