Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I had a CentOS 5.5 server with two drives in it (sda, sdb) using LVM. sda had a combination of physical partitions and LVs. sdb had one volume group named data with multiple logical volumes. There were no logical volumes or volume groups that spanned the two disks.

Last week I decided to reinstall the OS including formatting /, /root, /boot and rebuilding the LVs on sda. sdb was not touched during the reinstallation as it contains all of the data I want to keep.

After the installation the physical volume on sdb was not listed as active by LVM. Running (as best I can tell from looking at my history) pvscan activated the physical volume. Unfortunately, none of the existing volume groups on sdb were being listed.

I then ran vgcreate data /dev/sdb which I thought would either give errors reporting an existing volume group existed with this name or would somehow activate the data volume group. Unfortunately for me, neither of these things happened.

At this point I haven't touched anything on /dev/sdb since I would like to recover the existing logical volumes that are defined on that drive. Is there anyway to reactivate those volumes?

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

If you had a backup of /etc/lvm/backup/data or perhaps even /etc/lvm/archive/data_* from before the reinstall it would help a great deal. You could use vgcfgrestore with the old config to rebuild the VG.

At any point before the vgcreate, you could probably have run vgscan and "vgchange -a y" to activate data and get it running again.

Now that you ran vgcreate, the options are more limited... I am assuming that vgs now shows an empty data VG.

Another option, if you happen to know the exact layout of the volumes on /dev/sdb, it is possible to create LVs in those exact positions and sometimes mount filesystems that are there... but it's tricky and I wouldn't want to do it unless I had no other choice, because the PEs have to be used in the exact same order.

share|improve this answer
    
Yeah vgs shows an empty data VG. It looks like I'm out of luck as I don't know the exact PE order –  Chris Gow Feb 28 '11 at 21:41
    
marking this answer as my accepted answer as it seems closest to what I would need to do, if I actually followed the correct migration steps –  Chris Gow Feb 28 '11 at 21:41
add comment

If you've somehow ended up with two volume groups with the same name, use vgrename to rename one of them. In your situation the two volume groups should have distinct UUIDs, and you can pass a UUID to vgrename to make sure it acts on the desired group.

Now, if I understand your question correctly, you now have two volume groups, A (new) and B (old), and you have some logical volumes in B that you'd like to be in A. First run vgscan and perhaps vgchange -ay to make sure all your volume groups are active. Then run vgmerge to merge the two volume groups into one, or vgsplit to move some physical volumes from B to A.

If this doesn't help, please post the output of pvs, lvs and vgdisplay.

share|improve this answer
    
I've updated the question giving more background. –  Chris Gow Feb 15 '11 at 1:59
    
The logical volumes in B were created before the reinstall but are not being recognized in the new install. I'm guessing that the LVs are referencing the old UUID of volume group B –  Chris Gow Feb 17 '11 at 2:30
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.