0% found this document useful (0 votes)
182 views16 pages

Startup and Shutdown PDF

The document discusses the boot and shutdown processes on Unix/Linux systems. It describes the key steps in booting including kernel initialization, hardware detection, starting system processes, and running startup scripts. It also covers single-user mode, GRUB boot loading, network booting, protecting the boot process, and differences in startup scripts between Solaris and HP-UX.

Uploaded by

teddy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
182 views16 pages

Startup and Shutdown PDF

The document discusses the boot and shutdown processes on Unix/Linux systems. It describes the key steps in booting including kernel initialization, hardware detection, starting system processes, and running startup scripts. It also covers single-user mode, GRUB boot loading, network booting, protecting the boot process, and differences in startup scripts between Solaris and HP-UX.

Uploaded by

teddy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

Booting and Shutting Down

 Bootstrapping
 The computer must pull itself up
 Automatic and manual booting
 Steps in the boot process
• Loading and initialization of the kernel
• Device detection and configuration
• Creation of spontaneous system processes
• Execution of system startup scripts
• Multi-user operation

Startup and Shutdown 1-1

Booting and Shutting Down


 Kernel initialization
• Pathname is vender dependent
– Traditional /vmunix
• Two steps loading
– ROM loads a small boot program into memory from disk
– This program then arranges for the kernel to be loaded
• Memory for internal data structure is allocated
 Hardware configuration
• Check what hardware present
• Locate and initialize each device as specified
• Probe the bus for devices and ask the appropriate
drivers for information.
– Reboot maybe needed for new devices connected later.

Startup and Shutdown 1-2

1
Booting and Shutting Down
 System processes
• Spontaneous processes
– Vary from system to system
– On system V-ish machines:
» sched – process 0
» init – process 1
» various memory and kernel process handlers.
– Not real processes, but port of kernel
• Once the spontaneous processes have been created,
the kernel’s role in bootstrapping in complete.

Startup and Shutdown 1-3

Booting and Shutting Down


 Single user
• Password may or maynot be required to enter into
root shell
• The root partition / is mounted
– /usr maybe mounted too
• You can mount other partition manually
• You can change the read only mount to be write-mode
 Execution of startup scripts
• Normal shell scripts
• Process init run them according some rules
 Multi-user operation
• Init spawns getty processes
• Getty allows user login

Startup and Shutdown 1-4

2
Booting and Shutting Down
 Booting in single-user mode
 Solaris
• From boot prom ( by press stop +a), type
boot –s
• Other boot commands
– boot /path_to_kernel
– boot –s
– boot –r
– boot –a /etc/system.bak
– probe-scsi
 HP-UX
• During prompt
• Type “boot pri isl”
• Then type “hpux –iS /stand/vmunix

Startup and Shutdown 1-5

Booting PC
 More complex than …
 Firmware in machine designed for Unix knows
 How to use the device connected to the machine
 How to talk to the network on a basic level
 How to understand disk based file system
 On PC, initial boot code is BIOS – extremely
simplistic compare to the firmware
 Set the boot priority, try cdrom, then disk, …
 Load the first 512 bytes of the disk – Master Boot
Record (MBR)
 MBR load a secondary boot program (“boot loader”) from
a disk partition
• Lilo (Linux Loader)
• Grub (Grand Unified Bootloader)

Startup and Shutdown 1-6

3
Grub
 Powerful boot loader
 Is designed to address the complexity of
booting a personal computer
 A wide variety of free OS + proprietary OS

 How to boot OS’


 Loading an OS directly
 Chain-loading

 Naming convention
 The first hard disk partition 1: (hd0,1)
 (hd0,0)/vmlinuz

Startup and Shutdown 1-7

Loading OS from Grub


 Grub can boot any multiboot-compliant OS
in the steps directly:
 Set root device with command root
 Load the kernel image with command kernel
• Append parameters to kernel after the filename
 Load modules with module
 Run the command with boot

 Example:
 title GNU/Linux
 Kernel (hd1,0) /vmlinuz root=/dev/hdb1

Startup and Shutdown 1-8

