Friday, May 27, 2011

Chapter 14. System Startup and Shutdown

Chapter Syllabus

14.1 Introduction to the Boot Process

14.2 Processor Dependent Code

14.3 Boot Area on the System Disk

14.4 Initial System Loader

14.5 Loading the HP-UX Kernel

14.6 The init Process

14.7 Runlevels

14.8 Adding a Program to Run at Boot Time

14.9 System Shutdown

Understanding of the system startup and shutdown processes is very important both for routine system administration and troubleshooting. Every HP-9000 server or workstation is supplied with boot code that resides on ROM. As soon as you power on the system, this code executes and performs self-tests and some initialization tasks. It then loads the HP-UX kernel and hands control over to it. The kernel does a number of system initialization tasks before you get a login prompt on your console or terminal. This chapter covers in detail all of the processes that take place from system power on to the display of the login prompt.

In the beginning, you will see an overview of the boot process. The boot process starts from processor dependent code (PDC) that resides on ROM in your system. You will learn how to work with PDC and use its commands by interrupting the boot process. During the boot process, the PDC checks for boot area on the primary boot disk. You will learn the structure of the boot area to

build an understanding of this part of the boot disk. The initial system loader (ISL) is used to load the kernel into memory. Its knowledge is important if you need to boot your machine in single-user mode. You have to rebuild the HP-UX kernel many times, and ISL helps you boot from an old kernel if your new kernel is misconfigured and fails to boot. You will also see how the autoboot works and how to enable or disable it.

Once the HP-UX kernel is loaded into memory, it initializes other processes. The init process is the most important of all of these. It is responsible for most of the system initialization. When you study the section containing information about the init process, you will see the structure of its configuration file and how it performs automatic initialization of other processes at different stages of the boot process.

Runlevels show the system state at a particular instant, and these are also controlled by the init process. You will see which runlevels are supported on HP-UX and what the function is of each. Changing system states by changing runlevels is also explained at this stage.

Many times you need to perform a task right after the system boots up. You may also need to run a program at the boot time. You will find a complete example of how programs are started and stopped during the system startup and shutdown processes. In the last part of this chapter, the shutdown process will be presented. You will see the difference between the shutdown and reboot commands.

After going through this chapter, you will understand the startup and shutdown processes and the different stages that involve these processes. In addition, you will have knowledge of commands and utilities that are used for this purpose. Having a good understanding of this process, you will be able to troubleshoot any HP-UX startup or shutdown problem.

14.1 Introduction to the Boot Process

The boot process of an HP-9000 server or workstation starts when you power it on or when you reboot a running system. It can be divided into two main parts.

boot ROM startup

HP-UX startup

In the first stage, the boot ROM startup process is carried out. At its completion, it initiates the HP-UX startup process, which is completed in a number of steps. On an abstract level, the boot sequence can be divided into the following steps.

1. Power on or reboot.

2. The processor dependent code (PDC) executes and performs self-tests. These tests include memory and CPU tests. The PDC also detects any peripherals attached to the system.

3. PDC initializes the console to display messages. It looks for the primary boot path for booting the system. The boot path is the hardware path to the disk used as the boot device.

4. PDC loads and executes the initial system loader (ISL) from the boot path and executes it. At this stage in the startup process, the role of the boot ROM ends.

5. ISL loads the secondary system loader known as hpux, which resides on the boot area of the disk.

6. The hpux loads the HP-UX kernel /stand/vmunix into memory and hands control over to the kernel.

7. The kernel starts the swapper process and then the init process.

8. The init process reads its initialization file, /etc/inittab, and initializes most of the operating system daemons and processes. It brings the system into an appropriate state and makes it usable for users.

As soon as the init process has completed its tasks, you see a login prompt at the console or at any terminal attached to the system. Part of a sample boot process is shown here.

Primary boot path = 0/2/0.6.0

Alternate boot path = 7/2/0.6.0

Console path = 15/1

Keyboard path = 15/1

[*** Manufacturing (or Debug) Permissions ON ***]

System is HP9000/800/V2500 series

Processor is starting the autoboot process.

To discontinue, press any key within 10 seconds.

Device : 0/2/0.6.0

File : hpux

Arguments : hpux

Loading : hpux ........... 163808 bytes loaded.

102368 + 61440 + 864504 start 0xd01cc0

Boot

: disc(0/2/0.6.0;0)/stand/vmunix

6848512 + 1181408 + 6521760 start 0x3a168

5/2/0.8.0.255.1.2.0 sctl

Probing epic6

Probe of epic6 complete

6 saga

6/0/0 btlan6

6/1/0 fcT1

6/1/0.5 fcT1_cntl

6/1/0.8 fcp

System Console is on SPP DUART0 Interface

WARNING: max message size > 65535, adjusting.

WARNING: max bytes on msg q > 65535, adjusting.

Logical volume 64, 0x3 configured as ROOT

Logical volume 64, 0x2 configured as SWAP

Logical volume 64, 0x2 configured as DUMP

Swap device table: (start & size given in 512-byte blocks)

entry 0 - major is 64, minor is 0x2; start = 0, size = 2097152

Starting the STREAMS daemons-phase 1

Checking root file system.

