Sorry for top-posting, but please: Disk sectors start with 1 (unless you are
reformatting the entire track and something like Write Record zero still
exists)
On DOS-FORMATTED disks, the initial sector is at cylinder 0, head 0, sector 1,
and contains within the bootstrap loader what DOS and Windows calls a
Partition Table.
The rest of track 0 is empty, unless you are running a boot sector virus or
such.

-----Original Message-----
From: owner-m...@openbsd.org [mailto:owner-m...@openbsd.org] On Behalf Of
Kenneth R Westerback
Sent: Friday, October 30, 2009 5:38 PM
To: Josh Grosse
Cc: Amarendra Godbole; misc
Subject: Re: Partitioning an external USB drive through OpenBSD -- disklabel

On Fri, Oct 30, 2009 at 08:53:45AM -0500, Josh Grosse wrote:
> On Fri, 30 Oct 2009 18:44:08 +0530, Amarendra Godbole wrote
>
> > Thank you all for responses -- I have a better idea now. The only
> > thing that I noticed was newfs_msdos wipes out the entire disklabel
> > as well as any fdisk created partitions and gobbles up the entire disk.
> >
> > I guess what James Hartley said in this thread is correct -- Windows
> > must be used to create the DOS partition, and then disklabel to get
> > the OpenBSD one.
>
> No, the reason the MBR and disklabel were wiped out was due to an error you
> made: starting the partition at sector #0.  That sector contians the MBR
and
> the MBR primary partition table, and the OpenBSD disklabel follows behind.
>
> Normally, one would begin the first partition -after- the first track
> (typically sectors 0-62).
>
> But, If you were to use Windows disk management to create a FAT partition
of
> some size on the disk, Windows will begin it at sector #63 for you.
Knowledge
> of disk geometry and usage is not required by a Windows user, as the tools
do
> not allow you the control that fdisk(8) does.

On MBR formatted disks, sector 0 is the MBR. So overwriting that
will indeed toast important information about the disk.

However the OpenBSD disklabel is not written to the sector after
the MBR if there is an OpenBSD partition, it is written to the
second sector of the first OpenBSD partition. So whacking the MSDOS
partition starting at sector 0 toasts the MBR, which means the
OpenBSD partition cannot be found, which means the disklabel is
inaccessable. If you were to re-create the MBR with the correct
partitions, the disklabel would re-appear.  The MSDOS parition would
now be broken of course. :-).

As an example here is one of my disks, and a hexdump of the first
65 sectors. The MBR can be seen at sector 0, and the disklabel
at sector 64. (64*512 = 32768 = 0x8000).

You'll have to take my word I did

dd if=/dev/rsd0c of=~/tmp/sect0to64 bs=512 count=65
hexdump -C ~/tmp/sect0to64 > ~/tmp/sect0to64.txt

.... Ken


Script started on Fri Oct 30 18:11:16 2009
# fdisk sd0
Disk: sd0       geometry: 38913/255/63 [625142448 Sectors]
Offset: 0       Signature: 0xAA55
            Starting         Ending         LBA Info:
 #: id      C   H   S -      C   H   S [       start:        size ]
-----------------------------------------------------------------------------
--
 0: 00      0   0   0 -      0   0   0 [           0:           0 ] unused
 1: 00      0   0   0 -      0   0   0 [           0:           0 ] unused
 2: 00      0   0   0 -      0   0   0 [           0:           0 ] unused
*3: A6      0   1   1 -  38912 254  63 [          63:   625137282 ] OpenBSD
# disklabel sd0
# /dev/rsd0c:
type: SCSI
disk: SCSI disk
label: WDC WD3200AAKS-0
flags:
bytes/sector: 512
sectors/track: 63
tracks/cylinder: 255
sectors/cylinder: 16065
cylinders: 38913
total sectors: 625142448
rpm: 3600
interleave: 1
boundstart: 63
boundend: 625137345
drivedata: 0

