Download presentation
Presentation is loading. Please wait.
Published byCecil Wheeler Modified over 9 years ago
1
Runlevel initialization
2
Boot to Linux
3
Grub interface
4
LILO interface Once LILO has successfully loaded, you will see a LILO prompt. You may let LILO time out (after 10 seconds), which will boot the default the Linux partition. Second, you can press the TAB key, which will list a selection of operating systems to boot from. In our example we would get "Linux" and "WindowsXP" as our options. Typing either of these will load up that OS.
5
Changing runlevel at boot time LILO: append the runlevel to the boot command : LILO: linux 3 or LILO: linux 5 GRUB: press the `e' key to edit the boot configuration append the runlevel to the end of the boot command as shown: kernel /vmlinuz ro root=/dev/hda1 5
6
Kernel is loaded into memory GRUB also passes “kernel command line” (255bytes) to the loaded Linux kernel
7
grub.conf # grub.conf generated by anaconda # # Note that you do not have to rerun grub after making changes to this\ file # NOTICE: You have a /boot partition. This means that # all kernel and initrd paths are relative to /boot/, eg. # root (hd0,1) # kernel /vmlinuz-version ro root=/dev/hdb3 # initrd /initrd-version.img #boot=/dev/hdb default=0 timeout=10 splashimage=(hd0,1)/grub/splash.xpm.gz title Linux Fedora (2.6.5-1.358smp) root (hd0,1) kernel /vmlinuz-2.6.5-1.358smp ro root=LABEL=/ rhgb quiet initrd /initrd-2.6.5-1.358smp.img title Linux Fedora-up (2.6.5-1.358) root (hd0,1) kernel /vmlinuz-2.6.5-1.358 ro root=LABEL=/ rhgb quiet initrd /initrd-2.6.5-1.358.img title Windows 2000 rootnoverify (hd0,0) chainloader +1 Specifies the default boot image will be the first hard entry Grub will wait for 10 seconds for input from the user before continuing to boot. The root partition is the second partition on the first hard drive.
8
Example lilo.conf File boot=/dev/hda map=/boot/map install=/boot/boot.b prompt timeout=50 default=linux image=/boot/vmlinuz-2.2.12-20 label=linux initrd=/boot/initrd-2.2.12-20.img read-only root=/dev/hda1
9
Kernel starts the init process Kernel passes desired runlevel to the init pocess as argument If runlevel not specified, then
10
System V initialization system RHEL 4 BOOTFLAGS It is possible to pass a number of flags to init from the boot monitor (eg. LILO). Init accepts the following flags: -s, S, single - Single user mode boot. In this mode /etc/inittab is examined and the bootup rc scripts are usually run before the single user mode shell is started. 1-5 - Runlevel to boot into. -b, emergency - Boot directly into a single user shell without running any other startup scripts. -a, auto - The LILO boot loader adds the word "auto" to the command line if it booted the kernel with the default command line (without user intervention). If this is found init sets the "AUTOBOOT" environment variable to "yes". -z xxx - The argument to -z is ignored. You can use this to expand the command line a bit, so that it takes some more space on the stack. Init can then manipulate the command line so that ps(1) shows the current runlevel.
11
/etc/inittab # The default runlevel is defined here id:5:initdefault: # First script to be executed si::sysinit:/etc/rc.d/rc.sysinit # /etc/init.d/rc takes care of # runlevel handling 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 ls:S:wait:/etc/init.d/rc S # what to do when CTRL-ALT-DEL is pressed ca::ctrlaltdel:/sbin/shutdown -r -t 4 now # getty-programs for the normal runlevels # The "id" field MUST be the same as the # last characters of the device name 1:2345:respawn:/sbin/mingetty --noclear tty1 2:2345:respawn:/sbin/mingetty tty2 3:2345:respawn:/sbin/mingetty tty3 4:2345:respawn:/sbin/mingetty tty4 5:2345:respawn:/sbin/mingetty tty5 6:2345:respawn:/sbin/mingetty tty6
12
rc.sysinit Setting the path and the hostname, and checking whether networking is activated. Mounting the /proc filesystem Setting the kernel parameters Setting the system clock Loading keymaps and fonts Starting swapping Initializing the USB controller along with the attached devices. Checking the root filesystem. Remounting the root filesystem as read-write. Loading modules as appropriate.
13
/etc/init.d/rc All initialization scripts are located in /etc/init.d. Scripts for changing the runlevel are also found there, but are called through symbolic links from one of the subdirectories ( /etc/init.d/rc0.d to /etc/init.d/rc6.d ). Because every script can be executed as both a start and a stop script, these scripts must understand the parameters start and stop. Possible init Script Options OptionDescription start Start service. stop Stop service. restart If the service is running, stop it then restart it. If it is not running, start it. reload Reload the configuration without stopping and restarting the service. force-reload Reload the configuration if the service supports this. Otherwise, do the same as if restart had been given. status Show the current status of service.
14
/sbin/rc unix root # more /sbin/rc #!/bin/bash trap ":" INT QUIT TSTP source /sbin/functions.sh # Only source this when this is a livecd booting... [ -f /sbin/livecd-functions.sh ] && source /sbin/livecd-functions.sh umask 022 try() { local errstr local retval=0 if [ -c /dev/null ]; then errstr="$((eval $*) 2>&1 >/dev/null)" else errstr="$((eval $*) 2>&1)" fi retval=$? if [ "${retval}" -ne 0 ] then # Progressbar begin if [ -c /dev/null ]; then rc_splash "stop" &>/dev/null & else rc_splash "stop" & fi # Progressbar end...
15
init scripts start other processes The system first runs the scripts whose names start with K to kill the associated processes /etc/rc.d/init.d/ stop The system runs the scripts whose names start with S to start the processes /etc/rc.d/init.d/ start
16
System V initialization system RHEL 4 [juris@ns1 rc4.d]$ pwd /etc/rc.d/rc4.d [juris@ns1 rc4.d]$ ls –l... lrwxrwxrwx 1 root root 19 Jun 2 2005 K05saslauthd ->../init.d/saslauthd lrwxrwxrwx 1 root root 13 Jun 2 2005 K20nfs ->../init.d/nfs lrwxrwxrwx 1 root root 14 Jun 2 2005 K24irda ->../init.d/irda lrwxrwxrwx 1 root root 15 Jun 2 2005 K25squid ->../init.d/squid lrwxrwxrwx 1 root root 16 Jun 2 2005 S09pcmcia ->../init.d/pcmcia lrwxrwxrwx 1 root root 16 Jun 2 2005 S40smartd ->../init.d/smartd lrwxrwxrwx 1 root root 14 Jun 2 2005 S55sshd ->../init.d/sshd lrwxrwxrwx 1 root root 16 Aug 11 2005 S55sshdlp ->../init.d/sshdlp... lrwxrwxrwx 1 root root 15 Jun 2 2005 S97rhnsd ->../init.d/rhnsd lrwxrwxrwx 1 root root 11 Jun 15 2005 S99local ->../rc.local [juris@ns1 rc4.d]
17
Benefits of init Scripts One of the benefits of using init directory scripts is that they are easily tested. The scripts may be manually invoked with the stop and start arguments as a check to determine whether they function correctly before creating the links to the rc directories, and trying them under actual system boot conditions. This procedure is recommended because it can help you catch mistakes that might interrupt the boot process and leave the system unusable.
18
System V initialization System service manipulation command [juris@ns1 init.d]$ /sbin/service Usage: service | --status-all | [ service_name [ command | --full-restart ] ] [juris@ns1 init.d]$ /sbin/service sshdlp Usage: /etc/init.d/sshdlp {start|stop|restart|reload|condrestart|status} [juris@ns1 init.d]$
19
Changing Run Levels The following commands are typically reserved for system maintenance activities. UNIX shutdown Command The System V init 0 Command The telinit Command NOTE: The shutdown, telinit, and init 0 commands can only be executed with root access.
20
System V initialization SIGHUPHas the same effect as telinit q. SIGUSR1On receipt of this signals, init closes and re-opens its control fifo, /dev/initctl. Useful for bootscripts when /dev is remounted. SIGINTNormally the kernel sends this signal to init when CTRL-ALT-DEL is pressed. It activates the ctrlaltdel action. SIGWINCHThe kernel sends this signal when the keyboardSignal key is hit. It activates the kbrequest action. Init reacts to several signals
21
The OS Kernel UNIX Run Levels All flavors of UNIX, and UNIX- work-alikes use similar foundations for the system run modes. As far as UNIX and its ilk are concerned, there are basically two run modes: single user (sometimes called maintenance mode), and multi-user. There may be several forms of the multi-user mode (with services, without services, and so on) on any given UNIX OS.
22
The OS Kernel Typically, BSD variants include a r un c ontrol (also known as an rc) script in the /etc directory. This allows the administrator to edit a single /etc/rc script to make it start a new service at boot time. Other BSD variants have simply increased the number of rc files in the /etc directory. For example, the FreeBSD start-up directory contains scripts with names such as /etc/rc.atm, /etc/rc.firewall, and /etc/rc.network. These individual scripts, respectively, configure the ATM network cards, cause the system to become a firewall, and configure the network links respectively. These scripts are called by the master script, /etc/rc
23
Sample BSD Startup Scripts /etc/rc.boot First rc script to run is /etc/rc.boot The first two lines set HOME and PATH environment variables Executes basic system commands during boot hostname file in /etc for each network interface enables IP networking on each interface Find hostname from other machine on NW using hostconfig program and use NFS to mount filesystems System Administrator intervene to fix problem
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.