linux-lvm-recovery
redhat/centos try to install lvm by default
while this kind of "modular" hard disk formatting is supposed to be easier to use it can be much more difficult to recover from a crash
ext3 and even ext2 have a very large number of recovery utilities, and generally speaking even if your os doesn't boot and you have bad sectors you can still mount in read only using a live rescue cd and try one last grab for your data (or even use a commercial data recovery tool).
LVM's, because they can move your data around, have meta files that keep track of where everything is... and when they go, everything gets lost.
AND there's an inherent flaw in that the system tries to always create VolGroup00 - thereby overwriting your previous data... (which was probably created by default using the name VolGroup00)
boot with system rescue cd
fdisk -l //should show you the /dev/sda1 and /dev/sda2 etc.
lvm lvs //should show you the LVM VolGroups (probably VolGroup00)
lvm vgdisplay //shows the status of each lvm
fsck -f -y /dev/VolGroup00/LogVol00
IF it gives superblock corrupt message, run e2fsck -y -b 8193 /dev/VolGroup00/LogVol00
start lvm by typing : lvm vgchange --ignorelockingfailure -P -a y
(note this activates all volume groups)
mount /dev/VolGroup00/LogVol00 /mnt/backup
The next hurdle is that the system now will have two sets of lvm2 disks with VolGroup00 in them. Typically, the vgchange -a -y command would allow LVM2 to recognize a new volume group. That won't work if devices containing identical volume group names are present, though. Issuing vgchange -a y will report that VolGroup00 is inconsistent, and the VolGroup00 on the RAID device will be invisible. To fix this, you need to rename the volume group that you are about to mount on the system by hand-editing its lvm configuration file.
If you made a backup of the files in /etc on raidbox, you can edit a copy of the file /etc/lvm/backup/VolGroup00, so that it reads VolGroup01 or RestoreVG or whatever you want it to be named on the system you are going to restore under, making sure to edit the file itself to rename the volume group in the file.
If you don't have a backup, you can re-create the equivalent of an LVM2 backup file by examining the LVM2 header on the disk and editing out the binary stuff. LVM2 typically keeps copies of the metadata configuration at the beginning of the disk, in the first 255 sectors following the partition table in sector 1 of the disk. See /etc/lvm/lvm.conf and man lvm.conf for more details. Because each disk sector is typically 512 bytes, reading this area will yield a 128KB file. LVM2 may have stored several different text representations of the LVM2 configuration stored on the partition itself in the first 128KB. Extract these to an ordinary file as follows, then edit the file: dd if=/dev/md2 bs=512 count=255 skip=1 of=/tmp/md2-raw-start vi /tmp/md2-raw-start
You will see some binary gibberish, but look for the bits of plain text. LVM treats this metadata area as a ring buffer, so there may be multiple configuration entries on the disk. On my disk, the first entry had only the details for the physical volume and volume group, and the next entry had the logical volume information. Look for the block of text with the most recent timestamp, and edit out everything except the block of plain text that contains LVM declarations. This has the volume group declarations that include logical volumes information. Fix up physical device declarations if needed. If in doubt, look at the existing /etc/lvm/backup/VolGroup00 file to see what is there. On disk, the text entries are not as nicely formatted and are in a different order than in the normal backup file, but they will do. Save the trimmed configuration as VolGroup01. This file should then look like Listing 6.
Listing 6. Modified Volume Group Configuration File VolGroup01 { id = "xQZqTG-V4wn-DLeQ-bJ0J-GEHB-4teF-A4PPBv" seqno = 1 status = ["RESIZEABLE", "READ", "WRITE"] extent_size = 65536 max_lv = 0 max_pv = 0
physical_volumes {
pv0 { id = "tRACEy-cstP-kk18-zQFZ-ErG5-QAIV-YqHItA" device = "/dev/md2"
status = ["ALLOCATABLE"] pe_start = 384 pe_count = 2365 } }
Generated by LVM2: Sun Feb 5 22:57:19 2006
sh-3.2# lvm vgscan Reading all physical volumes. This may take a while... Found volume group "VolGroup00" using metadata type lvm2 sh-3.2# lvm vgchange -ay 2 logical volume(s) in volume group "VolGroup00" now active
sh-3.2# lvm lvs LV VG Attr LSize Origin Snap% Move Log Copy% LogVol00 VolGroup00 -wi-a- 28.66G LogVol01 VolGroup00 -wi-a- 992.00M
load device module
modprobe dm-mod
change the volumes that exist to active
vgchange -ay
mount the logical partition
mkdir -p /mnt/VolGroup00/LogVol00 mount /dev/VolGroup00/LogVol00 /mnt/VolGroup00/LogVol00