Académique Documents
Professionnel Documents
Culture Documents
BIOS loads the first stage boot loader from the drive's MBR. BIOS loads another boot loader which then loads the first stage boot loader from a partition's boot sector.
The first stage boot loader is also known as Initial Program Loader (IPL). It must be less than 512 bytes in size, so it is fairly limited. It's primary job is to load a more functional boot loader (a.k.a. the second stage boot loader).
2. Configuration
Install the first stage of the boot loader on the MBR. It can then be configured to pass control to any desired operating system. Install the first stage of the boot loader in the boot sector of a partition. Another boot loader is then installed on the MBR. This other boot loader must be configured to pass control to the Linux boot loader.
4.2 Lilo
1. Configuration File
o /etc/lilo.conf
Sample File:
prompt timeout=50 default=linux boot=/dev/hda6 boot loader) # # # # Present lilo prompt so user can interact with lilo Timeout in milliseconds to wait for user interaction Default image to boot Specifies boot device (Location to install primary
map=/boot/map install=/boot/boot.b password=some_passwd restricted prompt message=/boot/message displayed at boot time. linear
# # # # #
To install in the MBR, specify /dev/hda Location of map file Location of Second stage boot loader A password required to boot Password only required if options are entered at boot
image=/boot/vmlinuz-2.4.7-10 memory compressed kernel label=linux initrd=/boot/initrd-2.4.7-10.img # Initial RAM Disk read-only root=/dev/hda9 # Location of root file system other=/dev/hda1 optional label=windows # Image definition
See lilo.conf man page for an example. 2. Command Line Options o -t - Test lilo configuration, but don't actually install. o -v - Verbose 3. Boot Time arguments
Command line options can be entered at the boot prompt by appending it to the image that you are booting. For example:
linux root=/dev/hda5 mem=128M 1
Tells lilo to boot the kernel with a label of "linux" into runlevel 1 using /dev/hda5 as the root filesystem. It also states the machine has 128 MB of RAM. If lilo has been password protected, you will be required to enter the password before booting.
4. Errors
The 'LILO' prompt itself can be used to help diagnose boot related errors. The number of letters presented at the LILO prompt can indicate the success or failure of the boot loader.
o L = First stage boot loaded and started. Usually indicates disk problems or invalid options in /etc/lilo.conf.
o o o o o
LI = Second stage boot loaded from /boot, but /etc/lilo.conf has invalid parameters or /boot/boot.b was moved without re-running /sbin/lilo. LIL = Second stage loader started, but the descriptor table can't be loaded due to a bad disk or invalid parms in /etc/lilo.conf. LIL? = Second stage loaded at an incorrect address because of invalid parms in /etc/lilo.conf or /boot/boot.b was moved without re-running /sbin/lilo. LIL- = Descriptor table is corrupt. Caused by invalid parms in /etc/lilo.conf or /boot/boot.b was moved without re-running /sbin/lilo. LILO = All of LILO loaded correctly.
5. Limitations o Must be installed on the 1st or 2nd IDE drive. o Limited by BIOS (uses BIOS to load kernel off of disk). o Must re-run /sbin/lilo every time you change your configuration. 6. Fixing a corrupt MBR
7. Uninstalling LILO
When LILO overwrites an existing boot sector, it saves a copy of the original boot sector in /boot. The name of the original boot sector will be boot.MMmm where 'MM' is the major device number and 'mm' is the minor device number. So, the original boot sector from /dev/hda will be /boot/boot.0300. To restore the original boot sector, use the dd command:
dd if=/boot/boot.0300 of=/dev/hda bs=446 count=1
The original boot sector is actually 512 bytes in length, but the remaining bytes after 446 are part of the partition table and we don't want to overwrite that in case it's changed.
8. Initial RAM Disk o Need: Allows necessary drivers to be loaded at boot time that aren't compiled directly into the kernel. o Creation: Use mkinitrd to create the initial RAM disk:
o o mkinitrd /boot/initrd-2.4.7-10 2.4.7-10 Setup: Specify in /etc/lilo.conf file as shown above.
4.3 Grub
1. Features o Command line interface available at boot prompt. o Can boot from multiple file systems including ext2/3, Reiserfs, FAT, minix, and FFS
Password protection using MD5 Changes to configuration file take effect immediately. Don't have to re-install MBR. 2. Configuration File
o /boot/grub/grub.conf
o o
Sample Configuration
# grub.conf generated by anaconda # # Note that you do not have to rerun grub after making changes to this file # NOTICE: You have a /boot partition. This means that # all kernel and initrd paths are relative to /boot/, eg. # root (hd0,0) # kernel /vmlinuz-version ro root=/dev/hdb5 # initrd /initrd-version.img #boot=/dev/hdb default=0 # Default to First definition for booting timeout=10 # Time in seconds to wait for user interaction splashimage=(hd1,0)/grub/splash.xpm.gz # Splash Screen password -$Z.............. # Password protection title Red Hat Linux (2.4.17) # First definition root (hd1,0) kernel /vmlinuz-2.4.17 ro root=/dev/hdb5 title Red Hat Linux (2.4.17pre2-pk) # Second definition root (hd1,0) kernel /vmlinuz-2.4.17pre2-pk ro root=/dev/hdb5 title Red Hat Linux (2.4.17pre2) root (hd1,0) kernel /vmlinuz-2.4.17pre2 ro root=/dev/hdb5 title Windows 98SE rootnoverify (hd0,0) makeactive chainloader +1
In order to pass arguments to the image being booted, you must enter menu editing mode, or enter the grub command line. If GRUB has been password protected, you'll need to enter 'p' followed by your password first. To enter menu editing mode, select and entry and press 'e'. This will allow you to modify an existing boot setup and pass options to the kernel as well as init.
The GRUB command line allows you to create boot commands that don't exist in your grub.conf file. You can also run diagnostic tests and view the contents of files on your file systems.
4. Device Names according to Grub o (fd0) - First floppy drive detected by BIOS o (hd0) - First hard drive detected by BIOS (SCSI or IDE) o (hd1,3) - Fourth partition on the 2nd hard drive detected by the BIOS 5. Fixing a corrupt MBR
6. Multi-disk scenario
In this situation, we have a nameless OS installed on /dev/hda and Linux installed on /dev/hdb. We need to setup grub to boot both OSes. This involves installing the first stage of grub on the MBR of /dev/hda and the second stage of grub on the /boot partition of /dev/hdb. We will use the grub configuration file listed above. This scenario assumes you either have a working system or are running in rescue mode chroot'd to /mnt/sysimage.
o
Note: The remaining steps will performed from within the "grub shell".
o
5.2 /etc/inittab
This file contains information needed by init to configure the system. Entries in the file have a specific format:
id:runlevel:style:command to run
1. id - A 1-4 character field the creates a unique identifier for the entry. 2. runlevel - Specifies the runlevel(s) that the entry applies to. 3. style - Specifies how the command is executed. o respawn - Process is restarted if it ever dies. o wait - Process is started once when the specified runlevel is entered. Init will wait for it to finish before proceeding. o once - Process will be executed once when the specified runlevel is entered. o boot - Process will be executed during system boot (runlevel field is ignored). o bootwait - Same as boot, except init will wait for it to complete before continuing. o initdefault - Specifies default run level (command field ignored). o sysinit - Process executed during boot before any boot or bootwait entries. o powerwait - Process executed when power goes down. Init waits for it to complete. o powerfail - Same as powerwait, except init doesn't wait for it to complete. o powerokwait - Executed when power is restored. Init waits for it to complete. o powerfailnow - Executed when battery on UPS is almost dead. o ctrlaltdel - Process executed when init receives SIGINT signal (CTRL+ALT+DEL was pressed). 4. command - Specifies process to execute.
or
service httpd restart
chkconfig - Configure services by runlevel (CLI). Doesn't affect currently running services. Defaults to runlevels 3,4, and 5 if none specified.
Default is to configure current run level. Use "--level" option to specify a different runlevel.
o tksysv - Configure services by runlevel (GUI) (Deprecated). 2. xinetd services o chkconfig - Configures running services. Takes effect immediately on xinetd services.
To start vsftp:
chkconfig vsftp on
Edit service configuration file in /etc/xinetd.d/ directly. To enable, specify "disable = no". To disable, specify "disable = yes". After changing file, xinetd must either be given a USR2 signal so it re-reads it's configuration file or be restarted.
killall -USR2 xinetd
o o
3. init services
The only way to modify init based services is to edit /etc/inittab. After modifying the file, activate the changes by executing "init q".