From: terry@cs.weber.edu (A Wizard of Earth C)
Subject: Re: DOS and 386BSD (and NT and OS2)
Organization: University of Utah Computer Center
Date: Thu, 15 Oct 92 02:57:22 GMT

I was hoping to avoid the level of detail required to install two OS's on an
IDE drive by shooting at the two most likely suspects... sorry this didn't
work for you.

In article <92288.123610K390670@ALIJKU11.BITNET>, <K390670@ALIJKU11.BITNET> writes:
|> In article <92286.101837K390670@ALIJKU11.BITNET> I write:
|> 
|> >My machine is a 486-50 with 212MB Conner CP3204F (IDE) and 543MB Conner
|> >CP3540 (SCSI-2), the latter of which is connected to an Adaptec 1542B.
|> >
|> >I have painstakingly followed Terry Lambert's advice about setting the
|> >IDE drive to its "native" parameters and about putting 386BSD (ptntype A5)
|> >*first* on the disk, DOS second.
|> >
|> >Besides that I lose all tracks beyond 1023 with this method, install
|> >still fails:
|> >>newfs: ioctl (WDINFO): No such process
|> >>newfs: /dev/rwd0a: can't rewrite disk label
|> >>Could not format filesystem. Installation failed.

386BSD isn't going to be able to recognize your drive as both translated and
untranslated.  If you don't turn off translation, you will have to use the
entire disk for 386BSD, or you will have to do some math to find a location
where the cylinder boundries are the same translated and untranslated, and
start the 386bsd partition table there.  The way this is done is to put an
extended DOS partition at the equivalence boundry and edit the DOS partition
table, changing the partition "type" field to the hexadecimal value A5.  This
has mixed results, depending on your controller.  Sometime install can find
it, sometimes it can't.

The reason you have to put a changed partition at the appropriate boundry is
so that install won't try to install the whole disk, or install at the first
free location on the disk.

The reason an "appropriate" boundry is required is that part of bootstrapping
386BSD to it running uses the BIOS, and part of it bypasses the BIOS entirely;
this means that part of the load is translated, and part of it isn't, on a
translated drive.  You have to pick a spot where the translated and
untranslated cylinder numbers are exactly the same.  One of these is *usually*
cylinder 0 -- that's why using the whole disk generally works, even if you
don't modify the translation in the CMOS settings.


If you turn off translation, then all cylinder boundries are physical cylinder
boundries.  This is helpful for you in that you don't have to find a location
that is both a translated and an untranslated cylinder boundry.  You just need
a cylinder boundry.

[A significant advantage of an "untranslated" drive geometry is that the UFS
 cluster allocation and seek optimizations work, speeding up disk I/O about
 30%.  The big win here is large clusters; only about 7% is attributable to
 the seekk and other more minor optimizations according to the papers on UFS].

On an untranslated drive used totally for 386BSD, there isn't a DOS partition
table.  This means you start on a cylinder boundry, which 386BSD needs.

On an untranslated drive partitioned with a DOS partition table (the DOS master
boot record and partition table are at the front) the partition in the DOS
table immediately following the DOS boot information is on a cylinder boundry;
thus installing 386BSD in the first partition will save you some hassle, since
you won't be required to figure out how many cylinders should be used by DOS
so that the second partition starts on an even cylinder boundry.  This means
that there may be a lot of work installing 386BSD on the second partition of
a disk drive.

If you have tried to install 386BSD on a drive, and are going back and trying
to install DOS and 386BSD on the same drive, you will have to fix the master
boot record.  This can be done by trashing it from a fixit.fs disk using the
command:

	dd if=/386bsd of=/dev/wd0a

And then reformatting it, or, if you have DOS 5.0, using the undocumented
option to "fdisk" to rewrite the master boot record, like so:

	fdisk /mbr

In either case, you will probably not be able to do anything until you have
DOS booting on the drive, since whatever you do will probably result in the
master boot record being trashed again by 386BSD.

If you are installing DOS first and 386BSD second, you can proceed one of
two ways.  Note that if DOS is not the second partition, you will have to
reinstall to get more than the default swap space.  If you don't have 16 Meg
of memory, and you want to run X, be prepared to reinstall if you insist on
having DOS be first on the disk.

The first approach is to create than delete a secondary DOS partition after
the DOS partition.  About 30% of the time (I got this number with my new hat
while reading comp.unix.bsd and my email) this will fail.  No good reason,
it just does.

The second approach is to create a secondary DOS partition where you want the
386BSD partition to be; then, using "Norton Utilities" or some other DOS disk
utility package, edit the partition table relabelling the partition "type" as
type A5 (this is a hexadecimal byte value).  When you boot the dist.fs disk
and run install, install will "just find it and install normally".  This is
quoted, because it has *never* worked for me, and I've installed 386BSD on a
fairly considerable variety of hardware.

In either approach, you will probably have to follow the procedure in the FAQ
to provide your own disktab entry.  This is because your disk geometry will
*not* match an existing entry, since you only have part of the disk to deal
with.  This is a pain in the butt.

The problem with putting the DOS partition first is that you can't ever get
more swap space without major brain surgery.


