Softpanorama

May the source be with you, but remember the KISS principle ;-)
Home Switchboard Unix Administration Red Hat TCP/IP Networks Neoliberalism Toxic Managers
(slightly skeptical) Educational society promoting "Back to basics" movement against IT overcomplexity and  bastardization of classic Unix

Moving a volume group to another system

It is quite easy to move a whole volume group to another system if, for example, a user department acquires a new server. To do this we use the vgexport and vgimport commands.

vgexport/vgimport is not necessary to move drives from one system to another. It is an administrative policy tool to prevent access to volumes in the time it takes to move them.

First, make sure that no users are accessing files on the active volume, then unmount it

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
          
It is now necessary to export the volume group. This prevents it from being accessed on the ``old'' host system and prepares disks to be physically removed.
# vgexport design
vgexport -- volume group "design" successfully exported
When the machine is next shut down, the disk can be removed and then connected to it's new machine 

Import the volume group

When plugged into the new system those disks will 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]          
We can now import the volume group (which also activates it) and mount the file system. 
# vgimport design
  Volume group "vg" successfully imported          

You must activate the volume group before you can access it.

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

Top Visited
Switchboard
Latest
Past week
Past month

NEWS CONTENTS

Old News ;-)

Moving a Volume Group to Another System

You can move an entire LVM volume group to another system. It is recommended that you use the vgexport and vgimport commands when you do this.

The vgexport command makes an inactive volume group inaccessible to the system, which allows you to detach its physical volumes. The vgimport command makes a volume group accessible to a machine again after the vgexport command has made it inactive.

To move a volume group form one system to another, perform the following steps:

  1. Make sure that no users are accessing files on the active volumes in the volume group, then unmount the logical volumes.
  2. Use the -a n argument of the vgchange command to mark the volume group as inactive, which prevents any further activity on the volume group.
  3. Use the vgexport command to export the volume group. This prevents it from being accessed by the system from which you are removing it.

    After you export the volume group, the physical volume will show up as being in an exported volume group when you execute the pvscan command, as in the following example.

    [root@tng3-1]# pvscan
      PV /dev/sda1    is in exported VG myvg [17.15 GB / 7.15 GB free]
      PV /dev/sdc1    is in exported VG myvg [17.15 GB / 15.15 GB free]
      PV /dev/sdd1   is in exported VG myvg [17.15 GB / 15.15 GB free]
      ...
    

    When the system is next shut down, you can unplug the disks that constitute the volume group and connect them to the new system.

  4. When the disks are plugged into the new system, use the vgimport command to import the volume group, making it accessible to the new system.
  5. Activate the volume group with the -a y argument of the vgchange command.
  6. Mount the file system to make it available for use.

Recommended Links

LVM-HOWTO Linux.com

Linux Online - Moving a volume group to another system

vgexport - Linux Command - Unix Command

LVM Export - lvm, export

Creating and Exporting LVM Volume Groups

Moving a volume group to another system

Common LVM Tasks

LVM – An introduction " Server Management Tips by SupportPRO