Linux – Is it possible to convert striped logical volume to linear logical volume

linuxlvm

I've a logical volume that is striped across three physical volumes. I had to move this logical volume to another physical volume. This worked nicely with pvmove command. However, I discovered later that the logical volume is still striped and now all three stripes are on the same physical volume. Is there any way to convert striped logical volumes to linear logical volumes? I'm using LVM2 on linux.

I figured that the obvious possibility is to rename the striped logical volume, create a new linear logical volume, and then copy data over, but that requires taking the filesystem system offline for some time. Unfortunately, I can't do that before the next week. Is there any better alternative?

Best Answer

It is also possible to build a mirror first using another single PV, and split of the striped volume afterwards. This requires a free PV but then again I assume pvmove needs this as well.

If you have a volume lvsplit using PV's sda1 and sdb1 for example, and sdc1 is a (temporary) PV with enough free extents, you can do this:

lvconvert -m 1 /dev/volumegroupname/lvsplit

This will create a mirror from your striped volume, using sdc1 to build the mirror

...let the mirror build...

lvconvert -m 0 /dev/volumegroupname/lvsplit /dev/sda1 /dev/sdb1

This will convert the mirror back to a single volume taking out the extents on PV /dev/sda1 and /dev/sdb1, leaving sdc1 as the only PV for your now lineair LV.

You can then pvmove from sdc1 to another PV, or use the mirror technique instead of pvmove to migrate back to sda1 or sdb1.