Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 2 Jul 1999 21:25:21 +0200 (SAST)
From:      Robert Nordier <rnordier@nordier.com>
To:        adrian@ubergeeks.com (Adrian Filipi-Martin), gram@cequrux.com (Graham Wheeler)
Cc:        hackers@freebsd.org
Subject:   Re: Porting LILO to FreeBSD
Message-ID:  <199907021925.VAA16275@ceia.nordier.com>
In-Reply-To: <Pine.BSF.4.05.9907021230061.24927-100000@thneed.ubergeeks.com> from Adrian Filipi-Martin at "Jul 2, 1999 12:58:04 pm"

next in thread | previous in thread | raw e-mail | index | archive | help
> > >         The standard boot partition selection softwre also works fine
> > > booting windoze OS's from other disks.  All you need to do is set the "disk
> > > id" in the DOS MBR to the correct number, 0x81 for your second disk. That's
> > > the only thing that MS doesn't do correctly whe installing the OS on the
> > > non-primary disk.  I used to do this a long time ago to boot FreeBSD of the
> > > "C" drive and the other stuff off of "second C" drive.
> > 
> > I'll try that this weekend. Preumably I can just do this under FreeBSD
> > using fdisk?
> 
> 	You cannot do it using fdisk.  I tonly manipulates the parition
> table poriton of the MBR.  The "bios device" number is in portion before
> the partition table.  I hesitate to just give an offset and say poke away,
> so I'd look for a disk editing tool like Norton Disk Editor.  That's what I
> used when I last did this a few years ago.

In the standard Microsoft way of doing things, the BIOS drive number
is recorded both in the MBR (sector 0 of the disk) and in the DOS
boot sector (sector 0 of the "fdisk partition").

A Microsoft-style MBR gets the drive number from the byte at offset
0 of the partition entry (field dp_flag of structure dos_partition
in /sys/sys/disklabel.h).  This is usually known as the "active
flag", and all standard fdisk utilities set this to 0x80 (corresponding
to BIOS fixed drive 0) when flagging a partition as active.

This can be patched by hand to some other value (eg. 0x81 for BIOS
fixed drive 1) but in a standard pre-Win95 OSR2 MBR this causes
problems, as the MBR code validates the partition table entries,
and will respond to the 0x81 with the message "Invalid partition
table" followed by a hang.

From Win95 OSR2, the MBR code tolerates value 0x80 through 0xff in
the "dp_flag" field.  The FreeBSD /sys/boot/i386/mbr code in -current
also allows BIOS drive numbers other than 0x80 in this field.  You
can also just install boot0 on both drives (and, no doubt, many
other boot managers as well) and forget about the MBR issues.

If you want to boot DOS specifically (and all Windows versions
other than NT are essentially DOS at the lowest level), you would
need to set the drive number in the DOS boot sector (the equivalent
of the FreeBSD boot1 bootstrap).  This occurs at at least three
different offsets, depending on the FAT filesystem parameters, but
it should be possible to deduce the logic required to find it by
looking at src/sbin/newfs_msdos/newfs_msdos.c: see the field drv
in the structure bsx.

The easiest approach, probably adopted by LILO, is to install a
wrapper around the BIOS int 0x13 services and just change drive
numbers as they go by.

--
Robert Nordier


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




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