ALUG
- Sharing Linux and GNU in East Anglia

From Boot to Halt

LPI objective 106 - local courses www.ttllp.co.uk

MJ Ray

28th September 2003

During this session, we covered:-

This session was run by MJ Ray as a demonstration of the taught sessions for the forthcoming Turo Technology LLP training for the LPI certification exam.

Right group at workCircle of cards by right groupLeft group at work

The session took place in a seminar form. A number of cards were handed out out to the participants in 2 work groups in batches, each card representing a step in the normal work cycle of a GNU/Linux system. Each batch added more detail to the boot process, starting with the simple "Power on" and "Power off" and finishing with a complete description of the process.

During the session, groups made notes on the cards from the discussion and placed them in order in the centre of the table, with ”power on” at the top and ”power off” at the bottom. If two cards were interchangeable, the cards were put side by site.

Session Outline

Cards placed by left group

  1. Power on - start fans, light lights...
  2. Power On Self Test - check basic hardware responds: memory, graphics, extra CPUs, CPU sensors; beep codes.
  3. “BIOS boot” - print list of hardware, offer setup screens
  4. Boot record - check drives in order (normally configured in BIOS setup) looking for the first active partition. Partitions are subdivisions of the disk, usually edited with fdisk, cfdisk or similar
  5. Boot manager - most popular are the LInux LOader (LILO) and the GRand Unified Bootloader (GRUB). They have to be installed to a place where the BIOS can find them: the command to do this for LILO is lilo and for GRUB, use grub-install. They have configuration files which tell them what kernel to use by default, what other options, how long to pause and wait for user instructions, and much more. GRUB reads its config file from disk, but LILO’s is stored with it. Keith mentioned the GRUB in Debian HOWTO from LinuxOrbit.
  6. Load kernel and initialised RAM disk - the boot manager copies the Linux kernel into memory and possibly an initrd containing more drivers.
  7. Kernel startup - the boot manager’s work is done and it calls the kernel code. Normally, its first actions are to decompress itself, work out what memory and processors it has and then start device drivers.
  8. Initialise built-in drivers - device drivers come in two forms: they can be built into the kernel and they can be add-on modules loaded by the kernel. The built-in ones cannot normally be deactivated and may cause conflicts with other drivers, so it’s recommended to use as few as possible, but some are necessary. If you make your own kernel, more advice on this is in the instructions.
  9. Load initrd modules - It used to be that you had to have built-in drivers for your main disks and so on, but recent kernels can use modules for these. A special ”RAM disk image” is made and loaded into memory by the boot manager. The kernel can load modules from this.
  10. Mount root filesystem - The RAM disk is a useful tool, but the next task is to get some permanent disks. The kernel mounts its main ”root” disk next. The drivers for it must have been loaded by now, else there will be a panic. Forgetting your disk drivers is a common error when compiling a kernel.
  11. Start “init” - The kernel has completed its basic startup and runs a program called “init” as its first task. This keeps track of the basic state of the machine and manages changes of state. It is told what commands to run when entering a particular state (or “runlevel”) by its config file at /etc/inittab and controlled manually using the command “telinit”
  12. Check disks, mount disks, add swap - init does some basic tasks, often stored in /etc/rcS.d, before picking a runlevel. The root partition was read-only until now, so it is checked for errors (throughly if necessary) and mounted. The same is done for other disks. Any “swap” partitions are added as virtual memory using the “swapon” command.
  13. Single-user mode - init enters runlevel S, the startup single-user mode. Any leftover process are killed and a command from inittab is run on /dev/console. This normally lets the superuser login and repair the machine.
  14. Multi-user mode - init enters a numbered runlevel like 2. This is set by a line in inittab. Normally commands in /etc/rc2.d starting with K are run with a parameter “stop” then any left-over processes are killed, and finally any commands in /etc/rc2.d starting with S are run with a parameter “start”.
  15. Graphical mode - some distributions and some system adminstrators use one of the numbered runlevels to start a graphical user interface. 5 is a popular choice. All numbered runlevels from 0 to 9 exist but 0, 1 and 6 have special meaning.
  16. Start server daemons - some of the S programs will start server daemons like the Apache webserver or PostgreSQL database server.
  17. Start graphical user interface - one of the S programs may start a graphical login interface like xdm, wdm, Login.app, kdm or gdm.
  18. Start “login” - the text-mode login is not normally started by an S program, but by “getty” which is controlled by lines in inittab for each virtual console.
  19. Prepare for reboot - runlevel 6 is special. After running K programs in /etc/rc6.d and killing leftovers, init calls reboot.
  20. Prepare for halt - runlevel 0 is special. After running any K programs in /etc/rc0.d and killing leftovers, init calls the halt command, which can switch power off on suitable machines.
  21. Power off