file system is clean - log replay is not required

Root check done.

Create STCP device files

Memory Information:

physical page size = 4096 bytes, logical page size = 4096 bytes

Physical: 16773120 Kbytes, lockable: 12203164 Kbytes, available:

14014856 Kbytes

/sbin/ioinitrc:

Starting /sbin/ioscan -f 1> /dev/null

Starting /sbin/insf -e -C disk 1> /dev/null

Done ioscan & insf

/sbin/bcheckrc:

Checking for LVM volume groups and Activating (if any exist)

Volume group "/dev/vg00" has been successfully changed.

Resynchronized volume group /dev/vg00

vxfs fsck: sanity check: root file system OK (mounted read/write)

(c)Copyright 1983-1997 Hewlett-Packard Co., All Rights Reserved.

(c)Copyright 1979, 1980, 1983, 1985-1993 The Regents of the Univ. of

California

(c)Copyright 1980, 1984, 1986 Novell, Inc.

(c)Copyright 1986-1992 Sun Microsystems, Inc.

(c)Copyright 1985, 1986, 1988 Massachusetts Institute of Technology

(c)Copyright 1989-1993 The Open Software Foundation, Inc.

(c)Copyright 1986 Digital Equipment Corp.

(c)Copyright 1990 Motorola, Inc.

(c)Copyright 1990, 1991, 1992 Cornell University

(c)Copyright 1989-1991 The University of Maryland

(c)Copyright 1988 Carnegie Mellon University

(c)Copyright 1991-1997 Mentat, Inc.

(c)Copyright 1996 Morning Star Technologies, Inc.

(c)Copyright 1996 Progressive Systems, Inc.

(c)Copyright 1997 Isogon Corporation

RESTRICTED RIGHTS LEGEND

Use, duplication, or disclosure by the U.S. Government is subject to

restrictions as set forth in sub-paragraph (c)(1)(ii) of the Rights in

Technical Data and Computer Software clause in DFARS 252.227-7013.

Hewlett-Packard Company

3000 Hanover Street

Palo Alto, CA 94304 U.S.A.

Rights for non-DOD U.S. Government Departments and Agencies are as set

forth in FAR 52.227-19(c)(1,2).

/sbin/auto_parms: DHCP access is disabled (see /etc/auto_parms.log)

HP-UX Start-up in progress

__________________________

Configure system crash dumps .............................. OK

Mount file systems ........................................ OK

Update kernel and loadable modules ........................ N/A

Initialize loadable modules ............................... N/A

Setting hostname .......................................... OK

Set privilege group ....................................... N/A

Display date .............................................. N/A

Save system crash dump if needed .......................... N/A

Enable auxiliary swap space ............................... OK

Start syncer daemon ....................................... OK

Configure HP Fibre Channel interfaces ..................... OK

.......................................................... OK

Configure Loopback interfaces (lo0) ....................... OK

Start Software Distributor agent daemon ................... OK

Configuring all unconfigured software filesets ............ OK

Recover editor crash files ................................ OK

Clean UUCP ................................................ OK

List and/or clear temporary files ......................... OK

Clean up old log files .................................... OK

Start system message logging daemon ....................... OK

Start pty allocator daemon ................................ OK

Start network tracing and logging daemon .................. OK

Configure HP Ethernet interfaces .......................... OK

Configure HP 100BT interfaces ............................. OK

Configure HP SPP 100BT interfaces ......................... OK

Configure LAN interfaces .................................. OK

Start name server daemon .................................. N/A

Start NFS core subsystem .................................. OK

Start NIS+ server subsystem ............................... OK

Start NIS+ client subsystem ............................... OK

Start NIS server subsystem ................................ OK

Start NIS client subsystem ................................ OK

Start NFS client subsystem ................................ OK

Start the Trusted Mode with Nis+ subsystem ................ N/A

Configure pseudo devices for MAC/LLA access ............... OK

Start multicast routing daemon ............................ N/A

Start Internet services daemon ............................ OK

Start dynamic routing daemon .............................. N/A

Start router discover protocol daemon ..................... N/A

Configuring PPP Interface ................................. OK

Start RARP protocol daemon ................................ N/A

Start remote system status daemon ......................... N/A

Configuring man pages for Internet Services ............... OK

Starting mail daemon ...................................... OK

Starting outbound connection daemons for DDFA software .... N/A

Start SNMP Master Network Management daemon ............... OK

Start OSPF MIB Network Management subAgent ................ N/A

Start SNMP HP-UNIX Network Management subAgent ............ OK

Start SNMP MIB-2 Network Management subAgent .............. OK

Start SNMP Trap Dest Network Management subAgent .......... OK

Start DCE daemons ......................................... N/A

Start RPC daemon if needed ................................ OK

Start the Isogon License Server daemon .................... N/A

Start remote boot daemon .................................. OK

Starting X Font Server at TCP port 7000 ................... N/A

Start vt daemon ........................................... OK

Start time synchronization ................................ OK

Start accounting .......................................... OK

Starting the password/group assist subsystem .............. OK

Starting disk array monitor daemons. ...................... OK

Start print spooler ....................................... OK

Starting HP Distributed Print Service ..................... OK

