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

####


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
stunnel: Authentication
Viewed 8933 times since Fri, Sep 28, 2018
linux ssh Remotely Initiated Reverse SSH Tunnel
Viewed 2608 times since Wed, Apr 22, 2020
ZPOOL: Create a new zpool for zfs filesystems
Viewed 1799 times since Sun, Jun 3, 2018
15 Linux Yum Command Examples – Install, Uninstall, Update Packages
Viewed 2939 times since Thu, Oct 25, 2018
RHCS6: Luci - the cluster management console
Viewed 2910 times since Sun, Jun 3, 2018
LVM: Create a new Volume Group
Viewed 1803 times since Sat, Jun 2, 2018
Turbocharge PuTTY with 12 Powerful Add-Ons – Software for Geeks #3
Viewed 14197 times since Sun, Sep 30, 2018
YUM CRON RHEL7: Configure automatic updates.
Viewed 1697 times since Fri, Oct 26, 2018
How to manage Linux password expiry with the chage command
Viewed 10908 times since Tue, Sep 11, 2018
ZPOOL: Remove an existing zpool
Viewed 1937 times since Sun, Jun 3, 2018