LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   Recover data from a reallocated(?) LVM2 drive set? (http://www.linuxquestions.org/questions/linux-general-1/recover-data-from-a-reallocated-lvm2-drive-set-738455/)

swan-1 07-07-2009 08:12 PM

Recover data from a reallocated(?) LVM2 drive set?
 
I *think* what happened is as follows: I was replacing a dead boot drive in a Fedora 11 system that also had two 250gig drives setup as a single LVM2 partition (mounted as /store in the old system). The LVM2 was formatted with JFS.

As part of installing FC11 to the new boot drive, the install seems to have setup a new LVM2 using all 3 drives in the system (the new boot, plus the two 250gig drives). I suspect it's formatted the 250gig drives with ext3 as well.

Is there anyway to recover the data on the old LVM2 drives?

unSpawn 07-08-2009 05:20 AM

Think of LVM as a set of "containers" (PV > VG > LV > filesystem). To get to the point where your filesystem (remnants) may become accessable (in one way or the other) you have to "open" each container to access the other within. Creating a LVM requires a few commands, the first being 'pvcreate' to create the Physical Volume(s). This command takes the "--metadatacopies" switch which allows you to set one or more copies of metadata. If the value is 1 then only one copy is available at the start of the PV, when it's 2 you have one copy at the start and one at the end of the PV to read from. If the installer defaults to 1 then the next round of PV creation will overwrite that single source of metadata. With 'pvcreate --restorefile' you can restore metadata from the /etc/lvm/backup/, but if that data is no longer available on disk (or from backup?) and unless running 'testdisk /debug /log' on the disks may reveal something you have a chicken-and-egg scenario I wouldn't know how to get out of.

(BTW I sincerely doubt there would have been no warning that the disks contained data and that repartitioning them would destroy old data. That being the case it's not the installer that allowed this fsck up to happen.)

swan-1 07-14-2009 08:56 PM

I really shouldn't post just before a trip. Anyway, I was able to get the old boot disk to boot, and now have copies of /etc/lvm/*.

Quote:

VG2forMyth {
id = "lI40tG-b8yh-w0a4-epb7-iSZN-8QmA-xGpEgY"
seqno = 6
status = ["RESIZEABLE", "READ", "WRITE"]
flags = []
extent_size = 131072 # 64 Megabytes
max_lv = 0
max_pv = 0

physical_volumes {

pv0 {
id = "Liz0DB-jL1b-1NFx-zDoX-Pxco-dCWX-3nKGUd"
device = "/dev/sdc1" # Hint only

status = ["ALLOCATABLE"]
flags = []
dev_size = 488392002 # 232.883 Gigabytes
pe_start = 384
pe_count = 3725 # 232.812 Gigabytes
}

pv1 {
id = "K7e4nC-HKJV-DUv8-3WLt-0STK-JMTz-MB3Ekx"
device = "/dev/sdb1" # Hint only

status = ["ALLOCATABLE"]
flags = []
dev_size = 488392002 # 232.883 Gigabytes
pe_start = 384
pe_count = 3726 # 232.875 Gigabytes
}
}

logical_volumes {

video {
id = "7idUrc-m3JG-eEZY-2XTU-4y66-8o6B-sLYMma"
status = ["READ", "WRITE", "VISIBLE"]
flags = []
segment_count = 2

segment1 {
start_extent = 0
extent_count = 3725 # 232.812 Gigabytes

type = "striped"
stripe_count = 1 # linear

stripes = [
"pv0", 0
]
}
segment2 {
start_extent = 3725
extent_count = 2835 # 177.188 Gigabytes

type = "striped"
stripe_count = 1 # linear

stripes = [
"pv1", 0
]
}
}

images {
id = "AUEquV-eh2a-qIo3-Uj5x-KrB9-BjIx-zE5Gq1"
status = ["READ", "WRITE", "VISIBLE"]
flags = []
segment_count = 1

segment1 {
start_extent = 0
extent_count = 160 # 10 Gigabytes

type = "striped"
stripe_count = 1 # linear

stripes = [
"pv1", 2835
]
}
}

music {
id = "nq5GUV-2XxT-vzcW-kOmw-CYMF-3D1t-3QBqvU"
status = ["READ", "WRITE", "VISIBLE"]
flags = []
segment_count = 1

segment1 {
start_extent = 0
extent_count = 480 # 30 Gigabytes

type = "striped"
stripe_count = 1 # linear

stripes = [
"pv1", 2995
]
}
}
}
}
So, it looks like I need to run:
pvcreate --restore /etc/lvm/backup/VG2forMyth --uuid Liz0DB-jL1b-1NFx-zDoX-Pxco-dCWX-3nKGUd /dev/sdc1

Doing so yields:
Couldn't find device with uuid 'Liz0DB-jL1b-1NFx-zDoX-Pxco-dCWX-3nKGUd'.
Couldn't find device with uuid 'K7e4nC-HKJV-DUv8-3WLt-0STK-JMTz-MB3Ekx'.
Couldn't find device with uuid 'Mh0xn3-Rk4d-D8h3-Cu2p-3l1l-5ZKg-mu0WlE'.
Couldn't find device with uuid 'Mh0xn3-Rk4d-D8h3-Cu2p-3l1l-5ZKg-mu0WlE'.
Can't initialize physical volume "/dev/sdc1" of volume group "vg_mythbe" without -ff

So, it looks like the new install did overwrite the 250gig drives. Hopefully it didn't also format with ext3, thus overwriting the JFS that was on there and loosing all my photos/music/video/data.


All times are GMT -5. The time now is 07:09 AM.