Escolar Documentos
Profissional Documentos
Cultura Documentos
Objectives
to interpret the Unix startup and shutdown configuration files
to be able to create a customised run level
Contents
bootstrap procedure
single and multi-user run levels
system startup files (rc files)
standard system processes
clean shutdown procedure
maintenance mode
Practicals
to modify the startup sequence of a Unix system
Summary
boot:
boot:linux
linuxroot=/dev/hda1
root=/dev/hda1
boot:
boot:linux
linuxsingle
single
run level 1
single-user
maintenance
run level 2
multi-user
run level 3
multi-user
& DFS
run level 4
multi-user
user defined
System HALT
Single user mode or administration mode
Local multiuser without remote network (e.g. NFS)
Full multi-user with networking
not used
Full multi-user with networking xdm (X-Windows)
System reboot
single-user mode
pseudo states (rarely used)
Structure of /etc/inittab
Each line has 4 fields separated by colons
id : level : action : process
id
unique identifier for line - up to four alphanumerics
level
run level(s) to activate process
action
keyword for how to run process
command
full pathname and parameters of command to be executed
sysinit
run command at first init
boot
run command at boot-time
but don't wait
bootwait
like boot, but wait for completion
initdefault defines default boot-level
Exercise - /etc/inittab
What processes are run at system startup
What processes are run at system shutdown
## more
more /etc/inittab
/etc/inittab
id:5:initdefault:
id:5:initdefault:
si::bootwait:/etc/init.d/boot
si::bootwait:/etc/init.d/boot
l0:0:wait:/etc/rc.d/rc
l0:0:wait:/etc/rc.d/rc 00
l1:1:wait:/etc/rc.d/rc
l1:1:wait:/etc/rc.d/rc 11
l2:2:wait:/etc/rc.d/rc
l2:2:wait:/etc/rc.d/rc 22
l3:3:wait:/etc/rc.d/rc
l3:3:wait:/etc/rc.d/rc 33
#l4:4:wait:/etc/rc.d/rc
#l4:4:wait:/etc/rc.d/rc 44
l5:5:wait:/etc/rc.d/rc
l5:5:wait:/etc/rc.d/rc 55
l6:6:wait:/etc/rc.d/rc
l6:6:wait:/etc/rc.d/rc 66
ls:S:wait:/etc/init.d/rc
ls:S:wait:/etc/init.d/rc SS
~~:S:respawn:/sbin/sulogin
~~:S:respawn:/sbin/sulogin
ca::ctrlaltdel:/sbin/shutdown
ca::ctrlaltdel:/sbin/shutdown -r
-r -t
-t 44 now
now
pf::powerwait:/etc/init.d/powerfail
pf::powerwait:/etc/init.d/powerfail
pn::powerfailnow:/etc/init.d/powerfail
pn::powerfailnow:/etc/init.d/powerfail now
now
po::powerokwait:/etc/init.d/powerfail
po::powerokwait:/etc/init.d/powerfail
1:2345:respawn:/sbin/mingetty
1:2345:respawn:/sbin/mingetty tty1
tty1
2:2345:respawn:/sbin/mingetty
2:2345:respawn:/sbin/mingetty tty2
tty2
0
1
2
3
looks in
looks in
looks in
looks in
/etc/rc0.d
/etc/rc1.d
/etc/rc2.d
/etc/rc3.d
for levels 0
for level 1
for levels 2 & 3
for level 3
## sh
sh S14xinet
S14xinet start
start
## more
more /etc/init.d/xinet
/etc/init.d/xinet
case
case "$1"
"$1" in
in
start)
start) ...
...
...;;
...;;
stop)
stop) ...
...
...;;
...;;
esac
esac
## Adding
Adding xinetd
xinetd
## ln
ln init.d/xinet
init.d/xinet rc3.d/K08xinet
rc3.d/K08xinet
## ln
init.d/xinet
rc3.d/S14xinet
ln init.d/xinet rc3.d/S14xinet
## init
init 33
## init
init 00
## sh
sh K08halt
K08halt stop
stop
1:off
1:off
1:off
1:off
1:off
1:off
1:off
1:off
1:off
1:off
1:off
1:off
1:off
1:off
1:off
1:off
1:off
1:off
1:off
1:off
2:off
2:off
2:off
2:off
2:on
2:on
2:on
2:on
2:on
2:on
2:on
2:on
2:on
2:on
2:off
2:off
2:off
2:off
2:off
2:off
3:on
3:on
3:off
3:off
3:on
3:on
3:on
3:on
3:on
3:on
3:on
3:on
3:on
3:on
3:on
3:on
3:on
3:on
3:on
3:on
4:on
4:on
4:off
4:off
4:off
4:off
4:off
4:off
4:off
4:off
4:off
4:off
4:off
4:off
4:off
4:off
4:off
4:off
4:off
4:off
5:on
5:on
5:off
5:off
5:on
5:on
5:on
5:on
5:on
5:on
5:off
5:off
5:on
5:on
5:on
5:on
5:on
5:on
5:on
5:on
6:off
6:off
6:off
6:off
6:off
6:off
6:off
6:off
6:off
6:off
6:off
6:off
6:off
6:off
6:off
6:off
6:off
6:off
6:off
6:off
Stop service
## /etc/init.d/xinetd
/etc/init.d/xinetd stop
stop
Shutting
down
xinetd:
Shutting down xinetd: done
done
Start service
## /etc/init.d/xinetd
/etc/init.d/xinetd start
start
Starting
INET
services.
Starting INET services. (xinetd)
(xinetd) done
done
id:3:initdefault:
id:3:initdefault:
l2:2:wait:/etc/rc.d/rc
l2:2:wait:/etc/rc.d/rc 22
l3:3:wait:/etc/rc.d/rc
l3:3:wait:/etc/rc.d/rc 33
ca::ctrlaltdel:/sbin/shutdown
ca::ctrlaltdel:/sbin/shutdown -t3
-t3 -r
-r now
now
pf::powerfail:/sbin/shutdown
pf::powerfail:/sbin/shutdown -f
-f -h
-h +2
+2 "Power
"Power Failure!"
Failure!"
pr:12345:powerokwait:/sbin/shutdown
pr:12345:powerokwait:/sbin/shutdown -c
-c "Power
"Power Restored"
Restored"
1:2345:respawn:/sbin/mingetty
1:2345:respawn:/sbin/mingetty tty1
tty1
2:2345:respawn:/sbin/mingetty
2:2345:respawn:/sbin/mingetty tty2
tty2
## ls
ls rc[23].d
rc[23].d
rc2.d:
rc2.d:
K20nfs
K55xdm
S40lp
K20nfs
K55xdm
S40lp
K33oracle
S33acct
K33oracle S05cron
S05cron
S33acct .. .. .. ..
rc3.d:
rc3.d:
S22nfs
S56xinetd
S22nfs
S56xinetd
S30oracle
S30oracle .. .. ..
System Shutdown
Use /sbin/shutdown when closing down a Unix system
shutdown [-tN ] [+M ] [-h ] [-r ] [-c ] time message
+M
wait period in seconds (now=0)
-tN wait period in seconds between message and action
-h
shutdown to halt -c
Cancel shutdown
-r
shutdown and reboot
time absolute time hh:mm
message
shutdown message
wall is used to send broadcasts at set intervals until system shutdown
shutdown is started by init changing to new run level
any process left running are sent a TERM signal
any still running are sent a KILL signal
## shutdown
shutdown r
r now
now
reboot
rebootthe
thesystem
systemnow
now
## shutdown
shutdown +3600
+3600 -r
-r
halt
haltsystem
systemininone
onehour
hour
## shutdown
shutdown now
now
password:
password:
## sync
sync
## sync
sync
## halt
halt
## halt
halt
## poweroff
poweroff
## reboot
reboot
Maintenance mode
Maintenance mode is used to get out of trouble
the system won't boot due to password/kernel/init problems
Summary
Unix systems start up through a clearly defined
sequence
The first configurable stage is with the init
process using /etc/inittab
Run levels provide additional configuration
through the run command scripts
Link and remove files from the /etc/init.d/rc*.d
directories to enable/disable sub-systems for
different run levels
Shutdown Unix using the shutdown command
AIX and OSF/1 (BSD) use a different mechanism
to SVR4 (SVR3.2) systems