CentOS / RHEL : How to move a Volume Group from one system to another


To move a whole volume group from one system to another, the vgexport and vgimport commands can be used. Below example involves the steps to move a volume group named “data_vg” from one system to another. The logical volume from this volume group is initially mounted at /data01.

1. Un-mount the file system

If required switch to “rescue” mode. Make sure that no users are accessing files on the active volume.

# umount /data01

2. Mark the volume group inactive

Marking the volume group inactive removes it from the kernel and prevents any further activity on it.

 
# vgchange -an data_vg

vgchange -- volume group "data_vg" successfully deactivated

3. Export the volume group

This prevents it from being accessed on the “old” host system and prepares it to be removed.

# vgexport data_vg

vgexport -- volume group "data_vg" successfully exported

4. Un-present the Disk

Once the Disk has been unplugged from the server, it can be shutdown. The Disk can now be presented to the new Server on which VG data_vg has to be discovered.

5. Present the Disk to the new Server

When plugged into the new system it becomes /dev/sdb so an initial pvscan shows as below:

# pvscan 
pvscan -- reading all physical volumes (this may take a while...) 
pvscan -- inactive PV "/dev/sdb1" is in EXPORTED VG "data_vg" [996 MB / 996 MB free] 
pvscan -- inactive PV "/dev/sdb2" is in EXPORTED VG "data_vg" [996 MB / 244 MB free] 
pvscan -- total: 2 [1.95 GB] / in use: 2 [1.95 GB] / in no VG: 0 [0]

6. Import the Volume Group

If importing on an LVM 2 system, run below command:

# vgimport data_vg 

Volume group "data_vg" successfully imported

Else if importing on an LVM system, add the PVs that need to be imported:

# vgimport data_vg /dev/sdb1 /dev/sdb2

vgimport -- doing automatic backup of volume group "data_vg"

vgimport -- volume group "data_vg" successfully imported and activated

7. Activate the volume group

# vgchange -ay data_vg

8. Mount the file system

# mkdir -p /data01
# mount /dev/data_vg/lv_data01 /data01


####

ls /sys/class/scsi_device/ | while read scsidev ; do echo 1 > /sys/class/scsi_device/$scsidev/device/rescan ; done

echo "- - -" > /sys/class/scsi_host/host0/scan*


umount /filesystem

echo "offline" > /sys/block/OLD_DISK/device/state
echo "1" > /sys/block/OLD_DISK/device/delete

vgchange -an vg_group

vgexport vg_group
vgimport vg_group /dev/sde (next disk)

vgchange -ay vg_group

mount /dev/mapper/vg_group_lv /filesystem

cd /filesystem

####




Article Number: 465
Posted: Mon, Jan 28, 2019 3:26 PM
Last Updated: Mon, Jan 28, 2019 3:26 PM

Online URL: http://kb.ictbanking.net/article.php?id=465