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
How to Register and Enable Red Hat Subscription, Repositories and Updates for RHEL 7.0 Server
Viewed 12098 times since Mon, Oct 29, 2018
Easily Monitor CPU Utilization in Linux Terminal With Stress Terminal UI
Viewed 3979 times since Thu, Apr 18, 2019
Easily Find Bugs In Shell Scripts With ShellCheck
Viewed 3268 times since Thu, Apr 18, 2019
RHCS6: Install a two-node basic cluster
Viewed 3361 times since Sun, Jun 3, 2018
How To Use Systemctl to Manage Systemd Services and Units
Viewed 7391 times since Mon, Dec 7, 2020
How setting the TZ environment variable avoids thousands of system calls
Viewed 9931 times since Mon, May 21, 2018
ZPOOL: Detach a submirror from a mirrored zpool
Viewed 2621 times since Sun, Jun 3, 2018
RHCS6: Clustered LVM
Viewed 2180 times since Sun, Jun 3, 2018
How to Configure ‘FirewallD’ in RHEL/CentOS 7 and Fedora 21
Viewed 10351 times since Wed, Oct 9, 2019
RHEL: Retrieve and generate a unique SCSI identifier
Viewed 3003 times since Sat, Jun 2, 2018