*BSD News Article 16139


Return to BSD News archive

Newsgroups: comp.os.386bsd.questions
Path: sserve!newshost.anu.edu.au!munnari.oz.au!spool.mu.edu!howland.reston.ans.net!gatech!emory!sol.ctr.columbia.edu!news.kei.com!ub!csn!hellgate.utah.edu!fcom.cc.utah.edu!cs.weber.edu!terry
From: terry@cs.weber.edu (A Wizard of Earth C)
Subject: Re: NetBSD and DOS coexistence ?
Message-ID: <1993May16.212102.6346@fcom.cc.utah.edu>
Sender: news@fcom.cc.utah.edu
Organization: Weber State University  (Ogden, UT)
References: <1993May15.164807.15131@alf.uib.no> <1t5kqp$mh4@lucy.ee.und.ac.za>
Date: Sun, 16 May 93 21:21:02 GMT
Lines: 204

In article <1t5kqp$mh4@lucy.ee.und.ac.za> barrett@lucy.ee.und.ac.za (Alan Barrett) writes:
>In article <1993May15.164807.15131@alf.uib.no>,
>tl@cmr.no (Tom Lislegaard) writes:
>> I'm having problems installing NetBSD and DOS on the same disk, can
>> anyone explain to me step by step how to do it so I can boot both systems
>> alternately.
>
>I have been unable to get NetBSD to work with its disk label anywhere
>other than in the second physical sector.  The docs suggest that one
>should be able to set aside a partition with type 0xA5, and have NetBSD
>keep its disk label in the second sector of that partition, but it
>doesn't work for me.  I did some reading of the sources and couldn't

OK, here's the gist of it:

1)	Does does use a translated geometry?

	- If you have an IDE drive, get ide_conf.exe (I reposted it, so
	  it's available in the news archives).  My mailbox has 2200
	  messages in it as I am writing this.   If you think your
	  message will be one of the lucky ones that isn't just junked,
	  feel free to try and get it from me (hint: try the archives
	  first; it's also supposed to show up on sun-lamp.cs.berkeley.edu
	  some time soon).

	- Get pfdisk.exe.  Same as ide_conf.exe for availability and
	  location, although it seems to also be widely avilable on DOS
	  archives, so you could archie for it and you'd be able to find
	  it.


	a)	Run one of the programs from DOS.  Write down the geometry
		as cylinders/heads/sectors.  If you used ide_conf.exe,
		also write down the untranslated geometry.

	b)	If you didn't use ide_conf.exe, boot the NetBSD disk.
		Write down the geometry reported by the disk controller
		probe on boot.  This is the untranslated geometry.
	
	c)	Run the pfdisk again.  Write down the number of cylinders
		used by the DOS partition.

	d)	Create a 386BSD partition.  You do this by using a start
		cylinder of one past the end of the DOS partition, and
		setting the type to "165".

	e)	Make the 386BSD partition active.

	f)	Boot the NetBSD kernel disk of your choice.  Switch root
		to the "install1" (use the new, good one, not the old
		buggy one.  If you got it recently from sun-lamp, it's the
		new, good one).

	g)	Get out your calculator.


2)	If the drive doesn't use translated geometry (the translated and
	unstranslated geometries are the same), you simply need to multiply
	the number of DOS cylinders (1c) by the number of heads and sectors
	to get the offset of the 386bsd partition from the start of the
	disk.


	The amount of disk available to 386bsd is the total number of
	cylinders available on the drive minus the number of DOC cylinders
	(1c) quantity time the heads times the sectors.