4
Grub’s chain-lading
 Boot unsupported operating system
 The boot load is in the boot sector of the partition
where the OS is installed
 Set root device with rootnoverify
 Set the active flag in the partition with makeactive
 Load the boot loader with chainloader
 Run boot
 Example:
Title Windows NT
Root (hd0,0)
Make active
Chainloader +1

Startup and Shutdown 1-9

Make your system robust

Startup and Shutdown 1-10

5
Network boot
 Situation
 No local disk
 Installation

 Net BOOT ROM - PXE ROM


 Boot the machine
 Set up the network card ( talk with DHCP)
 Download a second stage boot image – pxegrub
 Pxegrub will download configuration from tftp
server
 Then download the OS image

Startup and Shutdown 1-11

Protecting
 Set password to start interactive
operation
password –md5 $1$.............
 For each item
 Use lock
Title Boot DOS
Lock
Rootnoveryfy (hd0,1)
Makeactive
Chainload +1
 Use password in the place of lock
Startup and Shutdown 1-12

6
Grub’s user interface
 Menu interface
 Choose preconfigured
 Edit the configuration

 Command line
 flexible. – do what ever you need

 Get into the interface


 Interrupt before the timeout
timeout sec

Startup and Shutdown 1-13

Exercise
 Take a look at your grub configuration file
 /etc/grub.conf
 what is the root device

 Get into the grub menu interface


 Get into the grub command line

Startup and Shutdown 1-14

7
Startup scripts
 System V style
 /etc/init.d
 /etc/rc0.d /etc/rc1.d …
 Startup scripts perform
 Setting the name of the computer
 Setting the time zone
 Checking the disks with fsck
 Mounting the system’s disk
 Removing old files from /tmp directory
 Configuring the network interfaces
 Starting up daemons and network services

Startup and Shutdown 1-15

Startup scripts
 Run levels:
 Level 0: system is completely shut down
 Level 1 or S: single-user mode
 Level 2 –5 : multiuser levels
• 2 or 3 are normal
• 4 or 5 rarely used
 Level 6: reboot level
 What to do for each level
 Defined in /etc/inittab
• Entry format:
id:runlevels:action:process
• Default level
• Typically SAs don’t need to mess up with it

Startup and Shutdown 1-16

8
Startup scripts
 The startup scripts called by inittab
 Individual script master copy stays in init.d,
typically under /etc or /sbin
• Understand argument start, stop, [restart]
 Symbolic links are made to appropriate
directories /etc/rc*.d or /sbin/rc*.d
• Links start with S or K followed by a number and the
name of the service
– Example, on Fedora1 under /etc/rc3.d
K20nfs -> ../init.d/nfs
S12syslog -> ../init.d/syslog

Startup and Shutdown 1-17

Startup scripts
 When lower run level transitions to higher level:
• Init runs all the scripts start with S
– in ascending numerical order
– with argument start
 When higher run level transitions to lower level:
• Init runs all the scripts start with K ( for kill)
– in desending numerical order
– with argument stop
 To start a daemon, we need to make a symbolic
links.
• Example:
#ln –s /etc/init.d/sshd /etc/rc2.d/S99sshd
#ln –s /etc/init.d/sshd /etc/rc2.d/K25sshd

Startup and Shutdown 1-18

9
Startup scripts
 Solaris startup scripts
 System-V style
• /etc/init.d and /etc/rc*.d
 Configuration files
• /etc/default
– init
– Login
– Console
– Cron
– ……
• /etc/hostname.interface

Startup and Shutdown 1-19

Startup scripts
 HP-UX startup scripts
 System-V style
• /sbin/init.d and /sbin/rc*.d
 Configuration files
• Under /sbin/rc.config.d
• Match the master script name
• Example:
– /sbin/init.d/HpmOracle
– /sbin/rc.config.d/HpmOracle
 Output of startup scripts in /etc/rc.log
• Excellent place to look for startup errors.

Startup and Shutdown 1-20

10
Startup scripts
 Some commonly modified HP-UX config files in
