Re: Really big mistake -- I need some help

Harald Koenig (
Mon, 14 Jul 1997 17:30:29 +0200

On Jul 14, Kirk Bauer wrote:

> Okay, I managed to write over the first 300-500K of /dev/hda.

tsk tsk. Ob-answer: use your last night's backup (I know ;-))

> I still have not rebooted. I am trying to find a way to

good!! if you had install LILO in the MBR, you should have


which is a copy of your MBR when LILO was installed first.
if you haven't changed the partition layout since then, you
can just do

cp /boot/boot.0300 /dev/hda

but I'd check it first using

fdisk /boot/boot.0300

and so on...

> recreate the partition tables that are on the hard disk so
> that everything will be okay again. I can still do a
> 'df' and it will tell me how much space was on /dev/hda{1,3,5,6,7,9}.
> If I take the "Total" column from 'df' and multiply it by
> 1.0329, that will tell me how many blocks should be displayed
> in the 'fdisk' program.

df output doesn't show inode clocks etc. either use

hdparm -s /dev/hda1


wc -c < /dev/hda1

note that according to a quick test for hdparm output you have
to add one sector (512 bytes) for the extended partitions /dev/hda{5,6,7,9}

> My problem is -- notice that partitions 2 and 8 are not listed
> above. The reason is --these are both swap partitions. How
> can I find out how big each partition table is?
> Better yet -- I have a feeling that the kernel itself has
> enough information in internal memory to rebuild the partition
> table -- because *every* partition (except, of course, 4) is
> mounted right now (the mount was done back when I *did* have
> a partition table).
> So -- how can I find out how big each of my 2 swaps are

swapoff /dev/hda2
swapon /dev/hda2

gives a good estimate!

even better: read the first sector of each partition and write a small
C programm which scans the whole disk (/dev/hda) looking for this
sector. that way you can find (or at least check!) the real sector offset
for every partition...


All SCSI disks will from now on                     ___       _____
be required to send an email notice                0--,|    /OOOOOOO\
24 hours prior to complete hardware failure!      <_/  /  /OOOOOOOOOOO\
                                                    \  \/OOOOOOOOOOOOOOO\
                                                      \ OOOOOOOOOOOOOOOOO|//
Harald Koenig,                                         \/\/\/\/\/\/\/\/\/
Inst.f.Theoret.Astrophysik                              //  /     \\  \                     ^^^^^       ^^^^^