LinuxChix

System Startup and Recovery

What happens at startup?

The BIOS loads and runs the MBR

A series of "bootstrap" programs are loaded

see man boot

Kernel is loaded, and perhaps some modules

controlled by /boot/loader.conf

The root filesystem is mounted

Then...

/sbin/init is run

This is always the first process, so has pid=1

In normal operation it executes the main startup script /etc/rc

This in turn runs other scripts /etc/rc.d/*

The order is determined by dependency information within the scripts

Each script reads /etc/rc.conf to decide whether a service is wanted or not and to get options

init also controls console logins

How login shells are started

console

init ® getty ® login ® <shell>

controlled by /etc/ttys

ssh

sshd started by /etc/rc.d/sshd

sshd ® login ® <shell>

telnet (avoid)

inetd started by /etc/rc.d/inetd

inetd ® telnetd ® login ® <shell>

controlled by /etc/inetd.conf

inetd doesn't run unless you explicitly enable it

Single-user mode

If "single user mode" is chosen at startup, init just runs a single root shell

No startup scripts are run, meaning:

filesystems are not mounted

daemons are not started

no remote logins

Safest state for repairing the system

You will see this in the exercise

/boot/loader.conf

Controls the kernel loader

Examples:

snd_driver_load="YES"

load all possible sound modules

snd_ich_load="YES"

load just the "ich" sound module

if_wi_load="YES"

load the "wi" network interface module

hint.acpi.0.disabled="1"

Disable ACPI power management

kern.maxproc=5000

Set size of kernel process table

What to put in /boot/loader.conf?

Look in /boot/defaults/loader.conf

copy entries from here, but don't change this file

Look in /usr/src/sys/i386/conf/GENERIC.hints

Look in the handbook

You don't have to load all modules at bootup

you can load them later with kldload

kldload snd_driver

show loaded modules with kldstat

/etc/rc.conf

Controls behaviour of startup scripts

Examples:

sshd_enable="YES"

DO start the ssh daemon

ntpdate_enable="YES"

synchronise clock at bootup

ntpdate_flags="-b ntp-1.example.net"

which time server(s) to synchronise to

ifconfig_fxp0="192.0.2.1/24"

configure network interface(s)

What to put in /etc/rc.conf?

Look in /etc/defaults/rc.conf

copy entries from here, but don't change this file

The /etc/rc.d/* scripts are just plain old shell scripts

With experience you can read them, work out what they are doing, and what settings they use

Plain old shell scripts

Most system settings have a command-line tool to set them

e.g. "ifconfig" configures a network interface

The system forgets state when you reboot

All that the startup scripts do is to run the correct commands for you, using information taken from /etc/rc.conf

You can write your own startup scripts

/etc/rc.local

Or put scripts in /usr/local/etc/rc.d/

Better, as you can have one script per service

2005-04-14T09:14:59