How to migrate LVM to new storage


This documentation shows how to migrate existing logical volumes to other new drives without any downtime. Before moving further, I would like to give some useful information about Logical Volume Management(LVM). There are two ways to migrate an LVMs’ storage unit.

  • LVM Mirroring
  • LVM Pvmove

LVM Mirroring Methods:

Step 1:Check new device which ‘ll be used after migration

#fdisk -l

New Disk ID:/dev/sdd
Next command is optional:Just we create a new partition

 

#fdisk /dev/sdd
n,p,1,enter,enter


Step 2:Check LVM device which you need to migrate
 

#vgdisplay vghitachi
#lvdisplay -v /dev/vghitachi/lvhitachi


“You should check LVM size before get new LUN device. Your LUN device size must be bigger then total LVM size.”

Step 3:Create PV with new added LUN device
 

#pvcreate /dev/sdd1


Step 4:Extend VG with new added PV
 

#vgextend vghitachi /dev/sdd1


Step 5:Add new mirror device to LVM.
 

#lvconvert -m 1 –corelog /dev/vghitachi/lvhitachi /dev/sdd1


Step 6:Remove old disk from LVM.
Before remove old disk from LVM you need to check mirror state with “lvdisplay -v” or “lvs -o+devices” command.

#lvconvert -m 0 /dev/vghitachi/lvhitachi /dev/emcpowere1


Step 7:Remove old pv from Volume Group(vg).
 

#vgreduce vghitachi /dev/emcpowere1


Step 8:Remove old pv
 

#pvremove /dev/emcpowere1


LVM PvMove Method:

Instead using ‘lvconvert’ mirroring command, you can use ‘pvmove‘ command with option ‘-n‘ (logical volume name) method to mirror data between two pv device.

Step 1-2-3 are same as Mirroring Method

Step 4:Move Pv from old device to new device

#pvmove -n /dev/vghitachi/lvhitachi /dev/sdd1 /dev/emcpowere1

This command is one of the simple way to mirror data between two pv.But we strongly advice LVM mirroring Method instead of pvmove.

Tagged In:

I'm a IT Infrastructure and Operations Architect with extensive experience and administration skills and works for Turk Telekom. I provide hardware and software support for the IT Infrastructure and Operations tasks.

205 Total Posts
Follow Me