[comp.os.msdos.programmer] Boot sector parameter table tricks

phys169@canterbury.ac.nz (07/25/90)

berg@cip-s05.informatik.rwth-aachen.de (Solitair) writes....
>When I change things like the no. of FAT's or the start of the first FAT
>sector, in this table on my hard disk and/or on floppies, my MSDOS 3.3
>does not acknowledge this and does not use the new offsets and sizes.
> 
everett@hpcvra.CV.HP.COM (Everett Kaser) writes:
> First, MS-DOS appears to REQUIRE that there be two fats, even though there's
> an entry in the BOOT sector telling how many fats there are on the disk.  I've
> never been able to get just one fat to work, and I've seen several references
> to the fact that the two fats are pretty-well wired into MS-DOS. 

The device drivers keep a Bios Parameter Block in memory, for floppies several
are loaded with the driver itself, rather than use the proper area in the first
sector of the disk. It selects which to use based on the capacity of the disk,
and it doesn't trust/ignores much of the parameters from the disk. The way
around this is to supply your own device driver, which you are perfectly
entitled to do with DOS, but you might still be stuck with 2 FATS.

I think the background to it is:
 In the first version of DOS, there was no BPB on disk, rather an area said to
be reserved; IBM's PC DOS always put zeroes there, but other companies using
MS-DOS sometimes left all sorts of junk there. When the next version came
along, with BPB info there, the software tested for nuls, and assumed the early
(lower capacity, by the way) disk. Even today, some non-dos disks are assumed
to be low capacity disks by dos. So DOS keeps a bunch of BPB's in ram, and
chooses between them, because it cannot "trust" what is on the diskette. Why
this has to apply to hard disks, I don't know, but going from one version of
DOS to another can make your hard disk unbootable, because different versions
think the root directory starts in a different place, irrespective of what the
first sector says.

It may be possible to change parameters without going to the effort of writing
a new driver for your disk, by using something like Dos function 440D with
CL=40h to get at the area inside the device drivers. If anyone has any success,
let me know, but remember to worry about CHKDSK - I had changed disk parameters
to give a more efficient (for my purposes) number of sectors/cluster and
everything was working fine until one day I stupidly ran CHKDSK/F and lost the
whole disk full of data! It seems to have it's own ideas about the disk
structure too!

P.S. Does anyone know what the "NON-IBM" bit actually does in the attributes of
a block device? Does anything use it?

Mark Aitchison, Physics, University of Canterbury, New Zealand.

Ralf.Brown@B.GP.CS.CMU.EDU (07/25/90)

}P.S. Does anyone know what the "NON-IBM" bit actually does in the attributes of
}a block device? Does anything use it?

If clear, DOS passes the driver a pointer to the first sector of the FAT
for the "Build BPB" call.  If set, it passes a pointer to a scratch
buffer with which the driver may do anything it pleases.  The upshot is
that drivers without the "NON-IBM" bit can not support multiple media
whose first FATs start at different locations on the disk.
--
UUCP: {ucbvax,harvard}!cs.cmu.edu!ralf -=- 412-268-3053 (school) -=- FAX: ask
ARPA: ralf@cs.cmu.edu  BIT: ralf%cs.cmu.edu@CMUCCVMA  FIDO: 1:129/3.1
Disclaimer?    |   I was gratified to be able to answer promptly, and I did.
What's that?   |   I said I didn't know.  --Mark Twain

imp@dancer.Solbourne.COM (Warner Losh) (07/25/90)

: P.S. Does anyone know what the "NON-IBM" bit actually does in the attributes
: of a block device?  does anything use it?

The DEC Rainbow 100 uses it.  The Rainbow's disks have their own "boot sector"
format because the Rainbow gets booted from a Z80 and the code that is on
the boot block is for a Z80.  Also, the Rainbow was mostly designed when they
decided to add MS-DOS support for it.  Also, the Rainbow has some odd formatted
disks.  1 side 80 tracks 10 sectors per track.  That's not the reason that
it has the NON-IBM flag.  Heck, two FAT ID bytes are reserved for use by
Rainbow disks (FA and FB).

From reading my documentation on writing device drivers, the NON-IBM bit
means that the driver will pass you one sector's worth of buffer space when
DOS want you to build the BPB to pass back to it.  That's about the only
difference that I can see.

In DOS 3.10 it is very possible to write a device driver that tells dos
what is on the boot block and have it mostly believed (2 FATs seem to be
etched in code somewhere, however).  I've done it so I can use 3.5" disks
(more or less) in my Rainbow.  Too bad they don't format the same as on a
PC at the moment :-(.

--
Warner Losh		imp@Solbourne.COM
Boycott Lotus.		#include <std/disclaimer>

nacer@hpmcaa.mcm.hp.com (Abdenacer Moussaoui) (07/26/90)

1- Can anybody provide or point out to a tool to read a boot sector ,
store it on a floppy and then later on restore it?


For my information:

2- Is the boot sector the only sector that is required to be defect free?
Can IBMIO.COM and IBMDOS.COM (or equivalents) be started other than
cluster 2 in case the sectors are bad?
Assume a cluster size of 4, is cluster 1 actucally sector 0,1,2,3?

Thank you.

smwong@hantsv.enet.dec.com (Stephen Wong) (07/26/90)

In article <15350002@hpmcaa.mcm.hp.com>, nacer@hpmcaa.mcm.hp.com (Abdenacer
Moussaoui) writes: 
|> 1- Can anybody provide or point out to a tool to read a boot sector ,
|> store it on a floppy and then later on restore it?

Norton Utility can read any sector you specified on your harddisk, and write it
to a file.

stephen@hantsq.enet.dec.com