Missing partition table on Linux/RAID/LVM/ext4

How to use TestDisk to recover lost partition
Post Reply
Message
Author
krambjas
Posts: 2
Joined: 19 Jul 2017, 14:47

Missing partition table on Linux/RAID/LVM/ext4

#1 Post by krambjas » 19 Jul 2017, 15:07

Need a little help with what appears to be a missing partition table on one drive. I was working on zeroing out some bad sectors on a drive that was showing read errors. As part of that, I ran 'fdisk -lu /dev/sdb' early on the session to check where partition blocks started and ended and got:

Code: Select all

root@mail:/# fdisk -lu /dev/sdb

Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders, total 1953525168 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: 0x0009bc71

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *          63  1953520064   976760001   fd  Linux raid autodetect
Exactly as expected. I continued working on specific blocks and got through a couple. I was checking what block a specific file was in and happened to run fdisk again:

Code: Select all

root@mail:~# fdisk -lu /dev/sdb

Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders, total 1953525168 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

Disk /dev/sdb doesn't contain a valid partition table
No idea what happened, but obviously something screwed up the partition table. I have not rebooted to everything work right now as expected, but this obviously has me a bit concerned that it will break as soon as I do.

/dev/sdb should have /dev/sdb1 on it. Then /dev/md2 is all of /dev/sdb1. Then I have an LVM2 spanned partition (RAID 0) sitting on top of that and spread across /dev/md2 and /dev/sdc1. That LV is mounted as /dev/maildata/data and is has an ext4 filesystem.

TestDisk immediately finds two missing partitions, but I'm not sure which to recover or how to ensure the parameters right. As I understand it, this needs to be exactly correct or my entire LV will stop working. I still have access to /etc/lvm/backup, and I've seen ways to recreate the format with that backup. I just don't fully understand the relationship between all of the devices on top of each other and what does what. Output from TestDisk:

Code: Select all

TestDisk 6.13, Data Recovery Utility, November 2011
Christophe GRENIER <grenier@cgsecurity.org>
http://www.cgsecurity.org

Disk /dev/sdb - 1000 GB / 931 GiB - CHS 121602 255 63
     Partition               Start        End    Size in sectors
>D Linux LVM                0   1  1 121600 254 63 1953520002
 D Linux RAID               0   1  1 121600 254 63 1953520002 [md2]
I would guess only one of these are correct to add back to the partition table. Also, the start, end, and size look different than what came out of fdisk. I want to make sure I'm getting these exactly correct to ensure this works.

Could anyone provide some insight into what I need to do?

Sponsored links

User avatar
cgrenier
Site Admin
Posts: 3565
Joined: 18 Feb 2012, 15:08
Location: Le Perreux Sur Marne, France
Contact:

Re: Missing partition table on Linux/RAID/LVM/ext4

#2 Post by cgrenier » 19 Jul 2017, 17:30

Choose the raid partition, set it as P(rimary)

krambjas
Posts: 2
Joined: 19 Jul 2017, 14:47

Re: Missing partition table on Linux/RAID/LVM/ext4

#3 Post by krambjas » 19 Jul 2017, 17:48

Thanks so much for the response.

If I select this option, do I just need to write the partition table with what TestDisk found? That looks like it would end up slightly different size in sectors? What about the now missing disk identifier?

User avatar
cgrenier
Site Admin
Posts: 3565
Joined: 18 Feb 2012, 15:08
Location: Le Perreux Sur Marne, France
Contact:

Re: Missing partition table on Linux/RAID/LVM/ext4

#4 Post by cgrenier » 19 Jul 2017, 20:01

Choose Write, confirm, Quit and restart your Linux.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests