How to rename root volume group or logical volume in Red Hat Enterprise Linux?

Solution Verified - Updated

Environment

  • Red Hat Enterprise Linux (RHEL) 7
  • Red Hat Enterprise Linux (RHEL) 8
  • Red Hat Enterprise Linux (RHEL) 9
  • Red Hat Enterprise Linux (RHEL) 10
  • Logical Volume Manager (LVM)

Issue

  • How to rename root Volume Group or Logical Volume in Red Hat Enterprise Linux?

Resolution

  NOTE    Make sure you have a proper, healthy backup of needed/important data before proceeding. Caution! Understand that this process DOES require downtime, as we will need to power-down and boot to rescue mode using a RHEL DVD/ISO in order to safely make this change.
  1. Find downtime, and boot the system into rescue mode. During step 4 select Skip/Skip to shell.

  2. Without chrooting rename the existing Volume Group (VG) using vgrename:

# vgrename oldvg newvg
  1. Rename the Logical Volume (LV) with lvrename:
# lvrename /dev/newvg/oldlv /dev/newvg/newlv
  1. Once VG and LV names are changed, follow this process to manually build your chroot and chroot into /

  2. Update /etc/fstab with the new VG/LV names for all old VG/LV entries:

/dev/mapper/newvg-newlv  /  xfs  defaults  1  1
  1. Update /etc/default/grub with the new VG/LV names for all old VG/LV entries:
  # vi /etc/default/grub

  GRUB_CMDLINE_LINUX="rd.lvm.lv=newvg/newlv rd.lvm.lv=newvg/newlv1 crashkernel=auto  vconsole.font=latarcyrheb-sun16 vconsole.keymap=us "
  1. Ensure that /boot or /boot/efi is properly mounted and rebuild initramfs for the newest expected kernel.

  2. Take a backup and update-grub with the new VG and LV names:

    • For RHEL9 release:

            # cp /boot/grub2/grub.cfg /boot/grub2/grub.cfg.bak
      
            # grub2-mkconfig -o /boot/grub2/grub.cfg --update-bls-cmdline
      

      Note: Since RHEL9.3, the default behavior of grub2-mkconfig is changed. Refer to Change in the default behavior of grub2-mkconfig.

    • For RHEL7 and RHEL8 releases on BIOS-based machines:

            # cp /boot/grub2/grub.cfg /boot/grub2/grub.cfg.bak
      
            # grub2-mkconfig -o /boot/grub2/grub.cfg
      
    • For RHEL7 and RHEL8 releases on UEFI-based machines:

      # cp /boot/efi/EFI/redhat/grub.cfg /boot/efi/EFI/redhat/grub.cfg.bak
      
      # grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg
      
  3. If the below error occurs while generating grub configuration file, please refer to After renaming LVM volume group, receiving "/usr/sbin/grub2-probe: error: failed to get canonical path".

/usr/sbin/grub2-probe: error: failed to get canonical path of ‘/dev/mapper/rhelnew1-root’.
  1. Once all the steps above are completed, exit the rescue shell, remove the DVD/ISO, and boot the system normally.
Components
Category

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.