How to activate and mount 2 Volume groups with same names in CentOS/RHEL

Question: How to mount a Volume_Group/Logical Volume on a system that already has a volume group/logical volume mounted with the same Volume Group and Logical Volume Name.

Below is the summary of steps to perform to import new volume group with same name as that of already imported VG.

  • Backup the system.
  • Get the relevant volume group uuids from the system.
  • Change the name of the Volume Group.
  • Activate the Logical Volume Group.
  • Mount the Logical Volume and verify data avilability.

Steps to rename the volume group

1. As shown below, there are 2 VGs with same names vg_data. One of them is active and imported.

# vgdisplay | egrep -i "uuid|name"
  VG Name               vg_os
  VG UUID               YCz3rr-h7XO-rXJm-u91J-R52S-4PX7-69Ikql
  VG Name               vg_data    
  VG UUID               IL0a0r-A5cp-LkVZ-106X-bEQX-a9Me-7Nk19z
  VG Name               vg_data    
  VG UUID               QiOPy3-WhF8-RYns-44dY-FKKN-8orV-bEi3m3
# lvs
  LV       VG     Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  lv_root  vg_os  -wi-ao---- 300.00g
  lv_swap  vg_os  -wi-ao---- 256.00g
  lv_data  vg_data -wi-ao---- 200.00g

2. Rename the deported volume group (data_vg) as vg_data_new.

# vgrename -v QiOPy3-WhF8-RYns-44dY-FKKN-8orV-bEi3m3 vg_data_new
Checking for existing volume group "QiOPy3-WhF8-RYns-44dY-FKKN-8orV-bEi3m3"
Checking for new volume group "vg_data_new"
Wiping cache of LVM-capable devices
Archiving volume group "vg_data" metadata (seqno 2).
Renaming "/dev/vg_data" to "/dev/vg_data_new"
Writing out updated volume group
Creating volume group backup "/etc/lvm/backup/vg_data_new" (seqno 3).
Volume group "vg_data" successfully renamed to "vg_data_new"
Wiping cache of LVM-capable devices
Wiping internal VG cache

3. Perform a rescan of VGs and LVs to verify that the new VGs and underlying LVs are identified with new names.

# vgscan
Reading all physical volumes. This may take a while...
Found volume group "data_vg" using metadata type lvm2
Found volume group "data_vg_new" using metadata type lvm2
Found volume group "vg_os" using metadata type lvm2
# lvscan
ACTIVE '/dev/data_vg/lv_data' [200.00 MB] inherit
inactive '/dev/data_vg_new/lv_data' [2.00 GB] inherit
ACTIVE            '/dev/vg_os/lv_swap' [256.00 GiB] inherit
ACTIVE            '/dev/vg_os/lv_root' [300.00 GiB] inherit

4. Activate the LV(s) under the new VG – data_vg_new.

# lvchange -ay /dev/data_vg_new/lv_data

Verify that the volume(s) with new VG name is active.

# lvscan
ACTIVE '/dev/data_vg/lv_data' [200.00 MB] inherit
ACTIVE '/dev/data_vg_new/lv_data' [2.00 GB] inherit
ACTIVE            '/dev/vg_os/lv_swap' [256.00 GiB] inherit
ACTIVE            '/dev/vg_os/lv_root' [300.00 GiB] inherit

5. Mount the volume and check for data availability.

# mkdir /data_new
# mount /dev/data_vg_new/lv_data /data_new
# ls -lrt /data_new
Related Post