From owner-freebsd-current Sun Oct 4 11:42:48 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id LAA09140 for freebsd-current-outgoing; Sun, 4 Oct 1998 11:42:48 -0700 (PDT) (envelope-from owner-freebsd-current@FreeBSD.ORG) Received: from math.berkeley.edu (math.Berkeley.EDU [128.32.183.94]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id LAA09130 for ; Sun, 4 Oct 1998 11:42:44 -0700 (PDT) (envelope-from dan@math.berkeley.edu) Received: (from dan@localhost) by math.berkeley.edu (8.8.7/8.8.7) id LAA27025; Sun, 4 Oct 1998 11:42:21 -0700 (PDT) Date: Sun, 4 Oct 1998 11:42:21 -0700 (PDT) From: dan@math.berkeley.edu (Dan Strick) Message-Id: <199810041842.LAA27025@math.berkeley.edu> To: ccsanady@friley-185-114.res.iastate.edu Subject: Re: Partition weirdness.. Cc: current@FreeBSD.ORG, dan@math.berkeley.edu Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > 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