fdisk output

nail:~# fdisk /dev/hda

The number of cylinders for this disk is set to 2432.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): p

Disk /dev/hda: 255 heads, 63 sectors, 2432 cylinders
Units = cylinders of 16065 * 512 bytes

Device Boot Start End Blocks Id System
/dev/hda1 * 1 547 4393746 83 Linux
/dev/hda2 548 1094 4393777+ 83 Linux
/dev/hda3 1095 1641 4393777+ 83 Linux
/dev/hda4 1642 2091 3614625 5 Extended
/dev/hda5 1642 1969 2634628+ 83 Linux
/dev/hda6 1970 2091 979933+ 82 Linux swap

Command (m for help): q

 

dmesg

Linux version 2.2.20-idepci (herbert@gondolin) (gcc version 2.7.2.3) #1 Sat Apr 20 12:45:19 EST 2002
USER-provided physical RAM map:
USER: 0009e000 @ 00000000 (usable)
USER: 06f00000 @ 00100000 (usable)
Detected 1457629 kHz processor.
Console: colour VGA+ 80x25
Calibrating delay loop... 2909.79 BogoMIPS
Memory: 111652k/114688k available (1164k kernel code, 416k reserved, 1384k data, 72k init)
Dentry hash table entries: 16384 (order 5, 128k)
Buffer cache hash table entries: 131072 (order 7, 512k)
Page cache hash table entries: 32768 (order 5, 128k)
CPU: L1 I Cache: 64K L1 D Cache: 64K
CPU: L2 Cache: 256K
CPU: AMD Mobile AMD Athlon(tm) XP 1700+ stepping 00
Checking 386/387 coupling... OK, FPU using exception 16 error reporting.
Checking 'hlt' instruction... OK.
Checking for popad bug... OK.
POSIX conformance testing by UNIFIX
mtrr: v1.35a (19990819) Richard Gooch (rgooch@atnf.csiro.au)
PCI: PCI BIOS revision 2.10 entry at 0xfd87e
PCI: Using configuration type 1
PCI: Probing PCI hardware
PCI: Enabling I/O for device 00:00
Linux NET4.0 for Linux 2.2
Based upon Swansea University Computer Society NET3.039
NET4: Unix domain sockets 1.0 for Linux NET4.0.
NET4: Linux TCP/IP 1.0 for NET4.0
IP Protocols: ICMP, UDP, TCP
TCP: Hash tables configured (ehash 131072 bhash 65536)
Starting kswapd v 1.5
vga16fb: initializing
vga16fb: mapped to 0xc00a0000
Console: switching to colour frame buffer device 80x30
fb0: VGA16 VGA frame buffer device
Serial driver version 4.27 with HUB-6 MANY_PORTS MULTIPORT SHARE_IRQ enabled
pty: 256 Unix98 ptys configured
RAM disk driver initialized: 16 RAM disks of 4096K size
loop: registered device at major 7
ALI15X3: IDE controller on PCI bus 00 dev 80
ALI15X3: not 100% native mode: will probe irqs later
ide0: BM-DMA at 0x8080-0x8087, BIOS settings: hda:DMA, hdb:pio
ide1: BM-DMA at 0x8088-0x808f, BIOS settings: hdc:pio, hdd:pio
hda: FUJITSU MHS2020AT E, ATA DISK drive
hdc: Compaq DVD-ROM SD-C2612, ATAPI CDROM drive
ide0 at 0x1f0-0x1f7,0x3f6 on irq 14
ide1 at 0x170-0x177,0x376 on irq 15
hda: FUJITSU MHS2020AT E, 19077MB w/2048kB Cache, CHS=2432/255/63
hdc: ATAPI 24X DVD-ROM drive, 192kB Cache
Uniform CD-ROM driver Revision: 3.11
Floppy drive(s): fd0 is 1.44M
FDC 0 is a post-1991 82077
3c59x.c 18Feb01 Donald Becker and others http://www.scyld.com/network/vortex.html
pcnet32.c: PCI bios is present, checking for devices...
The PCI BIOS has not enabled the device at 0/88! Updating PCI command 0013->0017.
rtl8139.c:v1.07 5/6/99 Donald Becker http://cesdis.gsfc.nasa.gov/linux/drivers/rtl8139.html
eth0: RealTek RTL8139 Fast Ethernet at 0x8800, IRQ 11, 00:08:02:f2:79:44.
via-rhine.c:v1.08b-LK1.0.1 12/14/2000 Written by Donald Becker
http://www.scyld.com/network/via-rhine.html
Partition check:
hda: hda1 hda2 hda3 hda4 < hda5 hda6 >
apm: BIOS version 1.2 Flags 0x03 (Driver version 1.13)
apm: disabled on user request.
VFS: Mounted root (ext2 filesystem) readonly.
Freeing unused kernel memory: 72k freed
Adding Swap: 979924k swap-space (priority -1)
parport0: PC-style at 0x378 (0x778) [SPP,ECP,ECPEPP,ECPPS2]
parport0: detected irq 7; use procfs to enable interrupt-driven operation.
lp0: using parport0 (polling).
Linux PCMCIA Card Services 3.1.33
kernel build: 2.2.20-idepci #1 Sat Apr 20 12:45:19 EST 2002
options: [pci] [cardbus] [apm]
PCI routing table version 1.0 at 0xfdf10
Intel ISA/PCI/CardBus PCIC probe:
TI 1410 rev 02 PCI-to-CardBus at slot 00:0a, mem 0xffbfe000
host opts [0]: [ring] [pci + serial irq] [no pci irq] [lat 32/176] [bus 32/34]
ISA irqs (scanned) = none!<6> *NO* card interrupts, polling interval = 1000 ms

 

