Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 2 Aug 1999 12:07:12 +1000
From:      Bruce Evans <bde@zeta.org.au>
To:        current@FreeBSD.ORG, phk@FreeBSD.ORG
Subject:   Re: junior-hacker task:  "prepdisk"
Message-ID:  <199908020207.MAA23787@godzilla.zeta.org.au>

next in thread | raw e-mail | index | archive | help
>It seems that our new boot blocks doesn't like the taste of disks
>prepared according to the meagre information we have in the handbook.
>
>The following script seems to DTRT for me, and should really be
>either integrated into a "fdisk -A" flag or maybe as a stand alone
>script.  Either way: manpage & handbook needs updated too.
>...
>#!/bin/sh
>
>dev=fla0
>
>grep "$dev.*sectors" /var/run/dmesg | tr -d '(:)' | awk '
>	{
>	v = $3
>	c = $5
>	h = $7
>	s = $9
>	ss = c * h * s - s
>
>	print "#",$0 > "_"
>	print "g c"c" h"h" s"s > "_"
>	print "p 1 165",s,ss > "_"
>	print "a 1" > "_"
>
>	print "#",$0  > "__"
>	print "type: ESDI" > "__"
>	print "disk:", $1 > "__"
>	print "label:" > "__"
>	print "flags:" > "__"
>	print "bytes/sector: 512" > "__"
>	print "sectors/track:", s > "__"
>	print "tracks/cylinder:", h > "__"
>	print "sectors/cylinder:", s * h > "__"
>	print "cylinders:", c > "__"
>	print "sectors/unit:", ss > "__"
>	print "rpm: 3600" > "__"
>	print "interleave: 1" > "__"
>	print "trackskew: 0" > "__"
>	print "cylinderskew: 0" > "__"
>	print "headswitch: 0           # milliseconds" > "__"
>	print "track-to-track seek: 0  # milliseconds" > "__"
>	print "drivedata: 0 " > "__"
>	print "8 partitions:" > "__"
>	print "#        size   offset    fstype   [fsize bsize bps/cpg]" > "__"
>	print "a:",ss,"0 4.2BSD 512 4096 " > "__"
>	print "c:",ss,"0 unused 0 0" > "__"
>	}
>' 
>fdisk -f _ -i -v $dev
>disklabel -BrR ${dev} __
>newfs /dev/r${dev}a

This fails for SCSI disks, since the "sectors" line is formatted differently.
The disklabel parts of it are mostly a bad way to write:

	disklabel -BrR ${dev} auto
	disklabel -e ${dev}
	# Editing steps in above disklabel -e:
	# (1) Change "type" to ESDI if it is an ESDI disk.  It is a bug that
	#     the wd driver doesn't set label.d_type = DTYPE_ESDI.  The da
	#     driver doesn't have this problem.
	# (2) Add "a:" and any other desired/required partitions.  It is a
	#     bug if the bootstrap can't find boot2 in the 'c' partition
	#     where it has just been written.

or

	disklabel /dev/r${dev} | sed ... | disklabel -BrR ${dev} /dev/stdin
	# Editing steps in the sed command are as above.

All of the above only work for the easy case where the whole disk is
being labelled.  In general, the disk size must be reduced to the slice
size before applying a label to a slice.

Bruce


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199908020207.MAA23787>