From owner-freebsd-questions@FreeBSD.ORG Tue Aug 19 01:41:53 2003 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B689F16A4BF for ; Tue, 19 Aug 2003 01:41:53 -0700 (PDT) Received: from smtp.covadmail.net (mx01.covadmail.net [63.65.120.61]) by mx1.FreeBSD.org (Postfix) with SMTP id 7C18A43FBF for ; Tue, 19 Aug 2003 01:41:52 -0700 (PDT) (envelope-from strick@covad.net) Received: (covad.net 6933 invoked from network); 19 Aug 2003 08:41:48 -0000 Received: from unknown (HELO ice.nodomain) (68.164.193.90) by sun-qmail12 with SMTP; 19 Aug 2003 08:41:47 -0000 Received: from ice.nodomain (localhost [127.0.0.1]) by ice.nodomain (8.12.8p1/8.12.8) with ESMTP id h7J8fnKB000488; Tue, 19 Aug 2003 01:41:49 -0700 (PDT) (envelope-from dan@ice.nodomain) Received: (from dan@localhost) by ice.nodomain (8.12.8p1/8.12.8/Submit) id h7J8fnvs000487; Tue, 19 Aug 2003 01:41:49 -0700 (PDT) Date: Tue, 19 Aug 2003 01:41:49 -0700 (PDT) From: Dan Strick Message-Id: <200308190841.h7J8fnvs000487@ice.nodomain> To: freebsd-questions@FreeBSD.ORG cc: dan@ice.nodomain Subject: How does one erase a FreeBSD disk (slice) label? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Aug 2003 08:41:54 -0000 How does one erase a FreeBSD disk (slice) label? Suppose I want to reuse a disk slice that currently contains a FreeBSD file system for some other purpose that would not involve a FreeBSD disk label and partition table. The kernel won't let me overwrite the label block. Even if I write enable the label block with the DIOCWLABEL ioctl or the "disklabel -W" command (which is not as simple as you might think*), the kernel will insist that whatever I write into a label block be a valid label. For example, it will reject a zero block because it doesn't have the correct magic number for a disk label. It seems that once you create a disk label, you can't get rid of it. I tried changing the slice starting offset with fdisk so that the label block was someplace else and then zeroing the disk sector, but that didn't work. (I don't know why.) When I restored the slice the label somehow reappeared. What do I have to do to get rid of the blasted thing? Boot MS Windows and FORMAT the slice? Disable the code in /sys/kern/subr_diskslice.c that protects disk labels and build a new kernel? Go back in time and kill the person that wrote this code before he wrote it? Learn to love penguins? Please help ... I am slowly going crazy... Dan Strick strick@covad.net *P.S. An example of the extent of the insanity: the "disklabel -W" command does a DIOCWLABEL ioctl to write enable the slice label. It used to be the case that the label write enable flag was cleared on the final close of the special file. (Perhaps it still is.) That meant that the effect of the "disklabel -W" command lasted only until the disklabel program exited. The workaround was to do something like "od /dev/da1s2 | more" before "disklabel -W da1s2" in order to delay the final close. Of course this was documented nowhere that I could find. Alas, that hack is no longer sufficient.