Discussion:
newfs: cg 0: bad magic number
Xavier Mertens
2008-01-03 00:29:23 UTC
Permalink
Hi *,

I'm trying to build a new FS on an IDE disk.
All newfs commands end with:

# newfs /dev/rwd1a
..
..
newfs: cg 0: bad magic number
newfs: fsinit1 failed

Here is the disk info:

# disklabel wd1
# /dev/rwd1c:
type: ESDI
disk: ESDI/IDE disk
label: Maxtor 6B250R0
flags:
bytes/sector: 512
sectors/track: 63
tracks/cylinder: 255
sectors/cylinder: 16065
cylinders: 30515
total sectors: 490234752
rpm: 3600
interleave: 1
trackskew: 0
cylinderskew: 0
headswitch: 0 # microseconds
track-to-track seek: 0 # microseconds
drivedata: 0

16 partitions:
# size offset fstype [fsize bsize cpg]
a: 48195 0 4.2BSD 2048 16384 16
c: 490234752 0 unused 0 0


(I tried several fs size (stard or end of the disk, same error)

Any idea?

Xavier
--
Weird enough for government work.
Xavier Mertens
2008-01-03 00:43:44 UTC
Permalink
Strange... fdisk wd1 reports:

# fdisk wd1
Disk: wd1 geometry: 30515/255/63 [490234752 Sectors]
Offset: 0 Signature: 0x180
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: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused

When I create some partitions, write them to the disk, restart fdisk, I'm back
to the same empty config. Is my disk physically dead? :(

Xavier
--
There's no place like ~
Post by Xavier Mertens
Hi *,
I'm trying to build a new FS on an IDE disk.
# newfs /dev/rwd1a
..
..
newfs: cg 0: bad magic number
newfs: fsinit1 failed
# disklabel wd1
type: ESDI
disk: ESDI/IDE disk
label: Maxtor 6B250R0
bytes/sector: 512
sectors/track: 63
tracks/cylinder: 255
sectors/cylinder: 16065
cylinders: 30515
total sectors: 490234752
rpm: 3600
interleave: 1
trackskew: 0
cylinderskew: 0
headswitch: 0 # microseconds
track-to-track seek: 0 # microseconds
drivedata: 0
# size offset fstype [fsize bsize cpg]
a: 48195 0 4.2BSD 2048 16384 16
c: 490234752 0 unused 0 0
(I tried several fs size (stard or end of the disk, same error)
Any idea?
Xavier
--
Weird enough for government work.
Martin Schröder
2008-01-03 00:56:12 UTC
Permalink
Post by Xavier Mertens
When I create some partitions, write them to the disk, restart fdisk, I'm back
to the same empty config. Is my disk physically dead? :(
http://www.openbsd.org/faq/faq4.html#Install
4.5.2:

"On platforms which use fdisk, it is important that the first
partition skips the first track of the disk, in this case, starting on
sector 63. This will vary from machine to machine and disk system to
disk system. If an OpenBSD partition is created starting at offset 0,
this partition table will end up being overwritten by the OpenBSD
partition's Partition Boot Record. The system may still be bootable,
but it will be very difficult to maintain, and this configuration is
not recommended or supported."

Best
Martin
Nick Holland
2008-01-03 01:05:10 UTC
Permalink
Good thing OpenBSD only runs on one platform and one type of computer,
eh?

Xavier Mertens wrote:
...
Post by Xavier Mertens
# size offset fstype [fsize bsize cpg]
a: 48195 0 4.2BSD 2048 16384 16
c: 490234752 0 unused 0 0
Assuming this is i386 (what people usually assume when they don't
bother to show dmesg or even mention platform), you need a one
cylinder offset on your 'a' partition (or more accurately, your
first partition. TYPICALLY, that's 63 sectors, but not always).
What you have here clobbers your MBR, which holds your (now hosed)
fdisk partitions.

see faq4.html.

Nick.
Xavier Mertens
2008-01-03 01:14:53 UTC
Permalink
Indeed, this test was bad...
But the same occurs with an offset of 63 sectors :(

Same with fdisk:

fdisk: 1> edit 3
Starting Ending LBA Info:
#: id C H S - C H S [ start: size ]
------------------------------------------------------------------------
3: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused
Partition id ('0' to disable) [0 - FF]: [0] (? for help) A6
Do you wish to edit in CHS mode? [n]
offset: [0] 63
size: [0] 488392002
fdisk:*1> q
Writing current MBR to disk.
bash-3.2# fdisk wd1
Disk: wd1 geometry: 30515/255/63 [490234752 Sectors]
Offset: 0 Signature: 0x100
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: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused


Xavier
--
Secret hacker rule #11: hackers read manuals.
Post by Nick Holland
Good thing OpenBSD only runs on one platform and one type of computer,
eh?
..
Post by Xavier Mertens
# size offset fstype [fsize bsize cpg]
a: 48195 0 4.2BSD 2048 16384 16
c: 490234752 0 unused 0 0
Assuming this is i386 (what people usually assume when they don't
bother to show dmesg or even mention platform), you need a one
cylinder offset on your 'a' partition (or more accurately, your
first partition. TYPICALLY, that's 63 sectors, but not always).
What you have here clobbers your MBR, which holds your (now hosed)
fdisk partitions.
see faq4.html.
Nick.
Ted Unangst
2008-01-03 01:12:01 UTC
Permalink
Post by Xavier Mertens
# size offset fstype [fsize bsize cpg]
a: 48195 0 4.2BSD 2048 16384 16
your partition is not properly offset from the beginning of the disk,
where all the goodies like mbr need to live.
Xavier Mertens
2008-01-03 01:28:29 UTC
Permalink
Ok,

I fixed the disk partitions:

# fdisk wd1
Disk: wd1 geometry: 30515/255/63 [490234752 Sectors]
Offset: 0 Signature: 0x0
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: A6 0 1 1 - 30514 254 63 [ 63: 490223412 ] OpenBSD
2: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused
3: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused

# disklabel wd1
# Inside MBR partition 1: type A6 start 63 size 490223412
# /dev/rwd1c:
type: ESDI
disk: ESDI/IDE disk
label: Maxtor 6B250R0
flags:
bytes/sector: 512
sectors/track: 63
tracks/cylinder: 255
sectors/cylinder: 16065
cylinders: 30515
total sectors: 490234752
rpm: 3600
interleave: 1
trackskew: 0
cylinderskew: 0
headswitch: 0 # microseconds
track-to-track seek: 0 # microseconds
drivedata: 0

16 partitions:
# size offset fstype [fsize bsize cpg]
a: 490223412 63 4.2BSD 2048 16384 16
c: 490234752 0 unused 0 0

But I still have the same error at the end of the newfs:

newfs: cg 0: bad magic number
newfs: fsinit1 failed

:(

Xavier
--
Hint: A reload a day, keeps the TAC away .....
Post by Ted Unangst
Post by Xavier Mertens
# size offset fstype [fsize bsize cpg]
a: 48195 0 4.2BSD 2048 16384 16
your partition is not properly offset from the beginning of the disk,
where all the goodies like mbr need to live.
Xavier Mertens
2008-01-03 07:02:40 UTC
Permalink
Is that normal to have a signature of "0x0" reported by fdisk?
On my other disks, signature is 0xAA55.
Thanks for your help!

-----Original Message-----
From: owner-***@openbsd.org [mailto:owner-***@openbsd.org] On Behalf Of
Xavier Mertens
Sent: jeudi 3 janvier 2008 2:28
To: ***@openbsd.org
Subject: Re: newfs: cg 0: bad magic number

Ok,

I fixed the disk partitions:

# fdisk wd1
Disk: wd1 geometry: 30515/255/63 [490234752 Sectors]
Offset: 0 Signature: 0x0
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: A6 0 1 1 - 30514 254 63 [ 63: 490223412 ] OpenBSD
2: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused
3: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused

# disklabel wd1
# Inside MBR partition 1: type A6 start 63 size 490223412 # /dev/rwd1c:
type: ESDI
disk: ESDI/IDE disk
label: Maxtor 6B250R0
flags:
bytes/sector: 512
sectors/track: 63
tracks/cylinder: 255
sectors/cylinder: 16065
cylinders: 30515
total sectors: 490234752
rpm: 3600
interleave: 1
trackskew: 0
cylinderskew: 0
headswitch: 0 # microseconds
track-to-track seek: 0 # microseconds
drivedata: 0

16 partitions:
# size offset fstype [fsize bsize cpg]
a: 490223412 63 4.2BSD 2048 16384 16
c: 490234752 0 unused 0 0

But I still have the same error at the end of the newfs:

newfs: cg 0: bad magic number
newfs: fsinit1 failed

:(

Xavier
--
Hint: A reload a day, keeps the TAC away .....
Post by Ted Unangst
Post by Xavier Mertens
# size offset fstype [fsize bsize cpg]
a: 48195 0 4.2BSD 2048 16384 16
your partition is not properly offset from the beginning of the disk,
where all the goodies like mbr need to live.
Stuart Henderson
2008-01-03 10:22:41 UTC
Permalink
Post by Xavier Mertens
Is that normal to have a signature of "0x0" reported by fdisk?
On my other disks, signature is 0xAA55.
You overwrote things you shouldn't have when newfs'ing with
offset=0.

Scribble some zeros over the start of the disk (dd if=/dev/zero
of=/dev/rwd1c count=1k is more than enough), reboot (I can't
remember if this is needed, but it doesn't hurt), fdisk -i wd1,
disklabel -E wd1 (gives you the interactive editor from the
installer which suggests the correct offset), newfs.

Loading...