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

柔光的暖阳◎ 2023-10-14 19:31 118阅读 0赞

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. Stop all users/processes/application which is accessing the filesystem and then unmount the filesystem ( If required make use of “rescue” mode ). Make sure that no users are accessing files on the active volume.

    Raw

    1. # 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.

    Raw

    1. # vgchange -an design
    2. 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.

    Raw

    1. # vgexport design
    2. 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:

    Raw

    1. # pvscan
    2. pvscan -- reading all physical volumes (this may take a while...)
    3. pvscan -- inactive PV "/dev/sdb1" is in EXPORTED VG "design" [996 MB / 996 MB free]
    4. pvscan -- inactive PV "/dev/sdb2" is in EXPORTED VG "design" [996 MB / 244 MB free]
    5. 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:

    Raw

    1. # vgimport design
    2. Volume group "design" successfully imported
    • If importing on an LVM 1 system, add the PVs that need to be imported:

    Raw

    1. # vgimport design /dev/sdb1 /dev/sdb2
    2. vgimport -- doing automatic backup of volume group "design"
    3. vgimport -- volume group "design" successfully imported and activated
  7. Activate the volume group.

    Raw

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

    Raw

    1. # mkdir -p /mnt/design/users
    2. # 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

发表评论

表情:
评论列表 (有 0 条评论,118人围观)

还没有评论,来说两句吧...

相关阅读