Subject: bin/32121: disklabel copies MBR to PBR
To: None <gnats-admin@netbsd.org, netbsd-bugs@netbsd.org>
From: None <mjl@emsi.priv.at>
List: netbsd-bugs
Date: 11/19/2005 14:50:01
>Number: 32121
>Category: bin
>Synopsis: disklabel copies MBR to PBR
>Confidential: no
>Severity: serious
>Priority: high
>Responsible: bin-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sat Nov 19 14:50:01 +0000 2005
>Originator: Martin J. Laubach
>Release: NetBSD 3.0_RC1
>Organization:
>Environment:
System: NetBSD asparagus.emsi.priv.at 3.0_RC1 NetBSD 3.0_RC1 (ASPARAGUS.l) #0: Thu Nov 17 22:54:18 UTC 2005 root@asparagus.emsi.priv.at:/sys30/arch/i386/compile/ASPARAGUS.l i386
Architecture: i386
Machine: i386
>Description:
I'm trying to build a disk image to dd to a compact flash card. I'm
using the following snipped of script to prepare the image file (I've
left out the next steps, I know that this is not enough).
--- cut ---
#!/bin/sh -x
C=948 H=8 S=32
img=$HOME/disk.image
blks=$(( $C * $H * $S ))
sc=$(( $H * $S ))
csize=$(( $blks - $S ))
dd if=/dev/zero of=$img bs=512 count=$blks
echo > disktab "vnd:dt=vnd:se#512:ns#$S:nt#$H:sc#$sc:nc#$C:su#$blks:pa#4000:oa#32:ta=4.2BSD:ba#4096:fa#512:pc#$csize:oc#32:pd#$blks:od#0:"
fdisk -b $C/$H/$S -t disktab -T vnd -ua -F -0s 169/$S/$csize -f $img
disklabel -w -r -f disktab -F $img vnd
--- cut ---
This should build me an image with an MBR and a NetBSD partition
containing a correct PBR.
However, inspection of the resulting image shows that
| $ dd if=~/disk.image of=m1 bs=512 count=1
| 1+0 records in
| 1+0 records out
|
| $ dd if=~/disk.image of=m2 bs=512 count=1 skip=32
| 1+0 records in
| 1+0 records out
|
| $ cmp m1 m2 && echo "identical"
| identical
That is, the data in the PBR is in fact the MBR.
The net result is quite logically an endless loop spewing
"NetBSD MBR boot". I found an old post by David Laights on port-amd
where he says:
| That is caused by a bug in disklabel(8) that causes it to write the
| mbr sector to the pbr after sysinst has written out the correct data
| to the pbr.
which sounds exactly like what I'm seeing.
I tried it with different CF cards with different geometries, same
result.
>How-To-Repeat:
Run script above and check the image file.
>Fix: