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
CONFIGURE FOR ASM Linux
Viewed 5207 times since Sat, Jun 2, 2018
logrotate How log rotation works with logrotate
Viewed 8575 times since Sun, Jan 12, 2020
Używanie rsync poprzez Secure Shell
Viewed 40469 times since Thu, May 24, 2018
Linux LVM recovery
Viewed 17081 times since Wed, Jan 23, 2019
stunnel Howto A Guide to create SSL access to a HTTP-only webserver with stunnel
Viewed 2415 times since Fri, Sep 28, 2018
How to Migrate from RHEL 8 to CentOS 8
Viewed 2383 times since Fri, May 15, 2020
debian Debian/Ubuntu Linux: Find If Installed APT Package Includes a Fix/Patch Via CVE Number
Viewed 9163 times since Sun, Sep 23, 2018
Linux Audit The Linux security blog about Auditing, Hardening, and Compliance lynis
Viewed 1760 times since Thu, Jan 16, 2020
How To: Linux Hard Disk Encryption With LUKS [ cryptsetup Command ]
Viewed 7016 times since Fri, Jul 13, 2018
LVM: Recovering Physical Volume Metadata
Viewed 12844 times since Sat, Jun 2, 2018