16 partitions:
#                size           offset  fstype [fsize bsize  cpg]
  a:           417627               63  4.2BSD   2048 16384    1 # /
  b:         25173855           417690    swap
  c:        625142448                0  unused
  d:           417690         25591545  4.2BSD   2048 16384    1 # /tmp
  e:           417690         26009235  4.2BSD   2048 16384    1 # /var
  g:         20980890         26426925  4.2BSD   2048 16384    1 # /usr
  h:        514786860        110350485  4.2BSD   2048 16384    1 # /home
  i:         20980890         47407815  4.2BSD   2048 16384    1 # /usr/src
  j:         20980890         68388705  4.2BSD   2048 16384    1 # /usr/ports
  k:         20980890         89369595  4.2BSD   2048 16384    1 #
/usr/xenocara
# cat sect0to64.txt
00000000  ea 05 00 c0 07 8c c8 8e  d0 bc fc ff 8e d8 b8 a0  |j...@..h.p<|.X8
|
00000010  07 8e c0 31 f6 31 ff b9  00 02 fc f3 a4 ea 22 00
|....@1v19..|s$j".|
00000020  a0 07 1e 07 0e 1f b4 02  cd 16 a8 03 74 0a b0 07  |
.....4.M.(.t.0.|
00000030  e8 cb 00 80 0e b4 01 01  f6 c2 80 75 08 be 36 01
|hK...4..vB.u.>6.|
00000040  e8 af 00 b2 80 be be 01  b9 04 00 8a 04 3c 80 74
|h/.2.>>.9....<.t|
00000050  0f 83 c6 10 e2 f5 be 6a  01 e8 96 00 fb f4 eb fc
|..F.bu>j.h..{tk||
00000060  88 d0 24 0f 04 30 a2 27  01 b0 34 28 c8 a2 34 01
|.P$..0"'.04(H"4.|
00000070  56 be 1a 01 f6 06 b4 01  01 75 01 46 e8 73 00 5e
|V>..v.4..u.Fhs.^|
00000080  26 c7 06 fe 01 00 00 f6  06 b4 01 01 75 31 88 14
|&G.~...v.4..u1..|
00000090  bb aa 55 b4 41 cd 13 8a  14 72 24 81 fb 55 aa 75
|;*U4AM...r$.{U*u|
000000a0  1e f6 c1 01 74 19 b0 2e  e8 53 00 66 8b 4c 08 66
|.vA.t.0.hS.f.L.f|
000000b0  89 0e 12 01 56 b4 42 be  0a 01 cd 13 5e 73 19 b0
|....V4B>..M.^s.0|
000000c0  3b e8 3a 00 8a 74 01 8b  4c 02 b8 01 02 31 db cd
|;h:..t..L.8..1[M|
000000d0  13 73 05 be 52 01 eb 81  be 7d 01 e8 14 00 26 81
|.s.>R.k.>}.h..&.|
000000e0  3e fe 01 55 aa 75 05 ea  00 7c 00 00 be 61 01 e9
|>~.U*u.j.|..>a.i|
000000f0  67 ff 50 fc ac 84 c0 74  0f e8 02 00 eb f6 50 53
|gP|,....@t.h..kvps|
00000100  b4 0e bb 01 00 cd 10 5b  58 c3 10 00 01 00 00 00
|4.;..M.[XC......|
00000110  c0 07 00 00 00 00 00 00  00 00 21 55 73 69 6e 67
|@.........!Using|
00000120  20 64 72 69 76 65 20 58  2c 20 70 61 72 74 69 74  | drive X,
partit|
00000130  69 6f 6e 20 59 00 4d 42  52 20 6f 6e 20 66 6c 6f  |ion Y.MBR on
flo|
00000140  70 70 79 20 6f 72 20 6f  6c 64 20 42 49 4f 53 0d  |ppy or old
BIOS.|
00000150  0a 00 0d 0a 52 65 61 64  20 65 72 72 6f 72 0d 0a  |....Read
error..|
00000160  00 4e 6f 20 4f 2f 53 0d  0a 00 4e 6f 20 61 63 74  |.No O/S...No
act|
00000170  69 76 65 20 70 61 72 74  69 74 69 6f 6e 0d 0a 00  |ive
partition...|
00000180  90 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
|................|
00000190  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
|................|
*
000001b0  00 00 00 00 00 00 4f 78  00 00 00 00 00 00 00 00
|......Ox........|
000001c0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
|................|
*
000001e0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 80 01
|................|
000001f0  01 00 a6 fe ff ff 3f 00  00 00 82 d6 42 25 55 aa
|..&~?....VB%U*|
00000200  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
|................|
*
00007e00  eb 3c 90 4f 70 65 6e 42  53 44 00 00 02 02 00 00
|k<.OpenBSD......|
00007e10  00 00 00 00 00 f8 00 00  00 00 00 00 10 00 00 00
|.....x..........|
00007e20  00 00 00 00 00 00 29 00  00 00 00 55 4e 49 58 20  |......)....UNIX
|
00007e30  4c 41 42 45 4c 55 46 53  20 34 2e 34 00 00 ea 48  |LABELUFS
4.4..jH|
00007e40  00 c0 07 b0 58 e9 37 01  31 c0 8e d0 bc fc 7b 0e
|....@.0xi7.1@.P<|{.|
00007e50  1f be e4 01 88 d6 b4 02  cd 16 0c 00 a8 03 74 03
|.>d..V4.M...(.t.|
00007e60  4e 30 f6 e8 56 01 f6 c6  80 74 1e 52 bb aa 55 b4
|N0vhV.vF.t.R;*U4|
00007e70  41 cd 13 5a 72 13 81 fb  55 aa 75 0d f6 c1 01 74
|AM.Zr..{U*u.vA.t|
00007e80  08 c7 06 d1 01 84 01 eb  1a 52 b4 08 cd 13 72 b3
|.G.Q...k.R4.M.r3|
00007e90  88 36 55 01 80 e1 3f 74  aa 88 0e 4c 01 b0 3b e8
|.6U..a?t*..L.0;h|
00007ea0  25 01 5a 66 b8 18 00 00  00 bb e0 07 ff 16 d1 01
|%.Zf8....;`..Q.|
00007eb0  66 be 28 08 00 00 bf 03  00 89 f9 83 f9 0c 72 03
|f>(...?...y.y.r.|
00007ec0  b9 0c 00 bb 00 40 b0 2e  e8 fc 00 fc 66 ad 66 60
|9..;....@0.h|.|f-f`|
00007ed0  ff 16 d1 01 66 61 81 c3  00 04 4f e2 e9 09 ff 74
|.Q.fa.C..Obi.t|
00007ee0  22 b8 49 00 08 e4 0f 85  95 00 fe 06 e3 00 66 ad
|"8I..d....~.c.f-|
00007ef0  53 bb e0 07 ff 16 d1 01  5b 66 be 00 02 00 00 89
|S;`..Q.[f>.....|
00007f00  f9 eb c3 be f3 01 e8 b3  00 b8 00 40 8e c0 26 81
|ykC>s.h3...@.@&.|
00007f10  3e 02 00 4c 46 74 0f b0  4d be ee 01 a2 f2 01 e8
|>..LFt.0M>n."r.h|
00007f20  9a 00 fb f4 eb fc 51 88  d1 51 66 68 0d d0 01 c0
|..{tk|Q.QQfh.P.@|
00007f30  ea 00 00 12 40 e8 5d 00  66 a1 db 01 8b 0e d5 01
|j...@h].f![...u.|
00007f40  66 60 8e c3 52 66 31 d2  66 89 d1 b1 90 66 f7 f1
|f`.CRf1Rf.Q1.fwq|
00007f50  52 66 31 d2 b1 90 41 66  f7 f1 88 c5 c0 e4 06 88
|rf1r1.afw...@d..|
00007f60  e1 5b fe c3 08 d9 58 88  d6 88 c2 31 db b8 01 02
|a[~C.YX.V.B1[8..|
00007f70  e8 1d 00 66 61 66 40 83  c3 20 e2 c4 c3 b0 52 be  |h.....@.c
bDC0R>|
00007f80  ec 01 eb 98 e8 0e 00 89  1e d9 01 be d3 01 b4 42
|l.k.h....Y.>S.4B|
00007f90  cd 13 72 e9 c3 b9 20 02  66 50 28 e9 66 d3 e8 66  |M.riC9
.fP(ifShf|
00007fa0  a3 df 01 66 58 88 e9 66  d3 e0 66 05 3f 00 00 00
|#_.fX.ifS`f.?...|
00007fb0  66 a3 db 01 73 05 66 ff  06 df 01 c3 fc ac 08 c0
|f#[.s.f._.C|,.@|
00007fc0  74 0e e8 02 00 eb f6 53  b4 0e 31 db 43 cd 10 5b
|t.h..kvS4.1[CM.[|
00007fd0  c3 35 01 10 00 20 00 00  00 00 00 00 00 00 00 00  |C5...
..........|
00007fe0  00 00 00 21 4c 6f 61 64  69 6e 67 00 0d 0a 45 52
|...!Loading...ER|
00007ff0  52 20 3f 0d 0a 00 00 00  00 00 00 00 00 00 55 aa  |R
?...........U*|
00008000  57 45 56 82 04 00 00 00  53 43 53 49 20 64 69 73  |WEV.....SCSI
dis|
00008010  6b 00 00 00 00 00 00 00  57 44 43 20 57 44 33 32  |k.......WDC
WD32|
00008020  30 30 41 41 4b 53 2d 30  00 02 00 00 3f 00 00 00
|00AAKS-0....?...|
00008030  ff 00 00 00 01 98 00 00  c1 3e 00 00 b0 ea 42 25
|.......A>..0jB%|
00008040  00 00 00 00 00 00 00 00  10 0e 01 00 00 00 00 00
|................|
00008050  3f 00 00 00 c1 d6 42 25  00 00 00 00 00 00 00 00
|?...AVB%........|
00008060  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
|................|
00008070  00 00 01 00 00 00 00 00  00 00 00 00 00 00 00 00
|................|
00008080  00 00 00 00 57 45 56 82  48 46 10 00 00 20 00 00  |....WEV.HF...
..|
00008090  00 20 00 00 5b 5f 06 00  3f 00 00 00 00 00 00 00  |.
..[_..?.......|
000080a0  07 14 01 00 5f 1f 80 01  9a 5f 06 00 00 00 00 00
|...._...._......|
000080b0  01 00 00 00 b0 ea 42 25  00 00 00 00 00 00 00 00
|....0jB%........|
000080c0  00 00 00 00 9a 5f 06 00  f9 7e 86 01 00 00 00 00
|....._..y~......|
000080d0  07 14 01 00 9a 5f 06 00  93 de 8c 01 00 00 00 00
|....._...^......|
000080e0  07 14 01 00 00 00 00 00  00 00 00 00 00 00 00 00
|................|
000080f0  00 00 00 00 9a 24 40 01  2d 3e 93 01 00 00 00 00
|......@.->......|
00008100  07 14 01 00 2c 06 af 1e  95 d0 93 06 00 00 00 00
|....,./..P......|
00008110  07 14 01 00 9a 24 40 01  c7 62 d3 02 00 00 00 00
|......@.gbs.....|
00008120  07 14 01 00 9a 24 40 01  61 87 13 04 00 00 00 00
|......@.a.......|
00008130  07 14 01 00 9a 24 40 01  fb ab 53 05 00 00 00 00
|......@.{+s.....|
00008140  07 14 01 00 00 00 00 00  00 00 00 00 00 00 00 00
|................|
00008150  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
|................|
*
00008200
# exit
Script done on Fri Oct 30 18:11:39 2009

Reply via email to