restoring a volume group?
A message that is not in the archive (sent off-list or not yet received): [email protected]
hello everyone,
it's been quite some time since I participate in this list... my LVM installation has just purred along much to my satisfaction. 1,000 thanks to all the people whose effort has going into getting it right.
recently I did something horrible to my system (was building an RPM with someone else's spec file which performed a "rm -rf /" (as root)) and as I have everything (/boot, /root, /usr, /etc, /lib... etc.) on a single partition (/dev/hda1) and seemed unable to restore from dumps on the live filesystem I was forced to install Linux on a different partition so I could mount /dev/hda1 without it being my root... trouble was I didn't have a spare partition so I had to take /dev/hda3, one of the physical volumes in my volume group.
I thus installed Linux there blowing away what was there, did my restore, put the partition type back to LVM and then did a "pvcreate /dev/hda3"... however, I found I could not reload the volume... "vgchange -a y" reporting there were no volume groups found...
I therefore deleted /dev/LVM (my volume group) and its contents, and tried to recreate it:
# vgcreate /dev/LVM /dev/hda3 /dev/hdc
but this complained that /dev/hdc already belonged to the group LVM, so a:
# pvcreate -ff /dev/hdc
and I promptly blew away the data there, allowing me to start from scratch...
now, after my long description (and thank you for taking the interest to read this far), my question is: was my data in /dev/hdc in any way recoverable? given the circumstances, did I take the only steps I could have taken? and what can any of you suggest I could/should have done differently?
1,000 thanks - e
p.s. in the time I've been away from the list I've learnt a lot about building RPMs... so as I move forward I am still hopeful to make good on a promise to build RPMs for LVM... will be back with more on that.
Quoted 17 lines · Erick Calder
recently I did something horrible to my system (was building an RPM with someone else's spec file which performed a "rm -rf /" (as root)) and as I have everything (/boot, /root, /usr, /etc, /lib... etc.) on a single partition (
/dev/hda1) and seemed unable to restore from dumps on the live filesystem I was forced to install Linux on a different partition so I could mount/dev/hda1without it being my root... trouble was I didn't have a spare partition so I had to take/dev/hda3, one of the physical volumes in my volume group.I thus installed Linux there blowing away what was there, did my restore, put the partition type back to LVM and then did a "pvcreate
/dev/hda3"... however, I found I could not reload the volume... "vgchange -a y" reporting there were no volume groups found...I therefore deleted
/dev/LVM(my volume group) and its contents, and tried to recreate it:
Quoted 8 lines
# vgcreate /dev/LVM /dev/hda3 /dev/hdcbut this complained that
/dev/hdcalready belonged to the group LVM, so a:# pvcreate -ff /dev/hdcand I promptly blew away the data there, allowing me to start from scratch...
Ok, basically a series of wrong operations has gotten you into a hole...
The correct order of operations would have been:
- Don't use bad spec file (oops).
- Test your backup (yes, hindsight is golden).
- Use a rescue disk to boot and recover your data.
- As long as you are not reformatting, you could have reinstalled over the old root partition and it would have kept all of your data.
Quoted 5 lines
now, after my long description (and thank you for taking the interest to read this far), my question is: was my data in
/dev/hdcin any way recoverable? given the circumstances, did I take the only steps I could have taken? and what can any of you suggest I could/should have done differently?
Now, as to the LVM part:
- You should have used vgcfgrestore to restore the LVM metadata to /dev/hda3, and all would have been well.
- Your data on /dev/hdc may still be recoverable, depending on what you have done in the meantime. Try vgcfgrestore for both hda3 and hdc and you might get it back.
- If you have whole filesystems contained on /dev/hdc you can use something like gpart (or findsuper in the e2fsprogs source is best for ext2) to find the filesystem superblock and recover the whole fs.
Quoted 3 lines
p.s. in the time I've been away from the list I've learnt a lot about building RPMs... so as I move forward I am still hopeful to make good on a promise to build RPMs for LVM... will be back with more on that.
Well, I don't think people will be rushing out to use your .spec files any time soon ;-).
Cheers, Andreas
--
Andreas Dilger
http://sourceforge.net/projects/ext2resize/
http://www-mddsp.enel.ucalgary.ca/People/adilger/