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
There are no attachments for this article.
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
LVM: Rename root VG/LV
Viewed 971 times since Sat, Jun 2, 2018
RHEL: Adding a boot entry to GRUB/GRUB2 configuration
Viewed 1035 times since Sun, May 27, 2018
Top 25 Best Linux Performance Monitoring and Debugging Tools
Viewed 1839 times since Sun, Sep 30, 2018
Top 10 darmowych i publicznych serwerów DNS
Viewed 828 times since Tue, May 22, 2018
OpenSSL: Check SSL Certificate Expiration Date and More
Viewed 568 times since Mon, Feb 18, 2019
10 Linux DIG Command Examples for DNS Lookup
Viewed 395 times since Sun, Sep 30, 2018
How to encrypt a partition with DM-Crypt LUKS on Linux
Viewed 522 times since Fri, Jul 13, 2018
RHEL: iSCSI target/initiator configuration on RHEL6
Viewed 995 times since Sat, Jun 2, 2018
RHEL: Resize/disable /dev/shm filesystem
Viewed 1063 times since Sun, May 27, 2018
How to Synchronize Directories Using Lsyncd in Linux
Viewed 1023 times since Wed, Oct 31, 2018