Moving a whole volume group from one system to another can be achieved using the
vgimport commands in LVM2. This guide provides an example of how to move a volume group named “vmbsVG” from one system to another. Please note that the steps outlined here have been tested on CentOS.
Note: Ensure that no users are accessing files on the active volume before proceeding with the following steps.
Unmount the file system:
If required, switch to rescue mode and unmount the file system mounted at
Mark the volume group inactive:
Marking the volume group as inactive removes it from the kernel and prevents any further activity.
vgchange -an vmbsVG
vgchange -- volume group "vmbsVG" successfully deactivated
Export the volume group:
Exporting the volume group prevents it from being accessed on the “old” host system and prepares it to be removed.
vgexport -- volume group "vmbsVG" successfully exported
Unplug the disk from the old server:
Once the disk has been unplugged, you can shut down the old server. The disk will be presented to the new server where the volume group “vmbsVG” needs to be discovered.
Note: The following steps may vary depending on the server or virtualization platform being used.
Present the disk to the new server:
When the disk is plugged into the new system, it will be assigned a device name like
/dev/sdx. Use the following command to scan for physical volumes:
pvscan -- reading all physical volumes (this may take a while...) pvscan -- inactive PV "/dev/sdx1" is in EXPORTED VG "vmbsVG" [335 MB / 335 MB free] pvscan -- inactive PV "/dev/sdx2" is in EXPORTED VG "vmbsVG" [335 MB / 335 MB free] pvscan -- total: 2 [2.35 GB] / in use: 2 [2.35 GB] / in no VG: 0 
Import the volume group:
If importing on an LVM2 system, use the following command:
Volume group "vmbsVG" successfully imported
If importing on an LVM system, specify the physical volumes (
/dev/sdx2) to be imported:
vgimport vmbsVG /dev/sdx1 /dev/sdx2
vgimport -- doing automatic backup of volume group "vmbsVG" vgimport -- volume group "vmbsVG" successfully imported and activated
Activate the volume group:
Activate the imported volume group using the following command:
vgchange -ay vmbsVG
Mount the file system:
Create a mount point and mount the logical volume from the volume group to the desired location,
/vmbs1in this example:
mkdir -p /vmbs1 mount /dev/vmbsVG/lv_vmbs1 /vmbs1
Don’t forget to add the appropriate entry in the `/etc/f
stab` file to mount the file system automatically on boot.
For more information and detailed instructions, refer to the source documentation from Red Hat: Moving a Volume Group from One System to Another