Start clock daemon ........................................ OK

Support Tools Informational Fileset ....................... OK

Start diagnostic subsystem ................................ OK

Starting hardware predictive .............................. OK

Start environment monitoring daemon ....................... OK

Start auditing subsystem .................................. N/A

Start audio server daemon ................................. N/A

SAM System administration configuration ................... OK

MeasureWare performance software is being started. ........ OK

Reinitialize Software Distributor agent daemon ............ OK

Starting Event Monitoring Service ......................... OK

Start EMS SNMP subagent ................................... OK

Start NFS server subsystem ................................ OK

Start X print server(s) ................................... N/A

Start CDE login server .................................... OK

The system is ready.

GenericSysName [HP Release B.11.00] (see /etc/issue)

Console Login:

In the next sections, you will learn more details on how these tasks are performed.

14.2 Processor Dependent Code

The boot procedure for all HP-9000 systems is controlled by program code, PDC, that resides on the ROM installed inside the system. The PDC is different for different computers (that is why its name is processor dependent). PDC is executed after the system is reset or turned on. It performs self-tests and then tests hardware attached to the system. After thoroughly scanning the memory, it initializes the console and copies the console path to the memory. It copies the boot path and autoboot flag into memory. If the autoboot is disabled, it displays a menu of commands. If the autoboot is enabled, it displays a message showing that the system is going to start the autoboot process and gives you the option to interrupt this process by pressing a key within 10 seconds. If you press a key within 10 seconds, you get the PDC menu; otherwise, the system starts booting from the primary boot path.

PDC is an important part, where you perform system administration tasks to specify primary and alternate boot devices. You can display hardware paths and search boot devices attached to the system. You can also use PDC to boot the system from a device other than primary or secondary boot devices. On V-Class machines, PDC can also be used to boot into single-user mode.

PDC Menus

You get PDC menus by interrupting the boot process by pressing a key when a message like the following is displayed.

Processor is starting the autoboot process.

To discontinue, press any key within 10 seconds.

PDC menus may differ on servers and workstations slightly, but most of the commands are the same on all systems. A typical PDC menu looks likes the following.

---------------------- Main Menu --------------------------

Command Description

------- -----------

BOot [PRI|ALT|] Boot from specified path

PAth [PRI|ALT|] Display or modify a path

SEArch [Display|IPL] [] Search for boot device

COnfiguration menu Displays or sets boot values

INformation menu Displays hardware information

SERvice menu Displays service commands

Help [

|] Displays help for menu or cmd

RESET Restart the system

----------

Main Menu: Enter command or menu >

You can use any of these commands; most of the arguments are optional. For example, using the boot command without any arguments will start the autoboot process. If you want to boot from the alternate boot device, you can use the boot alt command. In case you need to boot the system from a device that is neither a primary nor an alternate boot device (such as booting from CD-ROM when installing HP-UX), you can specify the device name as an argument to the boot command.

All of these commands can be abbreviated. The capital letters in the start of each command show the command abbreviation. For example, you can use "bo" instead of boot and "sea" instead of the search command. Help on commands is also available with the Help command.

Searching Boot Devices

You need to search for boot devices if you don't know the exact name of a device for boot purposes. This is often required when installing a new system. The search command shows all disk drives, CD-ROM devices, and tape drives attached to the system. Output of the search command is like the one given here.

Main Menu: Enter command or menu > search

Searching for potential boot device(s)

This may take several minutes.

To discontinue search, press any key

(termination may not be immediate)

Path Number Device Path (dec) Device Type

----------- ----------------- -----------

P0 10/0/6 Random Access Media

P1 10/0/5 Random Access Media

P2 10/0/4 Random Access Media

P3 10/0/3 Random Access Media

P4 10/0/2 Random Access Media

P5 10/0/1 Random Access Media

P6 10/4/4.2 Toshiba CD-ROM Device

P7 10/4/4.1 Sequential Access Media

Random Access Media shows disks attached to the system, and Sequential Access Media is for tape drives. You can also see a line for a CD-ROM drive. Sometimes you will see Random Access Media in place of the CD-ROM drive. In that case, you have to make a guess which device shows the CD-ROM if you are not familiar with your HP system hardware configuration.

To boot from a particular device, you can use its path number or device path. For example, to boot from a CD-ROM, you can use any of the boot P6 or boot 10/4/4.2 commands.

Booting from an Alternate Disk

Many people use mirrored disks in servers for redundancy and reliability. In a mirror disk configuration, two disks have exactly the same data. Boot devices can also be mirrored so that in case one disk fails to boot the system, it may use the alternate one for the boot process.

To configure an alternate boot device, you can use the configure command. To manually boot from the alternate disk device, use the boot alt command.

Stable Storage

Stable storage is nonvolatile memory where your system stores information about the following.

primary boot path

alternate boot path

console

autoboot

autosearch

This information is used by PDC. You can change this information using the configure command. Autoboot and autosearch are either on or off.

Booting in Single-User Mode

On V-Class machines, you can use PDC to boot the system in single-user mode for maintenance purposes. The PDC command used for this purpose is:

Main Menu: Enter command or menu > boot pri -is

On other machines, you can stop the boot process and use ISL to boot into single-user mode as shown here.

