Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm rearranging a bunch of disks on my server at home and I find myself in the position of wanting to move a bunch of LVM logical volumes to another volume group. Is there a simple way to do this? I saw mention of a cplv command but this seems to be either old or not something that was ever available for Linux.

share|improve this question
add comment

4 Answers

up vote 12 down vote accepted

If you can arrange for the logical volume to be on a separate subset of physical volumes from the rest of the source volume group (lvconvert sourcevg/sourcelv /dev/pv1 ... may help), you can use vgsplit to split off the lv into a new vg and vgmerge to merge the new vg into the target vg.

Although LVM has a mirroring feature, you can't (sanely) use it to make a copy between volume groups, because both legs of the mirror must live on the same vg and the association can't be broken.

You can copy an LVM volume to another the way you'd copy any volume to another: create a target lv of the appropriate size, then copy the contents with dd if=/dev/sourcevg/sourcelv of=/dev/targetvg/targetlv bs=4M. If the source volume is active, you can leverage LVM to mkae a consistent copy: first take a snapshot of the source lv with lvcreate -s, then copy the snapshot.

share|improve this answer
    
Brilliant Gilles....vgsplit / vgmerge will probably be just fine: I can use pvmove after that to move the physical extents to the new disk and then remove the old volume from the VG. –  jkp Dec 2 '10 at 9:36
    
Shame, this didn't work for me in the end due to differing extent sizes. If thats not an issue for you though I suggest this method would be easiest. –  jkp Dec 2 '10 at 14:37
add comment

here is a step-by-step example of vgsplit

http://pleasedonttouchthescreen.blogspot.com/2011/10/migrating-logical-volumes-between.html

share|improve this answer
3  
allessandro: please expand your answer, link only answers are discouraged, as they don't provide any useful content if the URL goes dead. Cheers! –  studiohack Oct 8 '11 at 14:56
add comment
pvmove -n lvol1 /dev/sdb1 /dev/sdc1

pvmove can move data between physical volumes: LVM Administrator's Guide

share|improve this answer
3  
But not between volume groups. –  MattBianco Sep 19 '13 at 14:50
add comment

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.