Subject: Re: bin/32121: disklabel copies MBR to PBR
To: None <gnats-admin@netbsd.org, netbsd-bugs@netbsd.org>
From: Martin J. Laubach <mjl@emsi.priv.at>
List: netbsd-bugs
Date: 11/19/2005 15:08:02
The following reply was made to PR bin/32121; it has been noted by GNATS.

From: "Martin J. Laubach" <mjl@emsi.priv.at>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: bin/32121: disklabel copies MBR to PBR
Date: Sat, 19 Nov 2005 16:07:26 +0100

    Some more details:
 
    The full script is here
 
 --- 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
 
 vnconfig -v vnd0 $img
 
 newfs /dev/vnd0a
 mount /dev/vnd0a /mnt
 cp /usr/mdec/boot /mnt
 cp netbsd /mnt
 umount /mnt
 
 /usr/sbin/installboot -v -o timeout=300,console=com0,speed=19200 /dev/ 
 rvnd0a /usr/mdec/bootxx_ffsv1 /boot
 
 vnconfig -u vnd0
 --- cut ---
 
    But this does not change much. I added debug output to /usr/mdec/ 
 mbr and see
 it looping, calling boot_lba over and over again. The sector number  
 passed in
 is correct.
 
    Output looks like
 
 NetBSD MBR boot
 LBA boot 00000020
 NetBSD MBR boot
 LBA boot 00000020
 NetBSD MBR boot
 ...
 
    which indicates mentioned loop. 0x20 is correct as starting block  
 for the
 netbsd partition though.
 
    I could also trace it that it jumps to the loaded PBR sector. The
 partition starts with this, somehow this is returning to the MBR code,
 or perhaps the address the MBR code jumps to is wrong?
 
 00004000  eb 3c 90 4e 65 74 42 53  44 32 30 89 e6 bf 00 06   
 |.<.NetBSD20.....|
 00004010  b9 00 01 f3 a5 b9 00 02  f3 ab ea 1f 06 00 00 80   
 |................|
 00004020  fa 8f 7e 02 b2 80 52 52  be da 06 e8 12 01 bb 94   
 |..~...RR........|
 00004030  07 8d af 2a 00 8a 46 04  66 8b 7e 08 66 03 31 c0   
 |...*..F.f.~.f.1.|
 00004040  8e d8 8e c0 8e d0 bc fc  ff 52 cd 13 5a b9 01 00   
 |.........R..Z...|
 00004050  88 ee e8 f2 00 66 31 ed  66 8b 07 66 3b 06 00 7c   
 |.....f1.f..f;..||
 00004060  74 70 66 31 db 66 31 c9  bf be 07 8a 45 04 66 8b  | 
 tpf1.f1.....E.f.|
 00004070  6d 08 66 03 2e a3 7d 3c  a9 75 0a 66 85 f6 74 54  |m.f...} 
 <.u.f..tT|
 00004080  66 39 ee 74 4f 3c 05 74  08 3c 0f 74 04 3c 85 75  | 
 f9.tO<.t.<.t.<.u|
 00004090  04 66 8b 4d 08 83 c7 10  81 ff fe 07 75 cd 67 e3   
 |.f.M........u.g.|
 000040a0  15 66 85 db 75 03 66 87  d9 66 01 d9 66 89 0e a3   
 |.f..u.f..f..f...|
 000040b0  7d e8 84 00 eb af 66 85  f6 b8 77 7d 74 4c 66 31   
 |}.....f...w}tLf1|
 000040c0  f6 66 89 36 a3 7d e9 37  ff 8a 75 01 8b 4d 02 e8  |.f.6.}. 
 7..u..M..|
 000040d0  75 00 eb 4e 66 89 2e a3  7d 66 85 db 75 41 52 b4  |u..Nf...} 
 f..uAR.|
 000040e0  08 cd 13 8b 45 02 50 c0  e8 06 86 c4 c1 ea 08 42   
 |....E.P........B|
 000040f0  f7 e2 8a 55 01 01 d0 83  e1 3f f7 e1 5a 83 e2 3f   
 |...U.....?..Z..?|
 00004100  01 d0 48 5a 39 e8 74 c1  eb 15 50 be 50 7d e8 7a   
 |..HZ9.t...P.P}.z|
 00004110  00 5e e8 76 00 be 57 7d  e8 70 00 fb f4 eb fc e8   
 |.^.v..W}.p......|
 00004120  16 00 66 81 3e 04 0a d1  b6 86 78 b8 64 7d 75 da   
 |..f.>.....x.d}u.|
 00004130  66 89 ee ea 00 0a 00 00  60 be 9b 7d b4 42 cd 13  | 
 f.......`..}.B..|
 00004140  61 b8 5a 7d 72 c4 c3 bb  00 06 60 b8 0f 02 eb ee  |a.Z} 
 r.....`.....|
 00004150  45 72 72 6f 72 20 00 0d  0a 00 44 69 73 6b 20 72  | 
 Error ....Disk r|
 00004160  65 61 64 00 4e 6f 74 20  61 20 62 6f 6f 74 78 78  |ead.Not  
 a bootxx|
 00004170  20 69 6d 61 67 65 00 4e  6f 20 4e 65 74 42 53 44  |  
 image.No NetBSD|
 00004180  20 70 61 72 74 69 74 69  6f 6e 00 60 ac b4 0e bb  |  
 partition.`....|
 00004190  01 00 cd 10 ac 84 c0 75  f4 61 c3 10 00 0f 00 00   
 |.......u.a......|
 000041a0  06 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   
 |................|
 000041b0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 80 01   
 |................|
 000041c0  01 00 a9 07 e0 b3 20 00  00 00 e0 b3 03 00 00 00   
 |...... .........|
 000041d0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00   
 |................|
 *
 000041f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 55 aa   
 |..............U.|
 
    I could use some assistance in tracking that problem down, i386  
 assembler is
 not really my speciality...