Main Menu: Enter command or menu > boot pri

Interact with ISL (Y or N)?> Y

When you get the ISL prompt, use the following command to boot into single-user mode.

ISL> hpux -is

14.3 Boot Area on the System Disk

The system disk from which HP-UX boots has a boot area and a root partition. It may also have swap space and other file systems. The boot area contains a bootstrap loader and necessary information that is used at boot time. ISL is also a part of the boot area. The files in this area are in logical interchange format (LIF). Important parts of the boot area are:

an LIF volume header that identifies the LIF volume

a file containing an HP-UX volume name

a directory that contains a list of files contained in this area

ISL

secondary loader utility (hpux)

a file with name AUTO

After PDC has finished its job, the ISL is loaded into memory from the boot device selected by PDC. Now the ISL takes control of the boot process and accesses the AUTO file. The AUTO file contains the hpux utility name and any arguments to be passed to the hpux utility. The ISL loads hpux into memory and provides all arguments to hpux. After starting execution, the hpux utility uses these arguments to find the location and file name for the HP-UX kernel. By default, the kernel is present in the /stand directory and has the name vmunix. The hpux loads the kernel into memory and hands control over to the kernel.

Commands Related to the LIF Area

HP-UX has some commands to display the LIF area contents. The lifls command takes a character disk device file as its argument and lists the files in its LIF area. The lifcp command can be used to show the contents of the AUTO file. The following command lists the LIF area in long format on disk c0t6d0.

# lifls -l /dev/dsk/c0t6d0

volume ISL10 data size 7984 directory size 8 99/04/22 03:47:46

filename type start size implement created

===============================================================

HPUX -12928 584 800 0 99/04/22 03:47:47

ISL -12800 1384 240 0 97/11/06 02:10:13

AUTO -12289 1624 1 0 97/11/06 02:10:13

PAD -12290 1632 1700 0 97/11/06 02:10:14

LABEL BIN 3336 8 0 99/11/24 15:36:41

#

The mkboot and rmboot commands are used to install, modify, or delete files in the LIF area.

14.4 Initial System Loader

If autoboot is on and you don't interrupt the boot process, ISL performs its intended tasks automatically. You can interact with the ISL by interrupting PDC. After interruption, when you use the boot command from the PDC menu, it gives you an option to interact with the ISL. At the ISL prompt you can use the commands shown in Table 14-1 to change the parameters in stable storage.

Table 14-1. The ISL Commands

Command

Description

display

Displays existing values

conspath

Modifies console path

primpath

Modifies primary boot path

altpath

Modifies alternate boot path

autoboot

Turns autoboot on or off

autosearch

Turns autosearch sequence parameters on or off

You can also use the setboot command on a running system to view or change these parameters. A typical output of the setboot command is shown next. You can use the setboot options to modify the parameters shown here.

# setboot

Primary bootpath : 0/2/0.6.0

Alternate bootpath : 7/2/0.6.0

Autoboot is ON (enabled)

Autosearch is OFF (disabled)

#

Secondary Loader

As mentioned earlier, the boot block of the disk contains the LIF area where the secondary loader hpux is located. By default, the ISL reads the AUTO file in the LIF area to supply arguments to hpux. However, it is possible to run hpux at the ISL prompt and to provide different arguments to the command manually. If hpux is run without any argument, it loads /stand/vmunix from the primary boot devices. Let's see some important uses of hpux from a system administration point of view.

BOOTING ANOTHER KERNEL

You can have multiple HP-UX kernels on your system. If a new kernel does not work, use an alternate kernel for booting. For example, if you have an old kernel with name vmunix.old in the /stand directory, you can boot the system from that kernel with the following command at the ISL prompt.

ISL> hpux /stand/vmunix.old

BOOTING IN SINGLE-USER MODE

To boot the system in single-user mode for system administration purposes, use:

ISL> hpux -is

You may need to boot the system in single-user mode with a previous kernel if the new kernel does not work and you need to restore the old kernel. For this, you can use following command.

ISL> hpux -is /stand/vmunix.old

The hpux command can also be used to list files in the /stand directory if you forget the name of the old kernel for booting purposes. You can also list files in the LIF area using hpux. Use of the hpux utility is summarized in Table 14-2.

Table 14-2. Use of the hpux Command

Command

Result

hpux

Loads /stand/vmunix from the primary boot path

hpux -is

Loads /stand/vmunix and boots in single-user mode from the primary boot path

hpux ll /stand

Lists files in the /stand directory

hpux show autofile

Displays the contents of the AUTO file

hpux set autofile <filename>

Sets new AUTO file with the contents of filename

hpux -v

Displays the version number of the hpux utility

14.5 Loading the HP-UX Kernel

The default HP-UX kernel is /stand/vmunix, which is loaded into memory by the secondary loader hpux. After loading the kernel into memory, the control is transferred to it. The kernel then loads the device drivers and starts the swapper process. It then initiates a shell process to execute commands from /sbin/pre_init_rc. After executing these commands, the first process, /sbin/init, is started and control is transferred to this process.

Swapper Process

The swapper process has a process ID equal to 0. It manages memory for swapping in and out.

/sbin/pre_init_rc File

The most important command found in this file is fsck, which checks and repairs the root file system before any user starts using it.

14.6 The init Process

This is the most important process in the boot sequence. It is always started with a process ID of 1. After startup, it reads its configuration file, /etc/inittab, and

looks for an entry, initdefault in the action field. This tells init the default runlevel of the system. Runlevel is a state of the system, and at all times HP-UX is in one of the defined runlevels. If the initdefault entry is not present, init prompts for a default runlevel to enter. It then spawns ioinit, bcheckrc, rc, and getty processes depending on the default runlevel chosen.

The main actions taken by the init process are:

Read the initdefault parameter from the /etc/inittab file

Initialize the kernel data structures using /sbin/ioinitrc

Run /sbin/bcheckrc

Run /sbin/rc and bring the system to the default runlevel

/etc/inittab File

The /etc/inittab file is a configuration file read by the init process. This file contains entries in the following general format.

id:rstate:action:process

Each entry consists of one line in the file. However, an entry can be continued on the next line by ending the line with a backslash character. The fields in the inittab file are explained here.

id

It is a unique ID for each entry and can be 1 to 4 characters long.

rstate

This is the runlevel in which the entry is processed. Multiple runlevels can be specified in this field. If no runlevel is given, the process is assumed to run in all runlevels.

action

This is a keyword that tells init how to treat the process specified in the next field. A keyword "boot" in this field shows that the process is started at boot time but to not wait for its termination. The init process does not restart the process after it terminates. The keyword "bootwait" tells init to start the process at boot time and to wait for its termination; init does not restart the process after it terminates. The "initdefault" keyword tells init to which runlevel the system goes after the boot process is completed. It shows the default runlevel of the system. The "respawn" keyword tells the system that if this process does not exist or terminates due to some reason, restart it. A "sysinit" keyword in this file shows that this entry is processed before the init process accesses the

id It is a unique ID for each entry and can be 1 to 4 characters

long.

console. This is usually for the initialization of devices. The keyword "wait" tells init to start the process and to wait for its termination.

process

This is the actual process or command line that is executed.

Initialization of I/O Devices with ioinit

After reading the initdefault entry in the file, the init process starts executing commands or scripts that have sysinit. Most important of these is /sbin/ioinitrc. The ioinitrc file uses information from /etc/ioconfig and invokes the ioinit command to check and maintain consistency between /etc/ioconfig and the kernel data structure. This command assigns instance numbers to all new devices found in the system and invokes the insf command to create special device files for all of these devices.

The /sbin/bcheckrc Script

This script does things that are necessary before mounting the file systems. It activates LVM if it is being used on your system. It also checks and cleans file systems using fsck before these are mounted. It also loads appropriate key maps depending on the keyboard used with the system. If your workstation is also equipped with a EISA backplane, it runs eisa_config in automatic mode to configure and initialize it.

The /sbin/rc Script

The /sbin/rc script is run whenever a new runlevel is created or when the system moves from a lower runlevel to a higher one or vice versa. When moving from a lower to a higher runlevel, the rc script starts daemons and server processes for that runlevel. When moving from a higher to a lower runlevel, the rc script stops all servers and daemons not needed in the lower runlevel. The rc script halts the system when moving to runlevel 0.

Sample /etc/inittab

This sample inittab file is taken from a 9000-series server.

init:3:initdefault:

ioin::sysinit:/sbin/ioinitrc >/dev/console 2>&1

tape::sysinit:/sbin/mtinit > /dev/console 2>&1

muxi::sysinit:/sbin/dasetup /dev/console 2>&1 # mux init

stty::sysinit:/sbin/stty 9600 clocal icanon echo opost onlcr \

ixon icrnl ignpar /dev/systty

pwr::bootwait:/etc/powerstartup /dev/console 2>&1 # PowerPath

brc1::bootwait:/sbin/bcheckrc /dev/console 2>&1 # fsck, etc.

link::wait:/sbin/sh -c "/sbin/rm -f /dev/syscon; \

/sbin/ln /dev/systty /dev/syscon" >/dev/console 2>&1

cprt::bootwait:/sbin/cat /etc/copyright >/dev/syscon # legal req

sqnc::wait:/sbin/rc /dev/console 2>&1 # system init

#powf::powerwait:/sbin/powerfail >/dev/console 2>&1 # powerfail

cons:123456:respawn:/usr/sbin/getty console console # system console

#ttp1:234:respawn:/usr/sbin/getty -h tty0p1 9600

#ttp2:234:respawn:/usr/sbin/getty -h tty0p2 9600

#ttp3:234:respawn:/usr/sbin/getty -h tty0p3 9600

#ttp4:234:respawn:/usr/sbin/getty -h tty0p4 9600

#ttp5:234:respawn:/usr/sbin/getty -h tty0p5 9600

#ups::respawn:rtprio 0 /usr/lbin/ups_mond -f /etc/ups_conf

ems1::bootwait:/sbin/cat /etc/opt/resmon/persistence/reboot_flag

ems2::bootwait:/sbin/rm -f /etc/opt/resmon/persistence/runlevel4_flag

ems3:3:once:touch /etc/opt/resmon/persistence/runlevel4_flag

