*BSD News Article 49911


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.anu.edu.au!harbinger.cc.monash.edu.au!yarrina.connect.com.au!warrane.connect.com.au!gamera.zeta.org.au!not-for-mail
From: bde@zeta.org.au (Bruce Evans)
Newsgroups: comp.unix.bsd.freebsd.misc
Subject: Re: Adding second disk drive
Date: 3 Sep 1995 11:21:59 +1000
Organization: Kralizec Dialup Unix Sydney - +61-2-837-1183, v.32bis v.42bis
Lines: 79
Message-ID: <42avvn$k7a@godzilla.zeta.org.au>
References: <GILHAM.95Aug29180829@lily.csl.sri.com>
NNTP-Posting-Host: godzilla.zeta.org.au

In article <GILHAM.95Aug29180829@lily.csl.sri.com>,
Fred Gilham <gilham@lily.csl.sri.com> wrote:

>I`ve added a Seagate 4gb hawk drive to the system and struggled with
>it this afternoon to get it labeled so I could newfs it.  I get
>various error messages, such as 
>
>Aug 29 17:40:03 phlox /kernel: sd1: raw partition size != slice size
>Aug 29 17:40:03 phlox /kernel: sd1: start 32, end 8385898, size 8385867
>Aug 29 17:40:03 phlox /kernel: sd1c: start 32, end 8380931, size 8380900

This is probably caused by not telling disklabel the number of sectors
on the disk (su# in /etc/disktab or sectors/unit: in the text file
created by disklabel -e).  disklabel then defaults to the number of
sectors on the disk being:

	sectors/track * tracks/cylinder * (number of (full) cylinders)

This is unlikely to be correct, first because the last "cylinder" on a
SCSI disk isn't likely to be full (because the number of sectors/track
is an average and is usually only an approximation), second because
the 32 sectors before the start of the slice would turn a full last
cylinder into one 32 sectors short of being full.

>and an error from newfs about the calculated sectors/cylender not
>matching the disk label.  But things seem to work.

The message is only a warning.  It is supposed to make you think twice
about wasting all those sectors on the last cylinder (4967 sectors =
2.4MB).

>However, this all makes me nervous.  Is there a step-by-step
>description of how to add a new disk?  I've gone from dos fdisk to

Not at the right level.  There are a surprisingly large number of
things that can go wrong, but most users won't want to/need to know
about them.

>What I'd like is a description of the process of getting from a
>pristine disk, untouched by DOS or anything else, to a disk that
>FreeBSD can mount.

Method 1 (this is just the standard BSD method and is documented
in the disklabel man page).
	(a) Put a _correct_ disklabel entry `foo' in /etc/disktab.
	(b) disklabel -B -r -w sd1 foo.

Method 2 (another standard BSD method).
	(a) Put a _correct_ (text) prototype disklabel in /tmp/foo.
	    The correct format for /tmp/foo is easily obtained by
	    running disklabel on an old disk (preferably of the
	    same type): `disklabel sd0 >/tmp/foo'.
	    Edit /tmp/foo to suit the current disk.
	(b) disklabel -B -R sd1 /tmp/foo.

Method 3 (this depends on a FreeBSD-2.0.5 feature: drivers know
enough about the drive to access the whole drive without there being
a label, and drivers put some of what they know in a prototype
disklabel; use this label instead of one for an old disk).
	(a) disklabel /dev/rsd1 >/tmp/foo.
	(b) Continue as in 2(a).  In 2.0.5, drivers forget to initialize
	    the unused `rpm' and `interleave' fields.  You will have
	    to edit at least these for 3(b) to work.
	(c) Same as 2(b).

Method 4 (a practical method.  Most disks aren't pristine.  Clean the
MBR sector and the label sector in case they aren't):
	a) dd if=/dev/zero of=/dev/rsd1 count=2
	b) Continue as in method 3.

Disks with multiple slices or with a valid DOS partition table are more
complicated (methods 1-4 create a special INVALID DOS partition table).
Essentially, each slice is a virtual drive and you can apply methods
1-2.  Step 3(a) currently doesn't work unless a label already exists, so
method 3 is no better than method 2.  You have to run fdisk to create a
valid DOS partition table, and there are many complications, mostly due
to deficiencies and bugs in fdisk.
-- 
Bruce Evans  bde@zeta.org.au