I am new to LVM and partitioning in general, and so, am in a situation here.
The Situation:
I accidentally overwrote MBR of a Fedora 16-created LVM disk.
Now, everything else on this disk is intact; only the MBR has been corrupted (and that too, only the first 446 of its 512 bytes). I had corrupted the MBR by accidentally issuing:
$ dd if=/the/wrong/446-byte-file.txt of=/dev/sda
This disk (with corrupt MBR), which was initially /dev/sda in System A, is now plugged into my current system, System B, as a secondary disk, /dev/sdb
, for the purpose of file-system/data recovery. It is currently unmountable in System B.
Here's the fdisk -l
output on System B:
$ fdisk -l
Disk /dev/sda: 250.1 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders, total 488397168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x8e678e67
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 475813887 237905920 83 Linux
/dev/sda2 475813888 488396799 6291456 82 Linux swap / Solaris
Disk /dev/sdb: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders, total 156301488 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Device Boot Start End Blocks Id System
/dev/sdb1 * 2048 1026047 512000 83 Linux
/dev/sdb2 1026048 156301311 77637632 8e Linux LVM
Question: With /dev/sda running a healthy, non-LVM setup of Fedora 16, how do I manually mount /dev/sdb (with corrupt MBR) somewhere inside System B so as to be able to recover all the data from it? (The data, by the way, is stored on an ext4 file system inside.)
What I have tried so far:
a) I issued pvs
and got this:
(Notice how the VG column is empty!)
$ pvs
PV VG Fmt Attr PSize PFree
/dev/sdb2 lvm2 a-- 74.04g 74.04g
b) I issued pvscan
, I got this:
$ pvscan
PV /dev/sdb2 lvm2 [74.04 GiB]
Total: 1 [74.04 GiB] / in use: 0 [0 ] / in no VG: 1 [74.04 GiB]
c) I have the contents of /etc/lvm/backup/vg_XYZ
available with me from an earlier backup. But I don't know how to infer/construct Volume Name and Volume Paths from this file (Note that, in this file, /dev/sda2 is the partition of interest which has now become /dev/sdb2 in present system, System B):
# Generated by LVM2 version 2.02.84(2) (2011-02-09): Tue Oct 25 22:10:55 2011
contents = "Text Format Volume Group"
version = 1
description = "Created *after* executing 'vgchange -a y --sysinit'"
creation_host = "XYZ" # Linux XYZ 2.6.38.6-26.rc1.fc15.i686.PAE #1 SMP Mon May 9 20:36:50 UTC 2011 i686
creation_time = 1319560855 # Tue Oct 25 22:10:55 2011
vg_XYZ {
id = "WN8593-xRnx-dn29-rcpb-tRAm-Bs5R-93DGWw"
seqno = 3
status = ["RESIZEABLE", "READ", "WRITE"]
flags = []
extent_size = 65536 # 32 Megabytes
max_lv = 0
max_pv = 0
metadata_copies = 0
physical_volumes {
pv0 {
id = "voQHGq-9m5t-u39a-UBWP-1qKM-sS4M-t3EPYG"
device = "/dev/sda2" # Hint only
status = ["ALLOCATABLE"]
flags = []
dev_size = 155275264 # 74.041 Gigabytes
pe_start = 2048
pe_count = 2369 # 74.0312 Gigabytes
}
}
logical_volumes {
lv_swap {
id = "Osi18q-409G-iG1s-Mdb2-00Lt-wtQV-WpF2mN"
status = ["READ", "WRITE", "VISIBLE"]
flags = []
segment_count = 1
segment1 {
start_extent = 0
extent_count = 126 # 3.9375 Gigabytes
type = "striped"
stripe_count = 1 # linear
stripes = [
"pv0", 0
]
}
}
lv_root {
id = "Wc8qdx-sYKi-qFeM-Bv48-YvZC-ClGU-VrYl4W"
status = ["READ", "WRITE", "VISIBLE"]
flags = []
segment_count = 1
segment1 {
start_extent = 0
extent_count = 2243 # 70.0938 Gigabytes
type = "striped"
stripe_count = 1 # linear
stripes = [
"pv0", 126
]
}
}
}
}
Your prompt help would be greatly appreciated, otherwise I'm in real trouble!
Many thanks in advance...
/HS
dd if=/the/right/446bytefile of=/dev/sdb
, or is it lost in /dev/sdb and you can't access it?