From: Vaughan R. Pratt (pratt@Sunburn.Stanford.EDU)
Date: 09/24/93


From: pratt@Sunburn.Stanford.EDU (Vaughan R. Pratt)
Subject: Re: [Help] Invalid partition table message at boot
Date: Fri, 24 Sep 1993 20:04:06 GMT

In article <27rcsj$55i@homer.cs.mcgill.ca> yveslach@binkley.cs.mcgill.ca (Yves LACHANCE) writes:
>
> Somehow, I scrapped my partition table with Linux' fdisk. (I think)
>Details below. (Please respond in email.) Thank you.
>
> I first installed Linux on my drive (that is brand new) like this:
>
>/dev/hda1 10M Linux swap
>/dev/hda2 115M Linux extfs (ext2fs actually)
>
> I successfully mkswap'ed and mke2fs'ed these two. Then I made a new
>partition, for the remaining size of the drive:
>
>/dev/hda3 200M Linux extfs (ext2fs again)
>
> I had problems mke2fs'ing it, so I went back to fdisk, deleted the
>partition. Instead of typing "n" for a new partition, I typed "a" with
>the partition #3. I was told that this was an empty partition.
>Eventually, I figured out that I was typing "a" (for add) instead of "n".
>I then rebooted, and it told me, before the LILO prompt:
>
>Invalid partition table
>
> And hung up there. I have to boot with my floppy disk.
>
> When I couldn't make it work, I decided to re-install Linux from
>my SLS 1.03 distribution. After going through the main system (series
>a, b & c), it told me the same message. I tried the FIX-TABLE and the
>IGNORE-TABLE lines in /etc/lilo/config (and then lilo'e it), to no
>avail.
>
> Both MS-DOS' and Linux' fdisks read the partition table information
>fine... On my new configuration, I now have only two partitions, having
>merged the 115M and 200M ones.
>
> Can anyone help? Please reply by email.

Since as a Linux newbie I ran into this exact problem myself just
yesterday, I think it's worth posting this reply.

'a' does not denote add but active, and means toggle the bit denoting
whether the partition is *the* one to boot from (emphasis on "the").
Evidently you did this an odd number of times and left partition 3
bootable. Since 2 was presumably also bootable, this violates one of
the preconditions of the following, which I found just now on page 543
line -9 of Michael Tischer's "PC Intern".

        "If the partition sector program [the code lying in 0x0-0x1be]
        detects that more than one partition is active or that none of
        the partitions are active, it aborts the booting process,
        displays an error message, and waits in a continuous loop. You
        can exit this loop only by resetting."

For additional information on the PC booting process you can also
consult Amy Goebel's four articles TRYST[1-4].DOS, which I think I got
from a Simtel mirror but now can't locate so I've put my copies on
boole.stanford.edu, concatenated as /pub/tryst.dos. (Tryst however
mentions only the case of no active partitions as problematic and so
would not have helped in this particular case.)

The location of the error message "Invalid partition table" will be
apparent when (as root) you do

        hexdump -c -n 512 /dev/hda

The partition table lives in the last 66 bytes of this, which you can
lay out more neatly using

        dd if=/dev/hda of=/tmp/mbr count=1
        hexdump -s 0x1be /tmp/mbr

(Double check the dd command before hitting return, one badly chosen
typo here can blow away your partition table and two can blow away your
whole disk!! Unfortunately hexdump -s 0x1be /dev/hda prints nothing,
seems it can seek on files but not block devices---how come Linux has
no /dev/rhda?---whence the need for the dd.)

Each of the four 16-byte lines describes one partition:

        Status(1) Begin(3) Type(1) End(3) Boot-sector(4) Size(4)

(n) is bytes for this field. Status is 0x80 if `a'ctive (= bootable),
else 0x00. Begin and end are block addresses of the partition
endpoints in units of head(8 bits)/sector(6 bits)/cylinder(10 bits).
(What happens with disks with more than 1023 cylinders? There are
plenty of these in SCSI-land.) Type is what operating system the
partition contains (various flavors of DOS, XENIX, Linux, etc.) or what
function it performs (swap etc.). Boot-sector is the absolute sector
address of the boot sector for this partition (Tischer says it is the
sector address relative to the partition, but this does not agree with
what hexdump shows). Size is the total number of sectors in the
partition.

Following the four partition descriptors is the short 0xaa55 (don't
forget the 8086 architecture is little-endian, so this is 0x55 at
address 0x1fe followed by 0xaa at 0x1ff). This serves as the standard
signature, in the PC world, of useful data in the vicinity.

-- 
Vaughan Pratt
(FTPables: boole.stanford.edu:/pub/ABSTRACTS.)