How to move logical volume (LVM) to another disk?


We have two disk. The root partition is in /dev/sda2. LVM partition is in /dev/sdb1. We are going to move LVM partition from /dev/sdb1 to /dev/sda3.

Boot into SystemRescueCD

Switch to root.

su - root

New partition

Create an new partition on new disk using one of this tools (sfdisk, fdisk, gparted).

If you choose to use gparted, you need to VNC into the server using ip_address:5901.

Create a physical volume

pvcreate /dev/sda3

Add the physical volume to volume group

Find out the volume group name.



In this case, vg is the logical volume group name.

Add /dev/sda3/ to volume group.

vgextend vg /dev/sda3

Move the data

Move from old logical volume to new logical volume. Note that this will take hours to finish depending on the size of the volume.

Use the pvmove command to move the data f rom dev/sdb1 to /dev/sda3.

pvmove /dev/sdb1 /dev/sda3

If you cannot move the data due to insufficient size, then you need to resize the logical volume group and partition.

Remove the old physical volume from the volume group

After you have moved the data off /dev/sdb, you can remove it from the volume group.

vgreduce vg /dev/sdb1

You can now reallocate the disk to another volume group or remove the disk from the system.

Mike Mai
Mike Mai   Brooklyn, New York
I am a full-stack web developer. I love to learn cutting-edge technology and solve problems. I also like photography and graphic designs.