6

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?

2 Answers 2

3

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.

3
  • Nice solution! Although I got my problem solved in a different way while ago, I just had to try it on my a test machine (debian squeeze). It worked with one issue. Namely, the creation of a mirror from the split LV required the same amount of temporary PVs as used by the split LV.
    – JooMing
    Oct 15, 2012 at 14:33
  • 1
    Hi! I'm trying to convert striped LV to linear with Sam's solution and it doesn't work. When running lvconvert -m 1 ... I receive '--mirrors/-m' is not compatible with striped. Any help? Oct 15, 2014 at 20:40
  • lvconvert -m1 ... takes painfully long (I mean really long). You're better of doing a snapshot copy or rsync or cp-whatever to a new linear volume (preferably if the source LV ain't mounted/used).
    – rogerovo
    Sep 21, 2015 at 7:00
2

However, I discovered later that the logical volume is still striped

Yeah, it's such a PITA. Kills performance dramatically (have had known this once upon a time).

Is there any better alternative?

Sure, but quite unpleasant. You'd have to pvmove all the extents so that they would be in logical order. I'd prefer scripting it by my own, but you can try using http://bisqwit.iki.fi/source/lvm2defrag.html (at your own risk, of course).

9
  • Thank you for the hints! The link to lvm2defrag is very useful. I tried to use pvmove in a way that extents would be in a logical order (e.g. pvmove pv1:stripe1:start-end:stripe2:start:end pv2:start:end). It works, but stripes will be still there.
    – JooMing
    Feb 2, 2011 at 9:28
  • Such pvmove would at least fix interleaving which otherwise degrade performance severely. I'm digging int extents merging now.
    – poige
    Feb 2, 2011 at 9:38
  • Hi! Regarding segments merge: I've just tested pvmoving to another PV and back then; the result was single (merged) segment.
    – poige
    Feb 3, 2011 at 19:03
  • @poige: How did you do that? I did move extents back and forth, but could not merge the stripes in the process.
    – JooMing
    Feb 9, 2011 at 15:36
  • @JooMing, did you move them between different PVs?
    – poige
    Feb 9, 2011 at 18:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .