home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / HOWTO / MINI / LARGE-ID < prev    next >
Encoding:
Text File  |  1995-04-20  |  7.2 KB  |  175 lines

  1. Note: Kernels newer than 1.1.40 do not have any problem using large
  2. IDE drives (IDE drives with over 1024 cylinders). However, many distributions
  3. still use older kernels for their installation disks, so this might be 
  4. relevant.
  5.  
  6.                 Everything I Know About Linux and EIDE
  7.                 --------------------------------------
  8.  
  9.  
  10. Introduction
  11. ------------
  12.  
  13. It is possible to use Linux on a large EIDE drive with no restrictions
  14. on where anything resides.  I only deal with DOS and Linux here, but
  15. the approach I suggest should be compatible with other operating
  16. systems as well.
  17.  
  18. I presently use version 1.0.9 of the kernel, but everything here
  19. applies to kernels at least through 1.1.34.  Sometime in the future,
  20. Linux will probably support EIDE gracefully and transparently, at
  21. which point all of this will be moot.  Everything I suggest, however,
  22. should continue to work with these future kernels, although most of it
  23. will become unnecessary.
  24.  
  25.  
  26. Background and Terminology
  27. --------------------------
  28.  
  29. Sectors on an ATA (IDE) drive are 512 bytes long.  There are two ways
  30. to address sectors.  Logical Block Address (LBA) form, or logical
  31. form, numbers the sectors linearly starting with 0.
  32. Cylinder-Head-Sector (CHS) form, or physical form, addresses each
  33. sector with a (cylinder, head, sector) triplet.  To convert addresses
  34. from logical to physical form, it is necessary to know how many heads
  35. per cylinder and how many sectors per head the drive has.  If the
  36. total number of cylinders is known as well, the size of the drive can
  37. be determined.  The number of cylinders, heads per cylinder ("heads"),
  38. and sectors per head ("sectors") is called the "disk geometry".
  39.  
  40. Old controllers and BIOSes require sectors to be addressed in physical
  41. form; all controllers and BIOSes allow sectors to be addressed in
  42. physical form.  Linux uses logical addresses everywhere except at the
  43. lowest possible level, when it translates to physical form to talk to
  44. the controller.  Linux does not use the BIOS for anything except to
  45. determine the disk geometry.
  46.  
  47. The partition table records the start and end of each partition in
  48. *both* logical and physical form.  Both DOS fdisk and Linux fdisk
  49. expect these values to agree.  DOS fdisk obtains the disk geometry by
  50. querying the BIOS; Linux fdisk obtains the geometry by querying the
  51. kernel.
  52.  
  53. Now for the fun part.  MS-DOS and the BIOS interface use a 10-bit
  54. field to hold the cylinder number, so they only allow cylinders 0-1023
  55. to be accessed.  This is not sufficient for modern drives, which tend
  56. to have 63 sectors/head, 16 heads/cylinder, and many cylinders.  The
  57. "solution" is a complete hack: An EIDE BIOS will *lie* when queried
  58. for the disk geometry by halving (or quartering) the number of
  59. cylinders and doubling (or quadrupling) the number of heads.  Then
  60. whenever a physically addressed I/O request arrives, the BIOS will
  61. assume the request is based on the bogus disk geometry, and will
  62. convert it appropriately to talk to the controller.  This process is
  63. called "address translation".
  64.  
  65.  
  66. The Problem
  67. -----------
  68.  
  69. When the Linux kernel queries the BIOS (actually, it just reads the
  70. CMOS settings) to determine the disk geometry, it will get the bogus
  71. values which claim more than 16 heads.  Linux knows that this is
  72. impossible, so the code in hd.c gives up and skips the drive.  (Note
  73. that even though the BIOS is reporting a bogus geometry, requests to
  74. the controller still need to be based on the real geometry.  Thus
  75. merely eliminating the test in hd.c won't work.)
  76.  
  77.  
  78. The Wrong Solution
  79. ------------------
  80.  
  81. One fix is to use the BIOS "setup" program to turn off address
  82. translation completely.  You may have to manually set the
  83. cylinder/head/sector values to the real geometry, or it may be
  84. possible to simply turn off the translation, depending on how your
  85. setup works.
  86.  
  87. Then you can repartition your drive with DOS and/or Linux fdisk,
  88. install both operating systems, and things will work, provided you
  89. observe certain restrictions.
  90.  
  91. The problem is that the BIOS still can't be used to access cylinders
  92. above 1023.  So all of your DOS partitions will have to be below that
  93. limit, as will anything which needs to be accessed through the BIOS.
  94. For example, LILO uses the BIOS to do its dirty work; so if you want
  95. to use LILO to boot Linux, you will have to make sure the kernel
  96. (read: entire root partition) lies below the 1024 cylinder limit.
  97. Linux itself, however, will happily access the entire drive.
  98.  
  99.  
  100. The Right Solution
  101. ------------------
  102.  
  103. Restrictions are annoying, so we will avoid them.  This obviously
  104. requires leaving address translation on and dealing with the remaining
  105. problems in a different way.
  106.  
  107. To fix the kernel's problem, simply feed the real geometry to the
  108. kernel with a boot-time option line.  You can do this from the LILO
  109. boot prompt by typing "<image name> hd=<cylinders>,<heads>,<sectors>".
  110. You can also have LILO feed the options automatically by using an
  111. "append=" directive in your lilo.conf file.
  112.  
  113. Now the kernel will be able to recognize and access the drive, but
  114. when a user mode program (e.g., fdisk or the LILO installer) queries
  115. the kernel for the disk geometry, the kernel will return the real geometry,
  116. not the bogus one.  So Linux fdisk (which queries the kernel) and DOS
  117. fdisk (which queries the BIOS) will disagree about how the partition
  118. table should look.  Also, the LILO installer will be computing
  119. physical addresses which are incompatible with what the BIOS (and
  120. therefore the LILO runtime) requires.
  121.  
  122. The fdisk problem is easy to fix:  Go to expert mode, and set the
  123. number of cylinders and number of heads to the bogus (BIOS-compliant)
  124. values.  Then edit the partition table and write it out, confident
  125. that Linux fdisk and DOS fdisk are seeing eye to eye.
  126.  
  127. The LILO problem is just as easy to fix: Add the "linear" directive to
  128. your lilo.conf file.  This will cause LILO to use logical addresses
  129. instead of physical to store its data, forcing LILO to compute
  130. physical addresses at run time instead of at install time.  This will
  131. use the geometry supplied by the BIOS instead of that supplied by the
  132. kernel, and everything will "just work".
  133.  
  134.  
  135. Example / Summary
  136. -----------------
  137.  
  138. I have a 1 Gig EIDE drive on which I recently installed Linux.  Here
  139. is the procedure I used.
  140.  
  141. 1) Ran setup and examined the (bogus) disk geometry.  It said 505
  142. cylinders, 64 heads, 63 sectors.  More than 16 heads is impossible, so
  143. the real values must be 2100 cylinders, 16 heads, 63 sectors.
  144.  
  145. 2) Booted DOS boot disk, ran fdisk, created a DOS partition.
  146.  
  147. 3) Booted Slackware boot disk.  Typed "ramdisk hd=2100,16,63" to boot
  148. the kernel.  Ran Linux fdisk, typed "p" to see lots of errors, typed
  149. "x" to access expert mode, set cylinders to 505, set heads to 64,
  150. returned to normal mode, typed "p" to see my DOS partition and no
  151. error messages.  Created partitions to heart's content.  Saved
  152. partition table and rebooted from Slackware disk (not sure why I had
  153. to do this).
  154.  
  155. 4) Installed Slackware normally, creating an ordinary lilo.conf file.
  156.  
  157. 5) Edited lilo.conf (in this case, /mnt/etc/lilo.conf) to add these
  158. lines to the top:
  159.  
  160. append="hd=2100,16,63"
  161. linear
  162.  
  163. 6) Ran "lilo -r /mnt".  I expected to need the "-P ignore" option, but
  164. didn't.  Go figure.
  165.  
  166. 7) Installed DOS and Windows, much to my chagrin.
  167.  
  168.  
  169. Good luck to all.
  170.  
  171. - Patrick LoPresti
  172.   patl@lcs.mit.edu
  173.  
  174.  
  175.