[LINUX] LVM migration work (vgexport, vgimport)

Overview

The method of migrating LVM from A terminal to B terminal will be described. Roughly speaking, the VG is exported on the A terminal, read by the B terminal, and mounted.

Export First, check the VG to be migrated on the A terminal

$ sudo vgdisplay

  --- Volume group ---
  VG Name               ubuntu-vg
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  3
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               0
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               <447.13 GiB
  PE Size               4.00 MiB
  Total PE              114465
  Alloc PE / Size       114464 / 447.12 GiB
  Free  PE / Size       1 / 4.00 MiB

Inactivate the VG before entering the transition.

$ sudo vgchange -a n [VG Name]

Export VG information

$ sudo vgexport [VG Name]

Check if it was exported

$ sudo pvscan

  PV /dev/sdb1 is in exported VG

Import At this point, replace the physical disk of the VG of the A terminal with the B terminal. Next, check if the migrated LVM is recognized on the B terminal.

$ sudo pvscan
  PV /dev/sdb1 is in exported VG

Import VG.

$ sudo vgimport [VG Name]

Mount Find the LV on the B terminal.

$ sudo lvscan
  INACTIVE            '/dev/ubuntu-vg/root' [446.17 GiB] inherit

Activate.

$ sudo lvchange --available y ubuntu-vg

Confirmation of activation.

$ sudo lvscan
  ACTIVE            '/dev/ubuntu-vg/root' [446.17 GiB] inherit

Finally mount.

$ sudo mount /dev/ubuntu-vg/root /mnt/oldDisk

Recommended Posts

LVM migration work (vgexport, vgimport)