Subject: kern/18165: zeroing disklabel can prove difficult due to kernel label protection
To: None <gnats-bugs@gnats.netbsd.org>
From: None <grant@netbsd.org>
List: netbsd-bugs
Date: 09/04/2002 21:22:09
>Number: 18165
>Category: kern
>Synopsis: zeroing disklabel can prove difficult due to kernel label protection
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: kern-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed Sep 04 04:20:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: grant beattie
>Release: NetBSD 1.6F
>Organization:
>Environment:
System: NetBSD mofo 1.6F NetBSD 1.6F (MOFO) #1: Tue Aug 20 12:21:00 EST 2002 grant@mofo:/raid0/netbsd/current/src/sys/arch/i386/compile/MOFO i386
Architecture: i386
Machine: i386
>Description:
difficulty was experienced while attempting to blow away the NetBSD
disklabel on a disk, due to the default behavior of the kernel which
attempts to protect the label area of the disk.
the disk in question is wd1 on i386, and it has both a msdos and a
NetBSD mbr partition.
the disklabel currently looks like this:
# size offset fstype [fsize bsize cpg/sgs]
a: 204800 4209030 4.2BSD 0 0 0 # (Cyl. 4175*- 4378*)
c: 8389584 4209030 unused 0 0 # (Cyl. 4175*- 12498*)
d: 78177792 0 unused 0 0 # (Cyl. 0 - 77557*)
>How-To-Repeat:
# dd if=/dev/zero of=/dev/rwd1a bs=1024 count=1
dd: /dev/rwd1a: Read-only file system
1+0 records in
0+0 records out
0 bytes transferred in 0.001 secs (0 bytes/sec)
# dd if=/dev/zero of=/dev/rwd1c bs=1024 count=1
dd: /dev/rwd1c: Device not configured
>Fix:
workaround is first enable writing to the label area:
# disklabel -W wd1
then create a partition starting at the same sector as 'c', eg.
# size offset fstype [fsize bsize cpg/sgs]
a: 204800 4209030 4.2BSD 0 0 0 # (Cyl. 4175*- 4378*)
c: 8389584 4209030 unused 0 0 # (Cyl. 4175*- 12498*)
and then overwrite the label area:
# dd if=/dev/zero of=/dev/rwd1a bs=1024 count=1
this is suboptimal.
the user should be able to use the raw 'c' partition for this purpose,
and there should be a way to query the status of kernel disklabel
protection.
the kernel should also log a message when label protection results
in EROFS, and hint at "disklabel -W".
>Release-Note:
>Audit-Trail:
>Unformatted: