Subject: Re: port-i386/4089: Prevent disklabel from destroying boot blocks
To: None <gnats-bugs@gnats.netbsd.org>
From: Hiroyuki Ito <hiroy@netcom.com>
List: netbsd-bugs
Date: 09/08/1997 09:10:30
I forgot to write about an important case.

+>How-To-Repeat:
% alias pt hexdump -e \''"%06_ad " 8/1 " %02x" 2/4 " %8d" "\n"'\' \
        -v -s `expr 512 - \( 16 \* 4 + 2 \)` -n `expr 16 \* 4 + 2`
% alias pt
hexdump -e '"%06_ad " 8/1 " %02x" 2/4 " %8d" "\n"' -v -s 446 -n 66
% jot -c -s "" -n `expr 512 \* 15` 229 - 0 > e5x15
% 
% dd if=/dev/rsd0d of=mbr+15 count=16
16+0 records in
16+0 records out
8192 bytes transferred in 1 secs (8192 bytes/sec)
% 
% (dd if=mbr+15 count=1; cat e5x15) > xxx
1+0 records in
1+0 records out
512 bytes transferred in 1 secs (512 bytes/sec)
% dd if=xxx of=/dev/rsd0d
16+0 records in
16+0 records out
8192 bytes transferred in 1 secs (8192 bytes/sec)
% /sbin/disklabel -r sd0 | diff - protofile0
% pt xxx
000446  00 01 01 00 06 3f 20 77       32   245728
000462  00 00 01 78 05 3f 20 ef   245760   245760
000478  00 00 00 00 00 00 00 00        0        0
000494  80 00 01 f0 a5 3f e0 fe   491520  1603584
000510  55 aa                                    
% echo "" | dd of=xxx bs=1 seek=498 conv=notrunc
1+0 records in
1+0 records out
1 bytes transferred in 1 secs (1 bytes/sec)
% pt xxx
000446  00 01 01 00 06 3f 20 77       32   245728
000462  00 00 01 78 05 3f 20 ef   245760   245760
000478  00 00 00 00 00 00 00 00        0        0
000494  80 00 01 f0 0a 3f e0 fe   491520  1603584
000510  55 aa                                    
% dd if=xxx of=/dev/rsd0d
16+0 records in
16+0 records out
8192 bytes transferred in 1 secs (8192 bytes/sec)
% /sbin/disklabel -r sd0
disklabel: warning, DOS partition table with no valid NetBSD partition
disklabel: no disk label
% /sbin/disklabel -Rr sd0 protofile0
disklabel: warning, DOS partition table with no valid NetBSD partition
Erase the previous contents of the disk? [n]: y
% /sbin/disklabel -r sd0 | diff protofile0 -
% dd if=/dev/rsd0d of=xxx count=16
16+0 records in
16+0 records out
8192 bytes transferred in 1 secs (8192 bytes/sec)
% hd -n 512 xxx
000000  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
*
% hd -s 512 xxx | head -1
000200  57 45 56 82 04 00 00 00 6d 79 73 64 30 00 00 00  WEV.....mysd0...
% hd -s `expr 512 \* 2` xxx
000400  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
*
% 
% (dd if=mbr+15 count=1; cat e5x15) > xxx
1+0 records in
1+0 records out
512 bytes transferred in 1 secs (512 bytes/sec)
% dd if=xxx of=/dev/rsd0d
16+0 records in
16+0 records out
8192 bytes transferred in 1 secs (8192 bytes/sec)
% ./disklabel -r sd0 | diff - protofile0
% echo "" | dd of=xxx bs=1 seek=498 conv=notrunc
1+0 records in
1+0 records out
1 bytes transferred in 1 secs (1 bytes/sec)
% hd -v -n 512 xxx > xxx0.hd
% dd if=xxx of=/dev/rsd0d
16+0 records in
16+0 records out
8192 bytes transferred in 1 secs (8192 bytes/sec)
% ./disklabel -r sd0
disklabel: warning, DOS partition table with no valid NetBSD partition
disklabel: no disk label
% ./disklabel -Rr sd0 protofile
disklabel: warning, DOS partition table with no valid NetBSD partition
Erase the previous contents of the disk? [n]: y
% ./disklabel -r sd0 | diff protofile -
disklabel: warning, DOS partition table with no valid NetBSD partition
% dd if=/dev/rsd0d of=xxx count=16
16+0 records in
16+0 records out
8192 bytes transferred in 1 secs (8192 bytes/sec)
% hd -v -n 512 xxx | diff xxx0.hd -
% hd -s 512 xxx | head -1
000200  57 45 56 82 04 00 00 00 6d 79 73 64 00 00 00 00  WEV.....mysd....
% hd -s `expr 512 \* 2` xxx
000400  e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5 e5  ................
*
% 
% dd if=mbr+15 of=/dev/rsd0d
16+0 records in
16+0 records out
8192 bytes transferred in 1 secs (8192 bytes/sec)
% disklabel -r sd0 | diff - protofile0
% 

Hiroyuki Ito