How to rename root volume group or logical volume in Red Hat Enterprise Linux?
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.
-
Find downtime, and boot the system into rescue mode. During step 4 select
Skip/Skip to shell. -
Without chrooting rename the existing Volume Group (VG) using
vgrename:
# vgrename oldvg newvg
- Rename the Logical Volume (LV) with
lvrename:
# lvrename /dev/newvg/oldlv /dev/newvg/newlv
-
Once VG and LV names are changed, follow this process to manually build your chroot and
chrootinto/ -
Update
/etc/fstabwith the new VG/LV names for all old VG/LV entries:
/dev/mapper/newvg-newlv / xfs defaults 1 1
- Update
/etc/default/grubwith 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 "
-
Ensure that
/bootor/boot/efiis properly mounted and rebuild initramfs for the newest expected kernel. -
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-cmdlineNote: 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
-
-
If the below error occurs while generating
grubconfiguration 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’.
- Once all the steps above are completed, exit the rescue shell, remove the DVD/ISO, and boot the system normally.
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.