ems4:3456:respawn:/etc/opt/resmon/lbin/p_client

14.7 Runlevels

A runlevel is a state of the system showing which daemons and services are available at a particular time. HP-UX is in one of the eight runlevels at all times. These runlevels are 0 to 6, s, and S. The system default runlevel is determined by the initdefault entry in the /etc/inittab file. These runlevels are described in Table 14-3.

Table 14-3. HP-UX Runlevels

Runlevel

Description

0

Reserved for shutdown. When the system goes to this runlevel, it stops all processes and brings the system to a halted state.

s

This is a single-user runlevel and is used for system-administration-related tasks. Only one physical system console can be used. For this reason, it is called a single-user runlevel. The daemons available in this runlevel are those started by init having the sysinit keyword in the /etc/inittab file and any other daemon directly started by the HP-UX kernel.

S

This is similar to the single-user runlevel, the only difference being that the terminal you are logged into acts as the system console.

1

This starts some essential system processes and mounts the file system but still in single-user mode. This runlevel is also used for system administration tasks.

2

This is a multiuser runlevel; most of the system daemons and services are started at this runlevel.

3

Network services are started and NFS file systems are exported. This also starts the CDE graphical environment (for those users using it).

4

Activates the graphical user interface (GUI) for those users using the older HP VUE graphical environment.

5

Available for any user-defined services.

6

Available for any user-defined services.

Changing Runlevel

The runlevel of the system can be changed using the init command. The first argument to the command determines the new runlevel. If you are working in single-user mode for some maintenance work and want to bring the system into multiuser mode, you can use the following init command to bring the system to runlevel 3.

init 3

However, you should not use init S from a higher runlevel to go into single-user mode. This does not terminate other system activities and does not bring the system into single-user mode.

The shutdown command can also be used to bring the system into single-user mode. The reboot command changes the runlevel to 0 and reboots the system.

Determine Current Runlevel

You have already used the who command to determine who is currently logged into the system. Using who with the -r option determines the current system runlevel.

# who -r

. run-level 3 Sep 26 03:51 3 0 S

#

The last three fields show the current system state, the number of times the system has been in this state, and the last runlevel state. These fields change each time you change the runlevel of the system.

14.8 Adding a Program to Run at Boot Time

To add a program to your system so that it executes at a particular runlevel involves a few steps. First, an execution script for starting and stopping a program is installed in the /sbin/init.d directory. This directory contain scripts for all daemons and services. The execution script contains the four major parts that are passed as command line arguments to these scripts.

start_msg

Displayed on the console when starting the script.

stop_msq

Displayed on the console at stop time of the script.

start

Command to start the program.

stop

Command to stop the program.

These scripts have configuration files in the /etc/rc.config.d directory that are used for setting the appropriate variables and options for these scripts. You must place a configuration file for the execution script in this directory. An execution

script for the cron daemon (used for scheduling jobs) is /sbin/init.d/cron and is shown here.

#!/sbin/sh

# Start cron

case $1 in

'start_msg')

echo "Start clock daemon"

;;

'stop_msg')

echo "Stop clock daemon"

;;

'start')

if [ -f /etc/rc.config.d/cron ] ; then

. /etc/rc.config.d/cron

fi

if [ $CRON -eq 1 ] ; then

/usr/sbin/cron

fi

;;

'stop')

PID=`ps -el | grep cron|cut -c 10-14`

Kill $PID

;;

*)

echo "usage: $0 {start|stop}"

;;

esac

exit

Once the script is installed, you need to decide at which runlevel it should be activated. HP-UX has directories with names /sbin/rcn.d, where n represents a runlevel. These directories are called sequencer directories. You place a link to your script in these directories. If you want to start your script at runlevel 3, you will place a link in the /sbin/rc3.d directory. You have to put one link for starting the script and another one for stopping it.

Sequencer Directories

A sequencer directory represents a particular runlevel. For example, /sbin/rc2.d contains links to scripts that need to be started or stopped when the system moves to runlevel 2. Every link starts with the S or K character. The files starting with S show that the scripts will be started when the system enters in this runlevel, while those scripts starting with K show that it will be stopped (killed).

After the S or K character, there is a number that shows the sequence in which the script will be started or stopped. A typical link for starting the cron daemon is:

/sbin/rc2.d/S730cron

This shows that cron will be started in runlevel 2. The number 730 is the sequence number.

HP-UX executes scripts in the sequencer directories in the order of the sequence number. A script having a sequence of less than 730 will be executed earlier than the cron.

A typical sequencer script to stop the cron daemon is as follows.

/sbin/rc1.d/K270cron

It is located in the rc1.d directory showing that it will be executed when the system goes to runlevel 1. It starts with K, representing that it is a stop (kill) script. As you can see, the start and stop sequence numbers need not be the same. The "kill" links should be one runlevel behind the corresponding "start" link.

Configuration Files

Script configuration files are placed in the /etc/rc.config.d directory. These files are used by the sequencer scripts to check configuration for a particular daemon and usually have the same name as their corresponding script in the /sbin/init.d directory. The configuration file for the cron daemon is:

#!/sbin/sh

# @(#) $Revision: 72.3 $

# Cron configuration. See cron(1m)