3)	Translated geometries are "different".  You still need a calculator,
	but you also need a piece of paper and a pen.  Then you need to do
	the following:


	c, h, s :	untranslated geometry, as reported during boot.
	c', h`, s':	translated geometry, as reported by int13 ah=8
			or ide_conf.exe or pfdisk.exe..
	Dc:		Number of cylinders (using the translated geometry)
			reported by fdisk/pfdisk under DOS (1c).

	The calculations:

		Total_translated_cylinders = ( c * h * s) / ( h' * s')

		Total_translated_sectors = Total_translated_cylinders * h' * s'

		Total_translated_offset_sectors = Dc * h' * s'

		Total_386BSD_translated_sectors =
		  Total_translated_sectors - Total_translated_offset_sectors

	yield the information necessary for the disklabel for the 386BSD
	install after the DOS install.  Let's take a real example:

	We have a Maxtor Panther P1-17S SCSI drive (1.778G unformatted).
	We have an Adaptec 1742A in Standard mode (important!) with
	enhanced translation turned off (standard translation is turned
	on.  Adaptec is stupid, and you *can't* turn off BIOS translation).

	The translated geometry of the drive (reported by int13 ah=8) is:

		1024 Cylinders			c'
		  64 Heads			h'
		  32 Sectors			s'

	The actual geometry of the drive (reported by 386BSD on boot) is:

		1778 Cylinders			c
		  19 Heads			h
		  86 Sectors			s

	The 'Total_translated_cylinders' is the number of translated
	cylinders the disk would have if DOS didn't limit it to 1024.
	This ends up being:

		( 1778 * 19 * 86 ) / ( 64 * 32) = 1418.58

	To calculate 'Total_translated_sectors', we first round thi down
	to an integer value, since non-integer cylinder numbers are
	meaningless.  This means we are going to lose some disk space
	(about 608k, to be exact):

		1418 * ( 64 * 32) = 2904064


	Now we need to know 'Dc': the number of DOS cylinders; for our
	example, let's assume 180M.  This works out to a nice round 180
	cylinders for DOS (the DOS fdisk program shows a start of '0' and
	an end of '179').  Using this number, we determine the number of
	sectors into the disk where the 386BSD parition starts
	('Total_translated_offset_sectors):

		180 * ( 64 * 32) = 368640

	Finally, we need to know how many sectors are going to be available
	to 386BSD, or 'Total_386BSD_translated_sectors':

		2904064 - 368640 = 2535424


	We now have all the information necessary for our disktab entry:

		P1-17S|Maxtor Panther 1.78GB SCSI:\
			:dt=SCSI:ty=winchester:se#512:nt#64:ns#32:nc#1418:\
			:pa#????:oa#368640:ta=4.2BSD:ba#4096:fa#512:\
			:pb#????:ob#????:tb=swap:\
			:pc#2535424:oc#368640:\
			:pd#2904064:od#0:\
			:pe#????:oe#????:te=4.2BSD:be#4096:fe#512:\
			:pf#????:of#????:tf=4.2BSD:bf#4096:ff#512:\
			:pg#????:og#????:tg=4.2BSD:bg#4096:fg#512:\
			:ph#????:oh#????:th=4.2BSD:bh#4096:fh#512:


	Calculation of ???? values is based on how you want to divide up
	the disk partitions.  Partitions e-h are optional depending on
	the configuration chosen by the user, with the exception that the
	total of pa, pb, pe, pf, pg and ph can not exceed the value of pc,
	and that ob = oa + pa, oe = ob + pb, of = oe + pe, og = of + pf,
	and oh = og + pg.

	The values nt, ns, nc, oa, pc, oc, pd, and od should all be obvious
	in their derivation from:

		Total_386BSD_translated_sectors
		Total_translated_offset_sectors
		Total_translated_cylinders
		h'
		s'



4)	How to smarten up install so this BS isn't necessary.

	Basically, the second stage boot needs to record the translated
	geometry information in a memory area not tromped by the kernel
	on startup.  The kernel needs to record the information in a
	local area during init and make it available through a special
	ioctl() to all disk devices.  Fortunately, there is a convenient
	block of memory not already in use to do this: the unused bounce
	buffer hunk.

		/sys/i386/i386/pmap.c: pmap_bootstrap(): isaphysmem

	The disk driver will use the bounce buffer (when it's fixed), but
	we will have already made a local copy of the information.

	A utility that reports the geometry (maybe integrated with the
	disklabel program) could then ask the untranslated geometry and
	make it's own calculations using the contents of the DOS partition
	table to get the cylinder offset.

	Voila!  Automatic installation on translated drives and sharing
	of a disk with DOS (or anything else that has a DOS partition
	table entry for it).


					Terry Lambert
					terry@icarus.weber.edu
---
Any opinions in this posting are my own and not those of my present
or previous employers.
-- 
-------------------------------------------------------------------------------
                                        "I have an 8 user poetic license" - me