Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 4 Oct 1998 11:42:21 -0700 (PDT)
From:      dan@math.berkeley.edu (Dan Strick)
To:        ccsanady@friley-185-114.res.iastate.edu
Cc:        current@FreeBSD.ORG, dan@math.berkeley.edu
Subject:   Re:  Partition weirdness..
Message-ID:  <199810041842.LAA27025@math.berkeley.edu>

next in thread | raw e-mail | index | archive | help
> I have a couple of partitions that have been behaving somewhat odd.  Also,
> I have gotten a number of messages recently (from newfs--i think), about
> not being able to rewrite the disklabel.  Has anyone else been seen this?
> 
> On 2 of my bios partitions, I can not write to the second sector.  Doing
> so will cause the following:
> 
> friley-185-114:/# dd if=/dev/zero of=/dev/rda0s4e bs=512 count=1 seek=1
> dd: /dev/rda0s4e: Read-only file system
> 
> If I seek past 2 sectors, or only write the first sector, I have no
> trouble.  Does anyone know what might be causing this?  My disklabel,
> and fdisk output follow..

This is partially documented somewhere.  Check out the man pages for
"disklabel" in sections 5 an 8.  The FreeBSD disk label goes in the
second sector of a disk slice (i.e. DOS partition).  Disk label sectors
are special and the disk drivers normally refuse to write them.
You are supposed to be able to turn off this protection with the
"disklabel -W" command, though this never seems to work for me.

I have discovered (the hard way) that disk label sectors are also
special because the I/O system munges them when you read them.
It subtracts the slice base address from the bsd partition base
addresses in the label.  I suspect it also recomputes the label
sector checksum, though I don't remember specifically checking
for this.  It does not reverse these changes when you write
a label sector for the first time.  Therefore using dd to replicate
the dos/bsd label structures on a new disk does not work.

I present these possibly unintended features as an example of
what I think is a generally good design principle:  An unnecessary
and complex feature is usually a bad idea.  It is often much
better to have no feature at all.

Special treatment of disk label sectors goes back to 4.3BSD or
4.4BSD (I forget which) when BSD disk labels were first introduced.
I suspect the sectors were made read-only to protect fools from
themselves.  This is a most un-unix like feature and I think
the people who implemented it should have known better.
Fools should be allowed to shoot themselves in the feet.
This is how they learn not to be fools.
It will also teach them to be more careful with guns.

Dan Strick
dan@math.berkeley.edu

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message



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