If you are installing DOS second, it means you can put the DOS partition closer
to the end of the disk than it really needs to be, and rerun disklabel to give
yourself more swap space.  This is by far the easiest method; the only thing it
involves is editting your disk label (really, your disktab entry) to extend the
size of the "d" and swap partitions to include the extra space.  If you want
to be real safe, you can also edit the DOS partition table to allocate the
space to your 386BSD partition, *but 386BSD doesn't care*.

You can use either the "create/delete extended" or the "create extended/change
to A5" method to get 386BSD on the fist partition.

The problem with this arrangement is stupid DOS can see over 10 bits of a
cylinder address, so DOS has to live between the start of the DOS partition
and cylinder 1024 (untranslated).  Most drives requiring translation do so
to "lie" about the nuber of cylinders so DOS can use more of the disk.

The advantage is that you can back off DOS, redo the DOS partition, and get
more swap space without having to reinstall 386BSD.

In any case, there is still the possiblility of failure on either the A5 or
the "empty" (create/delete) install procedure, and the probability that you
will have to manually install (as documented in the FAQ) to overcome the fact
that your partition is not the same size as the disk.

|> Othman bin Ahmad replies to that:
|> 
|> >I do not need to do this. Just install DOS first and leave some for 386bsd
|> >at the last partition, then use nu to lavel the 386bsd partition a5. Linux
|> >archive has pdisk(?) or something, which may be used in lie of nu.
|> >        If there is a crash, use ndd to restore the boot sector.
|> 
|> However, in a posting, Terry Lambert replies (>) to someones troubles (>>):
|> 
|> >>Is it? My partition tables make me believe that my DOS
|> >>partition is the first on my disc and that 386BSD partitions are
|> >>located after it. ...
|> >
|> >This will have to change unless you modify the code which acts on the disk,
|> >and assumes 386BSD is first.  Again, this is asboot and disklabel.
|> >
|> >If you modify the drive type to set the correct geometry in the CMOS, you
|> >will have to reinstall DOS.  You might as well put the DOS partition after
|> >the 386BSD partition if you do this, since it will necessitate a reinstall
|> >anyway.
|> >(stuff deleted)
|> >Either way, you will have to back up your DOS partition, since it can't be
|> >the first thing on the disk, unless you choose to modify asboot, disklabel,
|> >and family and pick a place where the physical and translated cylinder
|> >boundries coincide for your 386BSD to live.
|> 
|> I am somewhat confused now. Should the DOS primary partition be put first
|> (avoiding the problem that you can't run past cyl. 1023) or second, to
|> keep asboot, disklabel, family happy?

I believe that the confusion here lies with the fact that Othman's procedure
will not work on a geometry translated drive.

There is one more possibility that I did not go into very good detail on here,
and which I did not touch above... installing 386BSD with translation turned
on and not fighting the CMOS about it.  Anyone who is familiar with Fahrenheit
to Celcius and Celcius to Fahrenheit conversions is basically familiar with the
problem of geometry translation and finding a location which is the same on
both "geometry scales".  For Fahrenheit and Celcius, this point is at -42.
Not only is a negative cylinder boundry impossible to install on, it is much
more likely that 0 is the only pace the physical and translated cylinders
meet, unless the number of tracks per sector increases on the physical geometry
but is constant on the translated geometry.  Then you have to hope the geometry
translation isn't done on a sector-by-sector basis.

If there isn't a positive location where the geometries agree on a cylinder
boundry, it's still possible to pick a translated location which maps to a
physical cylinder boundry as the start of the 386BSD partition.  The way to
do this is to hard-code the location into the boot code which is loaded from
the translated location so that it doesn't look at the translated location in
the DOS partition table, and seek there looking for the disk label or the code
(this happening is the most frequent reason the disk label can not be located
--the boot code is looking in the wrong place for the start of the 386BSD
file system to try and load the rest of 386BSD).  Instead, the BIOS looks at
the DOS partition table, loads the boot code from the *translated* address,
then the boot code, rather than *also* going to the translated address (which
the boot will think is a *physical* address, and get the wrong disk location),
it goes to the hard-coded location and continues loading from there.

The problem with this approach is that you have to recompile and install the
modified boot code, which means you have to have a working system and have the
addresses correct, make a fixit.fs, and reinstall.  This is a problem if you
make a mistake, since you have to reinstall each time.  A simple soloution,
which we can't use, is to ask the controller to give us the physical address
of the translated address, while we can still use the BIOS, and use that.  Most
controllers don't support the idea that you would ever need this information.


A partial solotion to installing and leaving translation on is to use Julian's
boot code.  I have never tried this on a non-SCSI drive, nor have I seen a
dist.fs with a kernel with Julian's drivers and the compressed cpio files
which make up a base system modified to include his boot code.  Such a dist.fs
would probably resolve the problem, as it uses BIOS to load the kernel.


REFERENCES:

	*	The FAQ.
	*	Previous posting on this subject by various authors.
	*	Julian's excellent documentation of the boot process.


Sorry, but there isn't any other information I am aware of.

					Terry Lambert
					terry@icarus.weber.edu
					terry_lambert@novell.com
---
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
 Get the 386bsd FAQ from agate.berkeley.edu:/pub/386BSD/386bsd-0.1/unofficial
-------------------------------------------------------------------------------