LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Recovering partition table !? (https://www.linuxquestions.org/questions/linux-software-2/recovering-partition-table-457225/)

Thoddy 06-22-2006 07:32 AM

Recovering partition table !?
 
Hi guys,

I lost my partition table (at least I hope it's only the table and the data is still there) - most probably during a reset after my system crashed... :mad:

So I did not create any partitions or format anything - the data should still be on the disk, right? It is a 300GB disk containing one primary ext3 partition.

What I did so far is:
  • dmesg: 'dmesg | grep partition' gives me "hdg: unknown partition table".
  • gpart: scanned the disk for like an hour and didn't find anything but "unused space".
  • fdisk: 'fdisk -l' tells me "Disk /dev/hdg doesn't contain a valid partition table". Starting 'fdisk /dev/hdg' gives me some output - amoung others "Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)". Writing the partition table does not seem to correct this - the same error occurs every time I start fdisk.
  • hdparm: 'hdparm /dev/hdg' gives me a correct output of the disks geometry - so it still works properly I hope.

Any suggestions?
PLEASE!!

Sm1ler 06-22-2006 07:35 AM

Not 100% sure but I think parted gives some options to recover partiton tables, It should be well worth a try..
Hope this helps
Sm1ler

Thoddy 06-22-2006 08:13 AM

Quote:

Originally Posted by Sm1ler
Not 100% sure but I think parted gives some options to recover partiton tables, It should be well worth a try...

Hm, just tried 'parted /dev/hdg' and then 'print', which gives me "Error: unable to open /dev/hdg - unrecognised disk label". The same output for the 'rescue' option...

I thought it might be a good idea to create a new disk label (partition table), so typed 'mklabel msdos'. No report (which hopefully means no problem), but still the same error message when I want to print the partition table after that... :mad:

Seems to be a good tool! But also seems there is some more severe problem with my disk!?

Anyone: can clearing the MBR and then re-adding a partition table help??

Sm1ler 06-22-2006 09:53 AM

I used parted last week and it does take a bit of getting used to, I will search around for some web help and post if I find anything further. Don't give up just yet and I would recomend doing some web searches on recovered disks with parted etc.. You might turn up something very helpful. ;)

binary_y2k2 06-22-2006 10:46 AM

In the parted help the only reference to rescueing a partition is
Quote:

rescue START END rescue a lost partition near START and END

J.W. 06-22-2006 08:06 PM

I don't know if this will help, but if you kill your partition table (without reformatting, etc) then Yes, you can recover your data. In order to do so however, you need to recreate the same partitions, using the same sizes as they were previously. Obviously, this may be easier said than done, and if you don't know what exact sizes they were in the past, it might not be possible.

However, thinking optimistically, if you know that (for example) hda1 was swap and it was 512Mg, and that hda2 was root and was 50G, and that hda3 was /home and was the rest of the drive, then if you just redefine those partitions, you should be up and running. FWIW, I've found myself in this exact situation more than once, but fortunately I had written up some notes about my system so I was able to recover.

Good luck with it. There are a number of other existing threads on this topic; check them out if you haven't already for other suggestions

syg00 06-22-2006 08:40 PM

If there was just the one partition on it, use fdisk to create a partition. Take all the defaults - start at the start, use the whole disk.
Doesn't matter if it winds up bigger than you had before - the filesystem will be intact and usable so long as your previous partition was at the beginning of the disk. As it will almost certainly have been.

Thoddy 06-23-2006 01:57 AM

Quote:

Originally Posted by syg00
If there was just the one partition on it, use fdisk to create a partition. Take all the defaults - start at the start, use the whole disk.

That's what I was hoping all the time - and I was sure to be able to simple re-create that one partition (without formating).

But then all the time (using both fdisk and parted) I received the message that my partition table was corrupt (see my post #2 - post #3 all together in this thread) and couldn't even make an empty new one. And without a partition table - of course - you can not create a partition... ;)

For whatever reason today I could?!?!?!? :) :scratch:

So now I could create an ext3 partition using the whole drive and... TA-DA... I can do an 'fsck /dev/hdg1', which means it is there and currently checking the file system!! :)

So - I have no idea what is different today!! But it works... thanks all!

syg00 06-23-2006 02:11 AM

Quote:

Originally Posted by Thoddy
So - I have no idea what is different today!! But it works...

You probably rebooted in the interim.

Thoddy 06-23-2006 03:04 AM

Quote:

Originally Posted by syg00
You probably rebooted in the interim.

Yes. But I am pretty sure I did that yesterday, too...

But anyway: do you have to reboot for being able to read a new partition table? I thought this could be done "on the fly"...

syg00 06-23-2006 03:22 AM

Of course you can do it on the fly - and generally you (probably) don't need to reboot.

I always reboot (just in case) - old habits die hard.

Sm1ler 06-26-2006 06:19 AM

I have noticed this in the past when using parted and "fdisk -l" updates are not displayed till a full reboot is completed, This can be a bit of a pain for me as I always forget and my laptop always fails to boot with external devices connected! D'Oh!

Anyway glad you got data back mate.


All times are GMT -5. The time now is 03:00 AM.