#

# CRON: Set to 1 to start cron daemon

#

CRON=1

When this file is sourced by its execution script, it assigns the value 1 to the CRON variable, showing that the cron daemon is enabled. Assigning a value 0 means that the daemon is disabled. If you make a change to a configuration file and later want to restore it, you can copy the original file from the /usr/newconfig/etc/rc.config.d directory.

14.9 System Shutdown

System shutdown is needed when you want to carry out maintenance work, such as adding or replacing some devices or upgrading memory. You also need to shut down and restart your system when you build a new kernel. The shutdown command is used for this purpose. Important options with the shutdown command are:

-r

Reboot the system after shutdown

-h

Halt the system after shutdown

-y

Does not require any interactive response

You can supply time in seconds as an argument to the command to delay the shutdown process for a specified number of seconds. You must change to the / directory before using this command. A broadcast message is sent to all logged-in users notifying them that the system is going down.

To shut down and halt your system after two minutes, use the following command.

# shutdown -h -y 0

You will see shutdown messages like the following, appear on your screen.

SHUTDOWN PROGRAM

07/17/99 13:28:50 EDT

Broadcast Message from root (console) Sat Jul 17 13:28:51...

SYSTEM BEING BROUGHT DOWN NOW ! ! !

/sbin/auto_parms: DHCP access is disabled (see /etc/auto_parms.log)

System shutdown in progress

___________________________

Stop CDE login server ..................................... OK

Stop X print server(s) .................................... N/A

Stop NFS server subsystem ................................. OK

Stopping Event Monitoring Service ......................... OK

Stopping Netscape FastTrack Server ........................ OK

Shutting down Measureware performance software ............ OK

Stopping audio server daemon .............................. OK

Stop auditing subsystem ................................... N/A

Stop environment monitoring daemon ........................ OK

Stopping hardware predictive .............................. OK

Stop diagnostic subsystem ................................. OK

Stop clock daemon ......................................... OK

Stopping HP Distributed Print Service ..................... OK

Stop print spooler ........................................ OK

Stopping disk array monitor daemons. ...................... OK

Stop accounting ........................................... OK

Stopping time synchronization ............................. FAIL *

Stop vt daemon ............................................ OK

Terminating X Font Server ................................. OK

Stop remote boot daemon ................................... OK

Stop the Isogon License Server daemon ..................... OK

Stop RPC daemon ........................................... OK

Stop DCE daemons .......................................... OK

Stop HA cluster SNMP subagent ............................. OK

Stopping OSPF MIB Network Management subAgent ............. N/A

Stopping SNMP HP-UNIX Network Management subAgent ......... OK

Stopping SNMP MIB-2 Network Management subAgent ........... OK

Stopping SNMP Trap Dest Network Management subAgent ....... OK

Stopping SNMP Master Network Management daemon ............ OK

Stopping outbound connection daemons for DDFA software .... N/A

Stopping mail daemon ...................................... OK

Stopping remote system status daemon ...................... N/A

Stopping RARP protocol daemon ............................. N/A

Stop PPP configuration .................................... OK

Stopping router discover protocol daemon .................. N/A

Stopping dynamic routing daemon ........................... N/A

Stopping Internet services daemon ......................... OK

Stopping multicast routing daemon ......................... N/A

Stop the Trusted Mode with Nis+ subsystem ................. OK

Stopping Internet Services ................................ OK

Stop NFS client subsystem ................................. OK

Stop NIS client subsystem ................................. OK

Stop NIS server subsystem ................................. OK

Stop NIS+ client subsystem ................................ OK

Stop NIS+ server subsystem ................................ OK

Stop NFS core subsystem ................................... OK

Stopping name server daemon ............................... N/A

Unconfigure LAN interfaces ................................ OK

Stop network tracing and logging daemon ................... OK

Stop pty allocator daemon ................................. OK

Stop system message logging daemon ........................ OK

Stop Software Distributor agent daemon .................... OK

Unconfigure Loopback interfaces (lo0) ..................... OK

Stop syncer daemon ........................................ OK

Killing user processes .................................... OK

Unload loadable modules ................................... N/A

Update kernel and loadable modules ........................ N/A

Unmount file systems ...................................... OK

Transition to run-level 0 is complete.

Executing "/sbin/reboot -h ".

Shutdown at 13:30 (in 0 minutes)

*** FINAL System shutdown message from root@myhp ***

System going down IMMEDIATELY

System shutdown time has arrived

reboot: CAUTION: some process(es) wouldn't die

Timeout waiting for other processors to acknowledge reboot.

sync'ing disks (0 buffers to flush):

0 buffers not flushed

0 buffers still dirty

The shutdown command invokes /sbin/rc scripts which in turn use sequencer scripts to shut down all daemons before halting the system. The /etc/shutdown.log file keeps a log of shutdown or reboot of the system. Some log entries in this file are shown here.

15:24 Thu Sep 18, 1997. Reboot:

06:58 Fri Sep 19, 1997. Reboot:

08:10 Fri Sep 19, 1997. Halt: (by myhp!root)

12:16 Fri Sep 19, 1997. Reboot: (by myhp!root)