inittab

# /etc/inittab: init(8) configuration.

# The default runlevel.
id:2:initdefault:

# Boot-time system configuration/initialization script.
# This is run first except when booting in emergency (-b) mode.
si::sysinit:/etc/init.d/rcS

# What to do in single-user mode.
~~:S:wait:/sbin/sulogin

# /etc/init.d executes the S and K scripts upon change
# of runlevel.

l0:0:wait:/etc/init.d/rc 0
l1:1:wait:/etc/init.d/rc 1
l2:2:wait:/etc/init.d/rc 2
l3:3:wait:/etc/init.d/rc 3
l4:4:wait:/etc/init.d/rc 4
l5:5:wait:/etc/init.d/rc 5
l6:6:wait:/etc/init.d/rc 6
# Normally not reached, but fallthrough in case of emergency.
z6:6:respawn:/sbin/sulogin

# What to do when CTRL-ALT-DEL is pressed.
ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now

# What to do when the power fails/returns.
pf::powerwait:/etc/init.d/powerfail start
pn::powerfailnow:/etc/init.d/powerfail now
po::powerokwait:/etc/init.d/powerfail stop

# /sbin/getty invocations for the runlevels.
#
1:2345:respawn:/sbin/getty 38400 tty1
2:23:respawn:/sbin/getty 38400 tty2
3:23:respawn:/sbin/getty 38400 tty3
4:23:respawn:/sbin/getty 38400 tty4
5:23:respawn:/sbin/getty 38400 tty5
6:23:respawn:/sbin/getty 38400 tty6