Date: Tue, 19 Aug 2003 01:41:49 -0700 (PDT) From: Dan Strick <strick@covad.net> To: freebsd-questions@FreeBSD.ORG Cc: dan@ice.nodomain Subject: How does one erase a FreeBSD disk (slice) label? Message-ID: <200308190841.h7J8fnvs000487@ice.nodomain>
next in thread | raw e-mail | index | archive | help
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.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200308190841.h7J8fnvs000487>