LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Hardware (https://www.linuxquestions.org/questions/linux-hardware-18/)
-   -   Corrupt Partition Table (https://www.linuxquestions.org/questions/linux-hardware-18/corrupt-partition-table-88306/)

BigBadPenguin 09-02-2003 03:46 AM

Corrupt Partition Table
 
Morning all,
I know this isn't quite a hardware question, more low-level software, but this forum seemed the right level of techiness to ask :). Anyway, I've managed to bugger my partition table. This was either: 1 when i deleted my /boot :o (don't worry, i recovered it) 2. When i hard rebooted mid-load :o :o (I wanted to check my /boot fix had worked, and linux was very early on in the boot process) or 3. when i started to install gentoo.
I think 1 is most likely, but to be honest i don't really care why it happened. This is the result:

Out of the following:
Code:

/etc/fstab (still accessible)
/dev/hda7        swap            swap        defaults              0  0
/dev/hda1        /                ext2        defaults              1  1
/dev/hda9        /usr            ext2        defaults              1  2
/dev/hda10      /boot            ext2        defaults              1  2
/dev/hda5        /home            ext2        defaults              1  2
/dev/hda6        /var            ext2        defaults              1  2
/dev/hda8        /stuff          ext2        defaults              1  0
with /dev/hda3 being spare to load other distros

1 3 and 5 are accessible, so i can boot into slack but do little else (using knoppix right now).
I downloaded www.planetmirror.com/pub/gpart/]gpart[/URL]
and did the scan. This confirmed what i feared, a corrupt partition table but did\t correctly find my partitions. However, it struck me i have a printout of fdisk -l from YESTERDAY (prelimary to installing gentoo) ao I have the geometry and all.
I wondered if i can use fdisk and manually repair the partition table. Would it just be a case of adding the partitions in exactly the same place and printing the table? Might i salvage some stuff? I wanted to check here first (and i did search, but i think theses matters are handled best on a case to case basis) to see if this would be a good idea, cos i'm fed up of finding my partition ideas are bad the hard way.
Cheers for any help
-bbp

fancypiper 09-02-2003 09:55 AM

I managed to recover once after a Windows install re-wrote the partition table for me. I found a piece of paper with some numbers on it and it just happened to be my last partitioning scheme for that drive.

I booted a knoppix live cd, ran fdisk and partitioned again, intstalled grub and wow! It was all back, just like before. :cool:

What a relief it was as I had been doing everything in Linux for about a year and a half, so I had tons of stuff I could have lost.

Now I do backups....

Give it a shot. I don't know if /boot will be screwed up though.

BigBadPenguin 09-02-2003 10:17 AM

Thanks a lot, I've actually just rebooted it from trying it. Unfortuanately the former partition table was generated by parted, and the new fdisk table doesn't quite match, the start and end cylinders are the same but for two of the partitions the blocks don't match:
Code:


OLD PARTITION TABLE

  Device Boot    Start      End    Blocks  Id  System
/dev/hda1  *        1      624  5012248+  83  Linux                                (/)
/dev/hda2          1841      9733  63400522+  f  Win95 Ext'd (LBA) 
/dev/hda3          625      1840  9767520  83  Linux                              (empty)
/dev/hda5          9037      9551  4136706  83  Linux                            (/home)
/dev/hda6          8909      8991    666697+  83  Linux                            (/var)
/dev/hda7          9552      9733  1461883+  82  Linux swap                  (swap)
/dev/hda8          1841      5724  31198167  83  Linux                            (media)
/dev/hda9          5725      8907  25567416  83  Linux                            (/usr)
/dev/hda10        8908      8908      8001  83  Linux                              (/boot)

Code:

NEW PARTITION TABLE

  Device Boot    Start      End    Blocks  Id  System
/dev/hda1  *        1      624  5012248+  83  Linux                                (/)
/dev/hda2          1841      9733  63400522+  f  Win95 Ext'd (LBA)
/dev/hda3          625      1840  9767520  83  Linux                              (empty)
/dev/hda5          9037      9551  4136706  83  Linux                            (/home)
/dev/hda6          8909      8991    666697+  83  Linux                            (/var)
/dev/hda7          9552      9733  1461883+  82  Linux swap                  (swap)
/dev/hda8          1841      5724  31198198+  83  Linux                          (media)
/dev/hda9          5725      8907  25567416  83  Linux                            (/usr)
/dev/hda10        8908      8908      7969+  83  Linux                              (/boot)

See what I mean? 8 and 10 aren't right.
As a result All of my partions are working now (mounting in knoppix) apart from 2 (8 and 9, strangely enough, which SUCKS; boot is recognised perfectly). Since I have the copy of the old partition table, if i could access the table directly I'd be able to fix, and judging by the results so far, recover.
Any idea where i can find a program? Searching so far has told me i need a ptedit.exe clone, and there's one on sourceforge but it's in the planning stage still.

BigBadPenguin 09-02-2003 11:02 AM

sorted
 
Well, worked better this time :D . I couldn't install parted on knoppix ramdisk cos of dependencies, so i looked what other stuff there was. ran sfdisk, cfdisk and nparted and all gave me errors of some kind. Then i ran fdisk again and the numbers were suddenly right! So, i'm back in slack now, with every partition running on all cylinders. Thanks a lot for your help.


All times are GMT -5. The time now is 09:25 PM.