Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 27 Jul 1996 00:02:52 +1000
From:      Bruce Evans <bde@zeta.org.au>
To:        Andries.Brouwer@cwi.nl, bde@zeta.org.au, freebsd-bugs@freebsd.org, j@uriah.heep.sax.de
Subject:   Re: installation fails
Message-ID:  <199607261402.AAA03847@godzilla.zeta.org.au>

next in thread | raw e-mail | index | archive | help
>    Apparently the partition table has the wrong offsets in it.

>What happens here (my first encounter with the phenomenon of
>disk labels went by reading "dd if=/dev/hda4 | od -c")
>is that d_partitions[0] and d_partitions[1] contain all zeros,
>while d_partitions[2] and d_partitions[3] describe the (same)
>partition - they only differed in a type byte. The remaining
>partitions are zero again.

This is a possible but unusual configuration.  Partition 2 must
always exist and partition 3 is your filesystem partition.  But
I thought you said that you were using partition 'e'.

>   `part' and both of the p_offset's should be 0 here.

>So part is zero, and so is d_partitions[part].p_offset,
>but not dl->d_partitions[2].p_offset.  Indeed, the latter
>equals sector. The effect is that boff is set to zero,

Oops.  I forgot that the offset of the slice gets subtracted from
all of the d_partition offsets when the label sector is read in
under FreeBSD (and added back when the label sector is written
under FreeBSD).  This is mainly for backwards compatibility -
partitition offsets are absolute in the on-disk label and relative
in the in-core label and even in the buffer cache.  You must have
run "dd | od" under Linux to see a nonzero value.  The bootblock
should see nonzero offsets and

	boff = dl->d_partitions[part].p_offset -
		dl->d_partitions[2].p_offset + sector;

is normally the same as

	boff = dl->d_partitions[part].p_offset;

which is what the pre-DiskManager-aware version did.  This fails
completely for empty partitions.  Empty partitions have absolute
offset 0 for backwards compatibility.

The patch should be:

	...
	bsize = ...;
	if (bsize == 0) {
		printf("empty partition");
		return 1;
	}


>to get the same effect.  A reasonable thing to do for
>a robust booter might be to pick for part the smallest
>number different from 2 for which d_partitions[part].p_offset
>is nonzero, and 2 if there is no such number.

Not when then user has specified the partition.  Then it should
simply fail.

>By the way, there is a formal bug in the source there, in
>that b_size is only defined inside #ifdef DO_BAD144 ... #endif,
>while it is used here outside such an ifdef.

Already fixed in -current.

>    >Discussion:
>    >    The above patches work entirely satisfactorily,
>    >    but the real problem is that this Disklabel Editor
>    >    did not write anything in partition[0], while the
>    >    disk.c code assumes that there would be something.    

>    It has to write something there since all of the partition
>    entries have to be written together.  It probably writes 0.

Actually it writes 0 to the in-core label, and usually non-0
to disk.

Bruce



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199607261402.AAA03847>