home *** CD-ROM | disk | FTP | other *** search
/ Freelog Special Edition 1: Linux / CD1.iso / doc / HOWTO / mini / LILO < prev    next >
Text File  |  1998-10-14  |  20KB  |  529 lines

  1.   Lilo mini-Howto
  2.   Cameron Spitzer (cls@truffula.sj.ca.us), Alessandro Rubini
  3.   (rubini@linux.it).
  4.   v2.02, 16 August 1998
  5.  
  6.   LILO is the most used Linux Loader for the x86 flavour of Linux; I'll
  7.   call it Lilo rather than LILO here because I don't appreciate upper¡
  8.   case.  This file describes some typical Lilo installations.  It's
  9.   intended as a supplement to the Lilo User's Guide.  I think examples
  10.   are informative even if your setup isn't much like mine.  I hope this
  11.   saves you trouble. Since Lilo's own documentation is very good, who's
  12.   interested in the details is referred to /usr/doc/lilo*
  13.   ______________________________________________________________________
  14.  
  15.   Table of Contents
  16.  
  17.  
  18.   1. Introduction
  19.  
  20.   2. Background Information and Standard Installation
  21.  
  22.      2.1 Where Should I Install Lilo?
  23.      2.2 How Should I Configure my IDE Hard Drives?
  24.      2.3 How Can I Interact at Boot Time?
  25.      2.4 How Can I Uninstall Lilo?
  26.  
  27.   3. The Simple Configuration
  28.  
  29.      3.1 How to Deal with Big Kernels
  30.      3.2 Other Sources of Information
  31.  
  32.   4. Installing
  33.  
  34.   5. Using Lilo When the BIOS Can't See the Root Partition
  35.  
  36.   6. Accessing Huge Disks When the BIOS Can't
  37.  
  38.   7. Booting from a Rescue Floppy
  39.  
  40.  
  41.  
  42.   ______________________________________________________________________
  43.  
  44.   1.  Introduction
  45.  
  46.   Although the documentation found in Lilo's sources (the one installed
  47.   in /usr/doc/lilo-version) is very comprehensive, most Linux users
  48.   experience some trouble in building their own /etc/lilo.conf file.
  49.   This document is meant to support them by giving the minimal
  50.   information and by showing five sample installations:
  51.  
  52.  
  53.   ╖  The first example is the classical ``Linux and other''
  54.      installation.
  55.  
  56.   ╖  The next one shows how to install Lilo on a hard drive connected as
  57.      /dev/hdc that will boot as /dev/hda.  This is usually needed when
  58.      you install a new Linux drive from your own running system. This
  59.      also tells how to boot from SCSI disks when your BIOS is modern
  60.      enough.
  61.  
  62.   ╖  The third example shows how to boot a Linux system whose root
  63.      partition can't be accessed by the BIOS.
  64.  
  65.   ╖  The next sample file is used to access huge disks, that neither the
  66.      BIOS nor DOS can access easily (this one is somehow outdated).
  67.   ╖  The last example shows how to restore a damaged disk, if the damage
  68.      resulted from installing another operating system).
  69.  
  70.  
  71.   The last three examples are by Cameron, cls@truffula.sj.ca.us, who
  72.   wrote the original document. Alessandro (tt/rubini@linux.it/, the
  73.   current maintainer doesn't run anything but Linux, so he can't check
  74.   nor update them by himself. Needless to say, any feedback is welcome.
  75.  
  76.  
  77.   2.  Background Information and Standard Installation
  78.  
  79.   When Lilo boots the system, it uses BIOS calls to load the Linux
  80.   kernel off the disk (IDE drive, floppy or whatever). Therefore, the
  81.   kernel must live in some place that can be accessed by the bios.
  82.  
  83.   At boot time, Lilo is not able to read filesystem data, and any
  84.   pathname you put in /etc/lilo.conf is resolved at installation time
  85.   (when you invoke /sbin/lilo). Installation time is when the program
  86.   builds the tables that list which sectors are used by the files used
  87.   to load the operating system. As a consequence, all of these files
  88.   must live in a partition that can be accessed by the BIOS (the files
  89.   are usually located in the /boot directory, this means that only the
  90.   root partition of your Linux system needs to be accessed via the
  91.   BIOS).
  92.  
  93.   Another consequence of being BIOS-based is that you must reinstall the
  94.   loader (i.e., you must reinvoke /sbin/lilo) any time you modify the
  95.   Lilo setup. Whenever you recompile your kernel and overwrite your old
  96.   image you must reinstall Lilo.
  97.  
  98.  
  99.   2.1.  Where Should I Install Lilo?
  100.  
  101.   The boot= directive in /etc/lilo.conf tells Lilo where it should place
  102.   its primary boot loader. In general, you can either specify the master
  103.   boot record (/dev/hda) or the root partition of your Linux
  104.   installation (is usually is /dev/hda1 or /dev/hda2).
  105.  
  106.   If you have another operating system installed in your hard drive,
  107.   you'd better install Lilo to the root partition instead of the MBR. In
  108.   this case, you must mark the partition as ``bootable'' using the ``a''
  109.   command of fdisk or the ``b'' command of cfdisk. If you don't
  110.   overwrite the master boot sector you'll find it easier to uninstall
  111.   Linux and Lilo if needed.
  112.  
  113.  
  114.   2.2.  How Should I Configure my IDE Hard Drives?
  115.  
  116.   I personally don't use LBA or LARGE settings in the BIOS (but I only
  117.   run Linux); they are horrible kludges forced on by design deficiencies
  118.   in the PC world. This requires that the kernel lives in the first 1024
  119.   cylinders, but this is not a problem as long as you partition your
  120.   hard drives and keep root small (as you should do anyways).
  121.  
  122.   If your hard disk already carries another operating system, you won't
  123.   be able to modify the BIOS settings, or the old system won't work any
  124.   more. All recent Lilo distribution are able to deal with LBA and LARGE
  125.   disk settings.
  126.  
  127.   Note that the "linear" keyword in /etc/lilo.conf can help in dealing
  128.   with geometry problems. The keyword instructs Lilo to use linear
  129.   sector addresses instead of sector/head/cylinder tuples.  Conversion
  130.   to 3D addresses is delayed to run-time, therefore making the setup
  131.   more immune to geometry problems.
  132.  
  133.   If you have more than one hard disk and some of them are only used by
  134.   Linux and are not involved in the boot process, you can tell your BIOS
  135.   that they are not installed. Your system will boot more quickly and
  136.   Linux will autodetect all the disks in no time. I often switch disks
  137.   in my computers, but I never touch the BIOS configuration.
  138.  
  139.  
  140.   2.3.  How Can I Interact at Boot Time?
  141.  
  142.   When you see the Lilo prompt, you can hit the <Tab> key to show the
  143.   list of possible choices. If Lilo is not configured to be interactive,
  144.   press and hold the <Alt> or <Shift> key before the ``LILO'' message
  145.   appears.
  146.  
  147.   If you choose to boot a Linux kernel, you can add command-line
  148.   arguments after the name of the system you choose. The kernel accepts
  149.   many command-line arguments. All the arguments are listed in the
  150.   ``BootPrompt-HOWTO'' by Paul Gortmaker, and I won't replicate it here.
  151.   A few command line arguments, however, are particularly important and
  152.   worth describing here:
  153.  
  154.  
  155.   ╖  root=: you can tell the Linux kernel to mount as root a different
  156.      partition than the one appearing in lilo.conf.  For example, my
  157.      system has a tiny partition hosting a minimal Linux installation,
  158.      and I've been able to boot the system after destroying my root
  159.      partition by mistake.
  160.  
  161.   ╖  init=: verson 1.3.43 and newer of the Linux kernel can execute
  162.      another command instead of /sbin/init, as specified on the command
  163.      line. If you experience bad problems during the boot process, you
  164.      can access the bare system by specifying init=/bin/sh (when you are
  165.      at the shell prompt you most likely will need to mount your disks:
  166.      try ``mount -w -n -o remount /; mount -a'', and remember to
  167.      ``umount -a'' before turning off the computer).
  168.  
  169.   ╖  A number: by specifying a number on the kernel command line, you
  170.      instruct init to enter a specific run-level (the default is usually
  171.      3 or 2, according to the distribution you chose).  Refer to the
  172.      init documentation, to /etc/inittab and to /etc/rc*.d to probe
  173.      further.
  174.  
  175.  
  176.   2.4.  How Can I Uninstall Lilo?
  177.  
  178.   When Lilo overwrites a boot sector, it saves a backup copy in
  179.   /boot/boot.xxyy, where xxyy are the major and minor numbers of the
  180.   device, in hex. You can see the major and minor numbers of your disk
  181.   or partition by running ``ls -l /dev/device''. For example, the first
  182.   sector of /dev/hda (major 3, minor 0) will be saved in
  183.   /boot/boot.0300, installing Lilo on /dev/fd0 creates /boot/boot.0200
  184.   and installing on /dev/sdb3 (major 8, minor 19) creates
  185.   /boot/boot.0813. Note that Lilo won't create the file if there is
  186.   already one so you don't need to care about the backup copy whenever
  187.   you reinstall Lilo (for example, after recompiling your kernel). The
  188.   backup copies found in /boot/ are always the snapshot of the situation
  189.   before installing any Lilo.
  190.  
  191.   If you ever need to uninstall Lilo (for example, in the unfortunate
  192.   case you need to uninstall Linux), you just need to restore the
  193.   original boot sector. If Lilo is installed in /dev/hda, just do ``dd
  194.   if=/boot/boot.0300 of=/dev/hda bs=446 count=1'' (I personally just do
  195.   ``cat /boot/boot.0300 > /dev/hda'', but this is not safe, as this will
  196.   restore the original partition table as well, which you might have
  197.   modified in the meanwhile). This command is much easier to run than
  198.   trying ``fdisk /mbr'' from a DOS shell: it allows you to cleanly
  199.   remove Linux from a disk without ever booting anything but Linux.
  200.   After removing Lilo remember to run Linux' fdisk to destroy any Linux
  201.   partition (DOS' fdisk is unable to remove non-dos partitions).
  202.  
  203.   If you installed Lilo on your root partition (e.g., /dev/hda2),
  204.   nothing special needs to be done to uninstall Lilo.  Just run Linux'
  205.   fdisk to remove Linux partitions from the partition table. You must
  206.   also mark the DOS partition as bootable.
  207.  
  208.  
  209.   3.  The Simple Configuration
  210.  
  211.   Most Lilo installations use a configuration file like the following
  212.   one:
  213.  
  214.  
  215.   boot = /dev/hda   # or your root partition
  216.   delay = 10        # delay, in tenth of a second (so you can interact)
  217.   vga = 0           # optional. Use "vga=1" to get 80x50
  218.   #linear           # try "linear" in case of geometry problems.
  219.  
  220.   image = /boot/vmlinux  # your zImage file
  221.     root = /dev/hda1     # your root partition
  222.     label = Linux        # or any fancy name
  223.     read-only            # mount root read-only
  224.  
  225.   other = /dev/hda4   # your dos partition, if any
  226.     table = /dev/hda  # the current partition table
  227.     label = dos       # or any non-fancy name
  228.  
  229.  
  230.  
  231.   You can have multiple ``image'' and ``other'' sections if you want.
  232.   It's not uncommon to have several kernel images configured in your
  233.   lilo.conf, at least if you keep up to date with kernel development.
  234.  
  235.  
  236.   3.1.  How to Deal with Big Kernels
  237.  
  238.   If you compile a ``zImage'' kernel and it is too big to fit in half a
  239.   megabyte (this is commong with new 2.1 kernels), you should build a
  240.   ``big zImage'' instead: ``make bzImage''. To boot a big kernel image
  241.   nothing special is needed, but you need version 18 or newer of Lilo.
  242.   If your installation is older, you should upgrade your Lilo package.
  243.  
  244.  
  245.   3.2.  Other Sources of Information
  246.  
  247.   In addition to the Lilo docs, there are a number of mini-howto's that
  248.   can be useful for your needs. All of them are called
  249.   ``Linux+foobarOS'', for some foobarOS, they deal with coexistence of
  250.   Linux and other operationg system(s). Also, ``Multiboot-with-LILO''
  251.   describes how the various Windows flavours can be made to coexist with
  252.   Linux.
  253.  
  254.  
  255.   4.  Installing hdc  to Boot as hda  and Using bios=
  256.  
  257.   Lilo allows to map the kernel image from one disk and instruct the
  258.   BIOS to retrieve it from another disk. For example, it's common for me
  259.   to install Linux on a disk I connect to hdc (master disk of secondary
  260.   controller) and boot it as a standalong system on the primary IDE
  261.   controller of another computer. I copied the installation floppy to a
  262.   tiny partition, so I can run chroot in a virtual console to install
  263.   hdc while I use the system to do something else.
  264.  
  265.   The lilo.conf file I use to install Lilo looks like:
  266.  
  267.  
  268.   # This file must be used from a system running off /dev/hdc
  269.   boot = /dev/hdc   # overwrite MBR of hdc
  270.   disk = /dev/hdc   # tell how hdc will look like:
  271.      bios = 0x80    #  the bios will see it as first drive
  272.   delay = 0
  273.   vga = 0
  274.  
  275.   image = /boot/vmlinux  # this is on /dev/hdc1
  276.     root = /dev/hda1     # but at boot it will be hda1
  277.     label = Linux
  278.     read-only
  279.  
  280.  
  281.  
  282.   This configuration file must be read by a Lilo running off /dev/hdc1.
  283.   The Lilo maps that get written the boot sector (/dev/hdc) must refer
  284.   to the files in /boot (currently installed as hdc); such files will be
  285.   accessed under hda when this disk will be booted as a standalone
  286.   system.
  287.  
  288.   I call this configuration file /mnt/etc/lilo.conf.hdc (/mnt is where
  289.   hdc is mounted during the installation. I install Lilo by invoking
  290.   ``cd /mnt; chroot . sbin/lilo -C /etc/lilo.conf.hdc''. Refer to the
  291.   manual page for chroot if this looks magic.
  292.  
  293.   The ``bios='' directive in lilo.conf is used to tell Lilo what the
  294.   BIOS thinks of your devices. BIOS calls identify floppy disks and hard
  295.   drives with a number: 0x00 and 0x01 select the floppy drives, 0x80 and
  296.   the following numbers select hard disks (old BIOSes can only access
  297.   two disks). The meaning of ``bios = 0x80 in the previous sample file
  298.   is therefore ``use 0x80 in your BIOS calls for /dev/hdc''.
  299.  
  300.   This Lilo directive can be handy in other situations, for example when
  301.   your BIOS is able to boot from SCSI disks instead of IDE ones. When
  302.   both IDE and SCSI devices are there, Lilo can't tell whether 0x80 will
  303.   refer to one or the other because the user is able to choose it in the
  304.   BIOS configuration menus, and the BIOS can't be accessed while Linux
  305.   is running.
  306.  
  307.   By default, Lilo assumes that IDE drives are mapped first by the BIOS,
  308.   but this can be overridden by using instructions like these in
  309.   /etc/lilo.conf:
  310.  
  311.  
  312.   disk = /dev/sda
  313.     bios = 0x80
  314.  
  315.  
  316.  
  317.  
  318.   5.  Using Lilo When the BIOS Can't See the Root Partition
  319.  
  320.   I have two IDE drives, and a SCSI drive.  The SCSI drive can't be seen
  321.   from BIOS.  The Linux Loader, Lilo, uses BIOS calls and can only see
  322.   drives that BIOS can see.  My stupid AMI BIOS will only boot from "A:"
  323.   or "C:" My root file system is on a partition on the SCSI drive.
  324.  
  325.   The solution consists in storing the kernel, map file, and chain
  326.   loader in a Linux partition on the first IDE.  Notice that it is not
  327.   necessary to keep your kernel on your root partition.
  328.  
  329.   The second partition on my first IDE (/dev/hda2, the Linux partition
  330.   used to boot the system) is mounted on /u2.  Here is the
  331.   /etc/lilo.conf file I used.
  332.  
  333.  
  334.   #  Install Lilo on the Master Boot Record
  335.   #  on the first IDE.
  336.   #
  337.   boot = /dev/hda
  338.   #  /sbin/lilo (the installer) copies the Lilo boot record
  339.   #  from the following file to the MBR location.
  340.   install = /u2/etc/lilo/boot.b
  341.   #
  342.   #  I wrote a verbose boot menu.  Lilo finds it here.
  343.   message = /u2/etc/lilo/message
  344.   #  The installer will build the following file. It tells
  345.   #  the boot-loader where the blocks of the kernels are.
  346.   map = /u2/etc/lilo/map
  347.   compact
  348.   prompt
  349.   #  Wait 10 seconds, then boot the 1.2.1 kernel by default.
  350.   timeout = 100
  351.   #  The kernel is stored where BIOS can see it by doing this:
  352.   #      cp -p /usr/src/linux/arch/i386/boot/zImage /u2/z1.2.1
  353.   image = /u2/z1.2.1
  354.           label = 1.2.1
  355.   #  Lilo tells the kernel to mount the first SCSI partition
  356.   #  as root.  BIOS does not have to be able to see it.
  357.           root = /dev/sda1
  358.   #  This partition will be checked and remounted by /etc/rc.d/rc.S
  359.           read-only
  360.   #  I kept an old Slackware kernel lying around in case I built a
  361.   #  kernel that doesn't work.  I actually needed this once.
  362.   image = /u2/z1.0.9
  363.           label = 1.0.9
  364.           root = /dev/sda1
  365.           read-only
  366.   #  My DR-DOS 6 partition.
  367.   other = /dev/hda1
  368.           loader=/u2/etc/lilo/chain.b
  369.           label = dos
  370.           alias = m
  371.  
  372.  
  373.  
  374.  
  375.   6.  Accessing Huge Disks When the BIOS Can't
  376.  
  377.   The system in my office has a 1GB IDE drive.  The BIOS can only see
  378.   the first 504 MB of the IDE.  (Where MB means 2**10 bytes, not 10**6
  379.   bytes.)  So I have MS-DOS on a 350 MB partition /dev/hda1 and my Linux
  380.   root on a 120 MB partition /dev/hda2.
  381.  
  382.   MS-DOS was unable to install itself correctly when the drive was
  383.   fresh.  Novell DOS 7 had the same problem.  Luckily for me, "Options
  384.   by IBM" forgot to put the "OnTrack" diskette in the box with the
  385.   drive.  The drive was supposed to come with a product called "OnTrack
  386.   Disk Manager."  If you only have MSDOS, I guess you have to use it.
  387.  
  388.   So I made a partition table with Linux' fdisk.  MSDOS-6.2 refused to
  389.   install itself in /dev/hda1.  It said something like ``this release of
  390.   MS-DOS is for new installations.  Your computer already has MS-DOS so
  391.   you need to get an upgrade release from your dealer.''  Actually, the
  392.   disk was brand new.
  393.  
  394.   What a crock!  So I ran Linux' fdisk again and deleted partition 1
  395.   from the table.  This satisfied MS-DOS 6.2 which proceeded to create
  396.   the exact same partition 1 I had just deleted and installed itself.
  397.   MS-DOS 6.2 wrote its Master Boot Record on the drive, but it couldn't
  398.   boot.
  399.  
  400.   Luckily I had a Slackware kernel on floppy (made by the Slackware
  401.   installation program "setup"), so I booted Linux and wrote Lilo over
  402.   MS-DOS' broken MBR.  This works.  Here is the /etc/lilo.conf file I
  403.   used:
  404.  
  405.  
  406.   boot = /dev/hda
  407.   map = /lilo-map
  408.   delay = 100
  409.   ramdisk = 0             # Turns off ramdisk in Slackware kernel
  410.   timeout = 100
  411.   prompt
  412.   disk = /dev/hda         # BIOS only sees first 500 MB.
  413.      bios = 0x80          # specifies the first IDE.
  414.      sectors = 63         # get the numbers from your drive's docs.
  415.      heads = 16
  416.      cylinders = 2100
  417.   image = /vmlinuz
  418.     append = "hd=2100,16,63"
  419.     root = /dev/hda2
  420.     label = linux
  421.     read-only
  422.     vga = extended
  423.   other = /dev/hda1
  424.     label = msdos
  425.     table = /dev/hda
  426.     loader = /boot/chain.b
  427.  
  428.  
  429.  
  430.   After I installed these systems, I verified that the partition
  431.   containing the zImage, boot.b, map, chain.b, and message files can use
  432.   an msdos file system, as long as it is not "stackered" or
  433.   "doublespaced."  So I could have made the DOS partition on /dev/hda1
  434.   500 MB.
  435.  
  436.   I have also learned that "OnTrack" would have written a partition
  437.   table starting a few dozen bytes into the drive, instead of at the
  438.   beginning, and it is possible to hack the Linux IDE driver to work
  439.   around this problem.  But installing would have been impossible with
  440.   the precompiled Slackware kernel.  Eventually, IBM sent me an
  441.   "OnTrack" diskette.  I called OnTrack's technical support.  They told
  442.   me Linux is broken because Linux doesn't use BIOS.  I gave their
  443.   diskette away.
  444.  
  445.  
  446.   7.  Booting from a Rescue Floppy
  447.  
  448.   Next, I installed Windows-95 on my office system.  It blew away my
  449.   nice Lilo MBR, but it left my Linux partitions alone.  Kernels take a
  450.   long time to load from floppy, so I made a floppy with a working Lilo
  451.   setup on it, which could boot my kernel from the IDE.
  452.  
  453.   I made the lilo floppy like so:
  454.  
  455.     fdformat /dev/fd0H1440      #  lay tracks on virgin diskette
  456.     mkfs -t minix /dev/fd0 1440 #  make file system of type minix
  457.     mount /dev/fd0 /mnt         #  mount in the standard tmp mount point
  458.     cp -p /boot/chain.b /mnt    #  copy the chain loader over
  459.     lilo -C /etc/lilo.flop      #  install Lilo and the map on the diskette.
  460.     umount /mnt
  461.  
  462.  
  463.   Notice that the diskette must be mounted when you run the installer so
  464.   that Lilo can write its map file properly.
  465.  
  466.   This file is /etc/lilo.flop.  It's almost the same as the last one:
  467.  
  468.  
  469.   #  Makes a floppy that can boot kernels from HD.
  470.   boot = /dev/fd0
  471.   map = /mnt/lilo-map
  472.   delay = 100
  473.   ramdisk = 0
  474.   timeout = 100
  475.   prompt
  476.   disk = /dev/hda     # 1 GB IDE, BIOS only sees first 500 MB.
  477.      bios=0x80
  478.      sectors = 63
  479.      heads = 16
  480.      cylinders = 2100
  481.   image = /vmlinuz
  482.     append = "hd=2100,16,63"
  483.     root = /dev/hda2
  484.     label = linux
  485.     read-only
  486.     vga = extended
  487.   other = /dev/hda1
  488.     label = msdos
  489.     table = /dev/hda
  490.     loader = /mnt/chain.b
  491.  
  492.  
  493.  
  494.   Finally, I needed MS-DOS 6.2 on my office system, but I didn't want to
  495.   touch the first drive.  I added a SCSI controller and drive, made an
  496.   msdos file system on it with Linux' mkdosfs, and Windows-95 sees it as
  497.   "D:".   But of course MSDOS will not boot off of D:.  This is not a
  498.   problem when you have Lilo.  I added the following to the lilo.conf in
  499.   Example 2.
  500.  
  501.  
  502.   other = /dev/sda1
  503.     label = d6.2
  504.     table = /dev/sda
  505.     loader = /boot/any_d.b
  506.  
  507.  
  508.   With this modification MSDOS-6.2 runs, and it thinks it is on C: and
  509.   Windows-95 is on D:.
  510.  
  511.  
  512.  
  513.  
  514.  
  515.  
  516.  
  517.  
  518.  
  519.  
  520.  
  521.  
  522.  
  523.  
  524.  
  525.  
  526.  
  527.  
  528.  
  529.