Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

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.

share|improve this answer
    
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 '12 at 14:33
add comment

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).

share|improve this answer
    
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 '11 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 '11 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 '11 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 '11 at 15:36
    
@JooMing, did you move them between different PVs? –  poige Feb 9 '11 at 18:42
show 4 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.