How do I move a Volume Group from one system to another?

Solution Verified - Updated -

Environment

  • Red Hat Enterprise Linux
  • LVM

Issue

  • How do I move a Volume Group from one system to another?

Resolution

To move a whole volume group from one system to a new system, the vgexport and vgimport commands can be used.

Note: These steps are only for the local disk, not for the Directl Lun mapped to the system.

When vgexport or vgimport is used, it is not necessary to move drives from one system to another. It is an administrative policy tool to prevent access to volumes while moving them to another system.

In this example we will run through the steps to move a volume group named design from one system to another. A logical volume from this volume group is initially mounted at /mnt/design/users:

  1. Umount the file system ( If required make use of "rescue" mode ). Make sure that no users are accessing files on the active volume.

    # umount /mnt/design/users
    
  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 design
     vgchange -- volume group "design" 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 design
     vgexport -- volume group "design" successfully exported
    
  4. When the machine is shut down, the disk can be unplugged and then connected to it's new machine.

  5. When plugged into the new system it becomes /dev/sdb so an initial pvscan shows:

    # pvscan
    pvscan -- reading all physical volumes (this may take a while...)
    pvscan -- inactive PV "/dev/sdb1"  is in EXPORTED VG "design" [996 MB / 996 MB free]
    pvscan -- inactive PV "/dev/sdb2"  is in EXPORTED VG "design" [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:
    # vgimport design
    Volume group "design" successfully imported
    
    • If importing on an LVM 1 system, add the PVs that need to be imported:
    # vgimport design /dev/sdb1 /dev/sdb2
    vgimport -- doing automatic backup of volume group "design"
    vgimport -- volume group "design" successfully imported and activated
    
  7. Activate the volume group.

    # vgchange -ay design
    
  8. Mount the file system.

    # mkdir -p /mnt/design/users
    # mount /dev/design/users /mnt/design/users
    

To make the change persistent after a system reboot put the entry below in /etc/fstab file:

/dev/design/users /mnt/design/users ext3 defaults 0 0

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

6 Comments

[root@tceq-sap-racd04 opt]# pvs
connect() failed on local socket: Connection refused
Internal cluster locking initialisation failed.
WARNING: Falling back to local file-based locking.
Volume Groups with the clustered attribute will be inaccessible.
PV VG Fmt Attr PSize PFre e
/dev/mpath/360050768018e026ce80000000000015e VolGroup01 lvm2 a-- 85.00G 1012 .00M
/dev/mpath/360050768018e026ce800000000000163 VolGroup01 lvm2 a-- 150.00G 4 .00M
/dev/mpath/360050768018e026ce800000000000164 lvm2 a-- 350.00G 350 .00G
/dev/mpath/360050768018e026ce8000000000003db VolGroup00 lvm2 a-- 119.97G 1 .41G
/dev/sda2 VolGroup00 lvm2 a-- 66.94G 0
[root@tceq-sap-racd04 opt]#

This is showing that you have clustered locking enabled but your cluster is not operational. It is only showing local non-clustered volumes.

how do I move Striped LV from one server to another server?

If you are planning to the move the entire volume group you can simply disconnect the hard disks used in the VG and plug them into the new server. The new server should automatically detect the LVM on the disks.

How do I move a Volume Group from one system to another? IF the lun from a storage ,of course ,the first ,the lun has mapped another system.

You're missing a vgscan after the pvscan. Without this the vgimport fails with a write error message.

This may only be necessary with lvm2.