13:17 Fri Sep 19, 1997. Reboot after panic: Data page fault

07:43 Mon Sep 22, 1997. Reboot: (by myhp!root)

08:20 Mon Sep 22, 1997. Reboot: (by myhp!root)

08:41 Mon Sep 22, 1997. Reboot:

09:04 Mon Sep 22, 1997. Reboot: (by myhp!root)

10:18 Mon Sep 22, 1997. Reboot: (by myhp!root)

Shutdown and Reboot Commands

The reboot command kills all processes instead of gracefully terminating them. Therefore, this speeds up the shutdown process but may cause data loss if other users are working on the system at the time of the reboot. If you are working in single-user mode, then it is safe to use the reboot command. Otherwise, always use the shutdown command.

The shutdown.allow File

This file is used to allow some system users to execute the shutdown command. Each line contains a system name followed by user names. Any user listed in this file has the privilege to shut down the system. An asterisk in the system name allows a user of given name from any system to execute the shutdown command. Some sample entries in this file are:

myhp root

myhp operator

* boota

Chapter Summary

HP-UX startup and shutdown processes are explained in this chapter. We started with an introduction to the startup process and listed the steps involved. The startup process can be divided into two major parts. The first part consists of

steps that are performed by code that resides in ROM. This code is called processor dependent code (PDC) and is different for each model of server and workstation. The second part consists of processes that are performed by the operating system. This part starts with the Initial System Loader (ISL). The ISL loads the hpux utility, which in turn loads the HP-UX kernel, /stand/vmunix, into the memory. The kernel starts the swapper process, ioinitrc, and then the init process. The init process starts the server daemons and brings the system into the appropriate runlevel state. At shutdown time, the init process changes the runlevel to 0 and halts the system.

In brief, the following items are discussed in the chapter.

Processor dependent code (PDC) does a self-test and probes the hardware attached can be used to boot HP-UX in single-user mode.

PDC uses the Stable Storage Area to keep configuration information.

The to the system.

PDC menus can be used to search devices attached to the system and to specify primary and secondary boot devices.

PDC can be used to boot from a particular device.

PDC boot area of the disk is in LIF format and it contains the ISL and some utility programs.

The swapper process has process ID 0 and manages memory swapping.

The init process reads the /etc/inittab file for its configuration.

Runlevel is a state of the system that shows what services are available at a particular time. HP-UX is in one of eight runlevels at all times.

To add a program to be run at boot time, you place an execution script in the /sbin/init.d directory and its configuration file in the /etc/rc.config.d directory. You place links to the script in the sequencer directories. The sequencer directories have names like /sbin/rcn.d where n represents a runlevel.

The shutdown command gets help from the execution scripts called by their respective links in the sequencer directories to stop server daemons and halt the system. The reboot command kills these daemons and reboots the system. The /etc/shutdown.allow files show which users are allowed to execute the shutdown command.

Test Your Knowledge

1:

All HP-9000 systems have processor dependent code (PDC). What is true about it?

A. It is used to add processors that are dependent on each other.

B. PDC on all HP systems is the same.

C. It is a programming language for HP processors.

D. It is used to initialize and boot HP systems.

2:

The autoboot information is stored in:

A. the AUTO file in the LIF area

B. the ISL

C. PDC

D. stable storage

3:

What can be used to boot HP-UX in single-user mode?

A. PDC

B. the hpux utility when properly called from the ISL

C. both of the above

D. none of the above

4:

What is the function of the secondary loader?

A. It loads the HP-UX kernel if the primary loader fails.

B. It is a utility that loads the HP-UX kernel during boot time.

C. It loads the ISL in the second phase of the boot process.

D. It is a configuration file for the kernel.

5:

The boot area of the primary system disk contains:

A. LIF

B. the hpux utility

C. the AUTO file

D. all of the above

6:

The search command in PDC is used to:

A. search primary boot disks

B. search all boot devices

C. search all network interfaces

D. search lost console devices

7:

What is the order of execution of scripts becheckrc, ioinitrc, and rc?

A. bcheckrc, ioinitrc, rc

B. ioinitrc, bcheckrc, rc

C. rc, ioinitrc, bcheckrc

D. rc, becheckrc, ioinitrc

8:

What information is present in stable storage?

A. primary boot path

B. alternate boot path

C. information if autoboot is enabled or disabled

D. all of the above

9:

What is true about the lifls command?

A. It is a standard HP-UX command to list files in the LIF area.

B. It is an LIF command to list files in the LIF area.

C. It is a PDC command to list files in the LIF area.

D. It is an LIF command used to list files in an HP-UX partition.

10:

The ID field in /etc/inittab file shows:

A. the processor ID number

B. the process ID number for the program in the action area

C. an arbitrary string to represent an entry in the file

D. runlevel in which the process is started

11:

What happens if the runlevel for a program is not specified in the /etc/inittab file?

A. The program is never started.

B. The program is started in all runlevels.

C. The program is started at the boot time.

D. The program is started only in runlevel 0.

12:

Which runlevel can be used for multiuser operation?

A. 0

B. 1

C. s

D. 3

13:

What command is used to check the current runlevel?

A. runlevel

B. who -r

C. showrun

D. init

No comments:

Post a Comment