Linux Init/Network Notes
executable file
script file or argument
environment variable file
directory
The following init activities are focussed on how a network device
comes alive and are deduced from a functioning RedHat 5.0 installation:
As the kernel boots into memory, it discovers network interfaces
such as eth and pi. The final step is to launch /sbin/init
which (as the man page says) is "the father of all processes". init
is responsible for initializing the whole show, much like
autoexec.bat did for DOS. Primarily, it creates processes using
the script file /etc/inittab.
/etc/inittab:
has information for the various runlevels but before dropping into the
default, id:n:initdefault: (run level<n> is 3 for full multiuser
or 5 for X11) it executes the line si:sysinit:/etc/rc.d/rc.sysinit
This is where system initialization activities occur.
/etc/rc.d/rc.sysinit:
sets env variables from /etc/sysconfig/network if it exists,
else it sets NETWORKING=no, HOSTNAME=localhost.
/sbin/swapon -a starts swapping
sets and echos HOSTNAME (got it from /etc/sysconfig/network)
domainname sets the NIS domain name (or none)
/sbin/fsck checks root filesystem, than mounts read only
/sbin/quoaton sets user/group quotas
mount mounts /proc
/sbin/isapnp sets up ISA PNP devices
mount remounts the / filesystem rw
enters / and /proc into mtab
if kernel uses modules it does /sbin/depmod -a -n
uses /etc/conf.modules (or modules.conf) to load sound modules
/sbin/kerneld is started to handle module requests
/sbin/fsck checks remaining filesystems
/bin/mount -a -t nonfs.proc mounts them
/sbin/quoaton -a turns on user and group quotas
and cleans up after itself (/etc/~mtab etc)
/etc/sysconfig/clock is sourced
if /sbin/hwclock exists it sets clock, else /sbin/clock(symlink to hwclock)
swapon enaples swap space
/etc/rc.d/rc.serial is sourced for serial ports
/etc/rc.d/rc.modules?? loads modules
/sbin/modprobe loads any SCSI tape module
/etc/rc.d/init.d/random starts
inittab then instructs init to use the files in /etc/rc.d/rc<n>.d to
change to the runlevel shown in its id:(n):initdefault line
/etc/rc,d/rc<n>.d directories have K* or S* links which normally
point to /etc/rc.d/init.d scripts which can Kill or Start
the appropriate processes by passing start or stop as an
argument to them. The order these scripts are called
in depends upon the number following the K's (called first) or
S's. Lower numbers are called first. The runlevel editor in
X plays with these.
Network start
For the sake of these notes, I'm now only following the networking
S10network (start) process on my installation.
It is a symlink to /etc/rc.d/init.d/network.
/etc/rc.d/init.d/network (start)
executes /etc/rc.d/init.d/functions
sources /etc/sysconfig/network (if it exists else exits)
sources /etc/sysconfig/pcmcia if it exists
checks that NETWORKING is set and /sbin/ifconfig exists (else exits)
cd's into directory /etc/sysconfig/network-scripts and
searches (with /bin/ls) for each interface(except loopback)
with a config file of the form '1fcfg-xyz0', where xyz is the device
type (xyz) and 0 is the number. eg. eth0 is type eth and number 0:
(start)
runs on every interface found (in the order
that /bin/ls found them above, this might be important)
now, following imaginary interface xyz0:
run ./ifup ifcfg-xyz0 boot
sources network-functions
sets CONFIG = ifcfg-xyz0
if ./ifcfg-xyz0 exists and user not root then execs
/usr/sbin/usernetctl CONFIG up to determine if user has
permission to bring thatinterface up
/etc/rc.d/init/d/functions:source_config
sources the ifcfg-xyz0 file (if exists else complains.
since it found it before.)
now,
DEVICE=xyz0
IPADDRESS= a.b.c.d
etc.
if variable ifcfg-xyz0:ONBOOT = 'no' then exits
runs ./ifup-xyz ifcfg-xyz0 boot if ifup-xyz exists
(notice no trailing number, this is a
file which (generally by using variables
from ifcfg-xyz0) does anything special that
the interface needs, beyond what happens
below). eth doesn't happen to need one.
special handling for ALIAS, BOOTPROTO,DHCP and SLAVE (not followed)
/sbin/ifconfig xyz0 ($MACADDR for eth if set) $IPADDRESS netmask $NETMASK broadcast $BROADCAST
(looks like IPADRESS, NETMASK and BROADCAST better all be valid)
/sbin/route add -host $IPADDR xyz0
/sbin/route add default gw $GATEWAY xyz0 (if GATEWAY set you get a default)
/sbin/update /etc/resolv.conf based on $DNSSRVS and $SEARCH if set
if no $HOSTNAME set HOSTNAME=$BOOTPHOSTNAME
runs ./ifup-post ifcfg-xyz0
source ./network-functions
sources ifcfg-xyz0
run ./ifup-routes xyz0
if it it exists, reads /etc/sysconfig/static-routes
static-routes has entries: $device $arguments
/sbin/route add $device $arguments for lines with device=xyz0
(ISALIAS=yes not followed)
$host > /etc/HOSTNAME (under some condition or other, I'm too tired
to figure this one out...)
/sbin/netreport notifies programs that have requested it
/bin/touch /ver/lock/subsys/network (timestamp on file shows time networking up)
DONE with network start (for one interface anyway)