/etc/rc.config.d
• SnmpMaster
• auditing
• netconf
• nameservs
• nfsconf
• mailservcs
• lp
 Red Hat startup scripts
• /etc/rc.local
• interactive confirmation mode
• /etc/sysconfig files
– Hwconf
– Network, network-scripts
– Sendmail
– syslog Startup and Shutdown 1-21

Startup scripts
 FreeBSD
 A single startup script /etc/rc
• No concept of level
• Read three files that specify configuration
– /etc/defaults/rc.conf
– /etc/rc.conf
– /etc/rc.conf.local
• Scripts rc.something will be run in a predefined order.
• Script rc.local

Startup and Shutdown 1-22

11
Rebooting and shutting down
 The need to reboot/shutdown
 Scheduled maintenance, such as OS upgrade
 Hardware changes or additions
 Running diagnostics
 Performance tunning, such as changing static
system configuration
 Administrative tasks, such as testing new
startup scripts, etc.
 System not responding

Startup and Shutdown 1-23

Rebooting and shutting down


 Clean system shutdown
 All users are notified, with some reasonable advance
warning.
 All running process are sent a singal to exit gracefully,
provided the program has mage provisions to do so
 All subsystems are shutdown gracefully
 All remaining users are logged off and remaining process
are killed
 File system integrity is maintained
 Depending on the type of shutdown, the system moves to
single-user mode, the processor is halted, or the system
is rebooted…

Startup and Shutdown 1-24

12
Rebooting and shutting down
 Ways to shutdown or reboot
 Turn off power
 Use shutdown command
 Use halt or reboot commands
 Sending init a TERM signal
 Using telinit to change init’s run level
 Killing init

Startup and Shutdown 1-25

Rebooting and shutting down


 Command shutdown
 Safest, most considerate, and most through way to
• Initiate a halt
• Reboot
• Return to single-use mode
 Arguments
• System V:
#shutdown –g n [-i level] [-y]
-g Wait time, default 60
level usually
0: if you intend to turn off the power
1: administrative state
2: single-user mode
5 firm ware
6 reboot to initdefault state
Startup and Shutdown 1-26

13
Rebooting and shutting down
• Example. On Hp-Ux
shutdown –h now
• Read “man shutdown “ on your lab machine and try it
out.
 Aborting a shutdown
 During grace period, kill it
 Otherwise, leave it

 Shutdown security
 On Hp-UX
• Only root is allowed by default
• Configure /etc/shutdown.allow

Startup and Shutdown 1-27

Rebooting and shutting down


 When the system crashes
 Hardware failure
• Ex: CPU panic
 Unrecoverable hardware errors
 Power failures
 Env problems: too hot.
 Software problems
 Resource problems
 What to do
 Reboot
 Collect the info
• Check the lights
• Check the console
• Check the crash dump file or other logs if rebooted already
 When the system won’t boot
Startup and Shutdown 1-28

14
Rebooting and shutting down
 Common failures
 Bad or flaky hardware
• Check the obvious first
– Is it turned on?
– Is cable connection loose?
– Is the SCSI chain terminated?
• Try humoring the device
– Power cycling
– Call field service
• Device failure
– Call field service

Startup and Shutdown 1-29

Rebooting and shutting down


 Unreadable filesystems on working disks
– Bad rootfilesystem
» Boot it up using other media (tape or cdrom)
» Remaking the system restoring its files from backup.
» The worst case is to reinstall OS and restore files
Example: HP-UX has the recovery utility
 Damage to non-filesystem areas of a disk
• Damaged boot areas:
– Boot block can be restored sometime.
– Exactly follow the steps that vendor support provides
• Corrupted partition tables
– Recreate the partition provided you have complete and
detailed records of how the partitions were setup.

Startup and Shutdown 1-30

15
Rebooting and shutting down
 Incompatible hardware
• New device
– System does not support the type of device
– Need system reconfigure
» Remove it first and then follow the vendor instruction
to make the change on your system first.
• Problems after an upgrade
– Too too old devices
– New release bugs
 System configuration
• Error in configuration files
• Unbootable kernel

Startup and Shutdown 1-31

16

You might also like