home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
BURKS 2
/
BURKS_AUG97.ISO
/
BURKS
/
LINUX
/
HOWTO
/
mini
/
largedsk.txt
< prev
next >
Wrap
Text File
|
1997-07-07
|
19KB
|
400 lines
Large Disk mini-HOWTO
Andries Brouwer, aeb@cwi.nl
v1.0, 960626
All about disk geometry and the 1024 cylinder limit for disks.
1. The problem
Suppose you have a disk with more than 1024 cylinders. Suppose
moreover that you have an operating system that uses the BIOS. Then
you have a problem, because the usual INT13 BIOS interface to disk I/O
uses a 10-bit field for the cylinder on which the I/O is done, so that
cylinders 1024 and past are inaccessible.
Fortunately, Linux does not use the BIOS, so there is no problem.
Well, except for two things:
(1) When you boot your system, Linux isn't running yet and cannot save
you from BIOS problems. This has some consequences for LILO and
similar boot loaders.
(2) It is necessary for all operating systems that use one disk to
agree on where the partitions are. In other words, if you use both
Linux and, say, DOS on one disk, then both must interpret the
partition table in the same way. This has some consequences for the
Linux kernel and for fdisk.
Below a rather detailed description of all relevant details. Note
that I used kernel version 2.0.8 source as a reference. Other
versions may differ a bit.
2. Booting
When the system is booted, the BIOS reads sector 0 (known as the MBR -
the Master Boot Record) from the first disk (or from floppy), and
jumps to the code found there - usually some bootstrap loader. These
small bootstrap programs found there typically have no own disk
drivers and use BIOS services. This means that a Linux kernel can
only be booted when it is entirely located within the first 1024
cylinders.
This problem is very easily solved: make sure that the kernel (and
perhaps other files used during bootup, such as LILO map files) are
located on a partition that is entirely contained in the first 1024
cylinders of a disk that the BIOS can access - probably this means the
first or second disk.
Another point is that the boot loader and the BIOS must agree as to
the disk geometry. It may help to give LILO the `linear' option.
More details below.
3. Disk geometry and partitions
If you have several operating systems on your disks, then each uses
one or more disk partitions. A disagreement on where these partitions
are may have catastrophic consequences.
The MBR contains a partition table describing where the (primary)
partitions are. There are 4 table entries, for 4 primary partitions,
and each looks like
struct partition {
char active; /* 0x80: bootable, 0: not bootable */
char begin[3]; /* CHS for first sector */
char type;
char end[3]; /* CHS for last sector */
int start; /* 32 bit sector number (counting from 0) */
int length; /* 32 bit number of sectors */
};
(where CHS stands for Cylinder/Head/Sector).
Thus, this information is redundant: the location of a partition is
given both by the 24-bit begin and end fields, and by the 32-bit start
and length fields.
Linux only uses the start and length fields, and can therefore handle
partitions of not more than 2^32 sectors, that is, partitions of at
most 2 TB. That is two hundred times larger than the disks available
today, so maybe it will be enough for the next ten years or so.
Unfortunately, the BIOS INT13 call uses CHS coded in three bytes, with
10 bits for the cylinder number, 8 bits for the head number, and 6
bits for the track sector number. Possible cylinder numbers are
0-1023, possible head numbers are 0-255, and possible track sector
numbers are 1-63 (yes, sectors on a track are counted from 1, not 0).
With these 24 bits one can address 8455716864 bytes (7.875 GB), two
hundred times larger than the disks available in 1983.
Even more unfortunately, the standard IDE interface allows 256
sectors/track, 65536 cylinders and 16 heads. This in itself allows
access to 2^37 = 137438953472 bytes (128 GB), but combined with the
BIOS restriction to 63 sectors and 1024 cylinders only 528482304 bytes
(504 MB) remain addressable.
This is not enough for present-day disks, and people resort to all
kinds of trickery, both in hardware and in software.
4. Translation and Disk Managers
Nobody is interested in what the `real' geometry of a disk is.
Indeed, the number of sectors per track often is variable - there are
more sectors per track close to the outer rim of the disk - so there
is no `real' number of sectors per track. For the user it is best to
regard a disk as just a linear array of sectors numbered 0, 1, ...,
and leave it to the controller to find out where a given sector lives
on the disk.
This linear numbering is known as LBA. The linear address belonging
to (c,h,s) for a disk with geometry (C,H,S) is c*H*S + h*S + (s-1).
All SCSI controllers speak LBA, and some IDE controllers do.
If the BIOS converts the 24-bit (c,h,s) to LBA and feeds that to a
controller that understands LBA, then again 7.875 GB is addressable.
Not enough for all disks, but still an improvement. Note that here
CHS, as used by the BIOS, no longer has any relation to `reality'.
Something similar works when the controller doesn't speak LBA but the
BIOS knows about translation. (In the setup this is often indicated
as `Large'.) Now the BIOS will present a geometry (C',H',S') to the
operating system, and use (C,H,S) while talking to the disk
controller. Usually S = S', C' = C/N and H' = H*N, where N is the
smallest power of two that will ensure C' <= 1024 (so that least
capacity is wasted by the rounding down in C' = C/N). Again, this
allows access of up to 7.875 GB.
If a BIOS does not know about `Large' or `LBA', then there are
software solutions around. Disk Managers like OnTrack or EZ-Drive
replace the BIOS disk handling routines by their own. Often this is
accomplished by having the disk manager code live in the MBR and
subsequent sectors (OnTrack calls this code DDO: Dynamic Drive
Overlay), so that it is booted before any other operating system.
That is why one may have problems when booting from a floppy when a
Disk Manager has been installed.
The effect is more or less the same as with a translating BIOS - but
especially when running several different operating systems on the
same disk, disk managers can cause a lot of trouble.
Linux does support OnTrack Disk Manager since version 1.3.14, and EZ-
Drive since version 1.3.29. Some more details are given below.
5. Kernel disk translation for IDE disks
If the Linux kernel detects the presence of some disk manager on an
IDE disk, it will try to remap the disk in the same way this disk
manager would have done, so that Linux sees the same disk partitioning
as for example DOS with OnTrack or EZ-Drive. However, NO remapping is
done when a geometry was specified on the command line - so a
`hd=cyls,heads,secs' command line option might well kill compatibility
with a disk manager.
The remapping is done by trying 4, 8, 16, 32, 64, 128, 255 heads
(keeping H*C constant) until either C <= 1024 or H = 255.
The details are as follows - subsection headers are the strings
appearing in the corresponding boot messages. Here and everywhere
else in this text partition types are given in hexadecimal.
5.1. EZD
EZ-Drive is detected by the fact that the first primary partition has
type 55. The geometry is remapped as described above, and the
partition table from sector 0 is discarded - instead the partition
table is read from sector 1. Disk block numbers are not changed, but
writes to sector 0 are redirected to sector 1. This behaviour can be
changed by recompiling the kernel with
#define FAKE_FDISK_FOR_EZDRIVE 0 in ide.c.
5.2. DM6:DDO
OnTrack DiskManager (on the first disk) is detected by the fact that
the first primary partition has type 54. The geometry is remapped as
described above and the entire disk is shifted by 63 sectors (so that
the old sector 63 becomes sector 0). Afterwards a new MBR (with
partition table) is read from the