9. CoreLinuxforRedHatandFedoralearningunderGNUFreeDocumentationLicense-Copyleft(c)AcácioOliveira2012
Everyoneispermittedtocopyanddistributeverbatimcopiesofthislicensedocument,changingisallowed
Boot the system
Boot process for PCs:
Boot overview
1. When PC is turned on, BIOS (Basic Input Output Service) performs a selftest;
2. When machine passes self test, BIOS loads Master Boot Record;
usually from first 512-byte sector of the boot drive.
This is usually the 1st hard drive on system, may also be diskette, CD, USB key.
3. For a hard drive, MBR loads a stage 1 boot loader;
Which is either LILO or GRUB stage1 boot loader on a Linux system.
This is another 512-byte, single-sector record.
4. stage 1 boot loader loads a sequence of records called stage 2 boot loader
(or sometimes the stage 1.5 loader).
5. stage 2 loader loads the operating system.
For Linux, this is the kernel, and possibly an initial RAM disk (initrd).
9
12. CoreLinuxforRedHatandFedoralearningunderGNUFreeDocumentationLicense-Copyleft(c)AcácioOliveira2012
Everyoneispermittedtocopyanddistributeverbatimcopiesofthislicensedocument,changingisallowed
Boot the system
Linux boot loaders have characteristics in common:
boot loaders characteristics
12
The code stored on the boot sector or the partition sector is just the first stageloader.
This means that its not responsible for loading the operating system, but only for loading boot loader into memory.
•The boot loader can be configured to load other operating systems.
- When loading other operating systems, the boot loader may load them into
memory,
- or call that operating system's own boot loader.
•Interactively enter options to be passed to the kernel to be loaded.
- Kernel options are used, to indicate where the root filesystem is (root=/dev/hda3),
- and can be used for debugging (init=/bin/sh).
Chain loading
Occurs when the boot manager that is located in the master boot record (MBR)
loads the boot loader that is in a partition boot record.
16. CoreLinuxforRedHatandFedoralearningunderGNUFreeDocumentationLicense-Copyleft(c)AcácioOliveira2012
Everyoneispermittedtocopyanddistributeverbatimcopiesofthislicensedocument,changingisallowed
Boot the system
Recovery
16
With prompt in recovery u can create a mount point (/mnt/sysimage), mount /dev/sda6,
chroot into the mounted system. cat /etc/issue commands show effect of chroot cmd.
Ex: root@yourcomp:~# mkdir /mnt/sysimage
root@yourcomp:~# mount /dev/sda6 /mnt/sysimage
root@yourcomp:~# cd /mnt/sysimage
root@yourcomp:~# mount -t proc none proc/
root@yourcomp:~# mount -t sysfs none sys/
root@yourcomp:~# mount -o bind /dev dev/
root@yourcomp:~# cat /etc/issue
Ubuntu 9.10 n l
root@yourcomp:~# chroot /mnt/sysimage
root@yourcomp:~#
sh-3.00# chroot /mnt/sysimage
[root@yourcomp /]# cat /etc/issue
Fedora release 8 (Werewolf)
Kernel r on an m
[root@yourcomp /]# grub-install /dev/fd0
Installation finished. No error reported.
This is the contents of the device map /boot/grub/device.map.
Check if this is correct or not. If any of the lines is incorrect,
fix it and re-run the script `grub-install'.
(fd0) /dev/fd0
(hd0) /dev/sda
[root@yourcomp /]#
19. CoreLinuxforRedHatandFedoralearningunderGNUFreeDocumentationLicense-Copyleft(c)AcácioOliveira2012
Everyoneispermittedtocopyanddistributeverbatimcopiesofthislicensedocument,changingisallowed
Boot the system
Kernel parameters
19
boot parameters used:
•root=/dev/hda1: change the root filesystem during bootup
•init=/sbin/init: kernel boot will run /sbin/init.
troubleshooting parameter is init=/bin/bash which runs an interactive shell instead of /sbin/init.
•mem=32M: limit the amount of memory to specified. kernel does not attempt to check memory actually present
•Noinitrd: don't execute /linuxrc on initial root disk image supplied by boot loader.
avoid the behaviour of initial root disk loading modules required for booting (filesystem support).
•Config devices compiled in Kernel with IO and IRQ settings in format: device=irq,iobase
•rdev cmd: used to modify a kernel image to not require boot options for:
- root device (rdev /boot/vmlinuz "/dev/hda7 "),
- VGA mode (vidmode /boot/vmlinuz "788"),
- Readonly/Readwrite root filesystem (rootflags ...)
•vga=value: changes display mode of VGA adapter
VESA graphics modes support:
Color depth 640x480 800x600 1024x768 1280x1024
8 bits 256 colours 769 771 773 775
15 bits 32768 colours 784 787 790 793
16 bits 65535 colours 785 788 791 794
24 bits 16.7 Million 786 789 792 795
21. CoreLinuxforRedHatandFedoralearningunderGNUFreeDocumentationLicense-Copyleft(c)AcácioOliveira2012
Everyoneispermittedtocopyanddistributeverbatimcopiesofthislicensedocument,changingisallowed
Boot the system
Kernel parameters with GRUB
21
GRUB's is free cross platform, so it does not follow Linux hard disk convention naming.
(fd0) – /dev/fd0
(hd0) – /dev/hda (SCSI = sd0)
(hd0,1) – /dev/hda2 (2nd
partition of 1st
disk)
To boot Linux, it is required that GRUB knows:
1.where are the files found (root);
2.where is the kernel found (kernel);
3.where is the initial root disk (initrd), that contain vital system modules (filesystem or SCSI controller).
The boot command tells GRUB to boot.
Ex: root (hd0,0) # source of grub files is
/dev/hda1
kernel /boot/vmlinuz root=/dev/hda1 # load a kernel
initrd /boot/initrd # load an initial root disk
boot # boot up
23. CoreLinuxforRedHatandFedoralearningunderGNUFreeDocumentationLicense-Copyleft(c)AcácioOliveira2012
Everyoneispermittedtocopyanddistributeverbatimcopiesofthislicensedocument,changingisallowed
Boot the system
Boot messages
23
When Linux kernel boots, each subsystem is initialised in a predetermined order.
The messages generated by each subsystem are generally displayed on the console.
And are also recorded in 2 places:
Ex:
yourname@yourcomp~> grep "^Apr.*d:" /var/log/messages|tail -n 14
Apr 2 15:36:50 lyrebird kernel: hdd: attached ide-scsi driver.
Apr 2 15:36:26 lyrebird rc.sysinit: Setting hostname lyrebird: succeeded
Apr 2 15:36:26 lyrebird rc.sysinit: Initializing USB keyboard: succeeded
Apr 2 15:36:55 lyrebird sshd: succeeded
Apr 2 15:36:57 lyrebird crond: crond startup succeeded
Listing daemon status messages after a reboot.
1.kernel message (ring) buffer – kernel keeps 16k of messages, displayed by dmesg command.
redirect output to a file for later analysis or forward it to a kernel developer for debugging purposes
2.syslogd records timestamped kernel messages to /var/log/messages.
• After system starts /sbin/init, kernel logs events in the ring buffer,
but processes use the syslog daemon to log messages, usually in /var/log/messages.
• Each syslog line has a timestamp, and the file persists between system restarts.
This file is where you should first look for errors that occurred during the init scripts stage of booting.