Download Chapter 5

Document related concepts

CP/M wikipedia , lookup

DNIX wikipedia , lookup

Plan 9 from Bell Labs wikipedia , lookup

Booting wikipedia , lookup

Spring (operating system) wikipedia , lookup

Unix security wikipedia , lookup

Mandriva Linux wikipedia , lookup

Linux kernel wikipedia , lookup

Linux wikipedia , lookup

Windows NT startup process wikipedia , lookup

Linux adoption wikipedia , lookup

Caldera OpenLinux wikipedia , lookup

Smallfoot wikipedia , lookup

Security-focused operating system wikipedia , lookup

Transcript
SUSE Linux Enterprise Server
Administration (Course 3037)
Chapter 5
Manage System Initialization
Objectives
•
•
•
•
•
Describe the Linux Load Procedure
Manage Runlevels
Manage the Kernel
Manage the GRUB Boot Loader
Modify System Settings
SUSE Linux Enterprise Server Administration (Course 3037)
2
Describe the Linux Load Procedure
• Objectives
–
–
–
–
BIOS and Boot Manager
Kernel
initrd and linuxrc
init
SUSE Linux Enterprise Server Administration (Course 3037)
3
Describe the Linux Load Procedure
(continued)
SUSE Linux Enterprise Server Administration (Course 3037)
4
Describe the Linux Load Procedure
(continued)
• BIOS and Boot Manager
– Tasks performed by the BIOS
• Power-on self-test
• Initial detection and setup of hardware
• Accessing bootable devices
– BIOS also reads the MBR (Master Boot Record)
– BIOS starts the boot manager
• Using the code in the MBR
– Boot manager (such as GRUB)
• Loads the kernel and the initrd to memory and starts
the kernel
SUSE Linux Enterprise Server Administration (Course 3037)
5
Describe the Linux Load Procedure
(continued)
• Kernel
– Uncompresses itself
– Organizes and takes control of the continued booting
of the system
– Checks and sets the console
– Reads BIOS settings
– Initializes basic hardware interfaces
– Probes existing hardware and initialize it accordingly
– Manages hardware access
– Allocates CPU time and memory to programs
SUSE Linux Enterprise Server Administration (Course 3037)
6
Describe the Linux Load Procedure
(continued)
• initrd and linuxrc
– Boot manager informs the kernel that an initrd exists
• And where it is located in memory
– If initrd exists, it is integrated into the kernel
– Kernel decompresses the initrd
• And mounts it as a temporary root file system
– linuxrc
• Loads modules required to mount root file system
• May be dynamically linked
– As soon as linuxrc finishes
• initrd is unmounted and the boot process continues
SUSE Linux Enterprise Server Administration (Course 3037)
7
Describe the Linux Load Procedure
(continued)
• init
– Boots the system with all its programs and
configurations
– init process has ID number of 1
– /etc/inittab file
• Configuration file
– /etc/init.d/boot script
• Controls the start of services
– /etc/init.d/rc script
• Uses configured runlevels to start services and
daemons
SUSE Linux Enterprise Server Administration (Course 3037)
8
Manage Runlevels
• Objectives
–
–
–
–
–
Runlevel Basics
How to Change the Runlevel at Boot
How to Manage Runlevels from the Command Line
How to Shut Down or Halt the System
How to Set Runlevels with YaST
SUSE Linux Enterprise Server Administration (Course 3037)
9
Runlevel Basics
• What runlevels are
– Various runlevels define the state of the system
• init configuration file (/etc/inittab)
– Determines what happens on individual runlevels
– Syntax: id:rl:action:process
– Standard entries parameters
•
•
•
•
•
initdefault
bootwait
wait
ctrlaltdel
respwan
SUSE Linux Enterprise Server Administration (Course 3037)
10
Runlevel Basics (continued)
SUSE Linux Enterprise Server Administration (Course 3037)
11
Runlevel Basics (continued)
• init scripts
– Located in the directory /etc/init.d/
– Scripts can be called up
• Directly by init when you boot the system
• Indirectly by init when you change the runlevel
• Directly by the /etc/init.d/ script start or stop commands
– Some of the most important script include
•
•
•
•
•
boot
boot.local
boot.setup
halt
rc
SUSE Linux Enterprise Server Administration (Course 3037)
12
Runlevel Basics (continued)
SUSE Linux Enterprise Server Administration (Course 3037)
13
Runlevel Basics (continued)
SUSE Linux Enterprise Server Administration (Course 3037)
14
Runlevel Basics (continued)
• Runlevel symbolic links
– Each runlevel has a subdirectory in /etc/init.d/
– Types of files
• Sxxservice
• Kxxservice
– Point to service scripts in /etc/init.d/
• Some links point to the same script
SUSE Linux Enterprise Server Administration (Course 3037)
15
Runlevel Basics (continued)
SUSE Linux Enterprise Server Administration (Course 3037)
16
Runlevel Basics (continued)
SUSE Linux Enterprise Server Administration (Course 3037)
17
Runlevel Basics (continued)
SUSE Linux Enterprise Server Administration (Course 3037)
18
Runlevel Basics (continued)
• How init determines which services to start and stop
– Script /etc/init.d/rc examines directories
• /etc/init.d/rccurrentrl.d/ and /etc/init.d/rcnewrl.d
– Options
• Kxx link in /etc/init.d/rccurrentrl.d/ and Sxx link in
/etc/init.d/rcnewrl.d/ for the same service
– Script in /etc/init.d/ is not called at all
• Kxx link in /etc/init.d/rccurrentrl.d/ and no Sxx link in
/etc/init.d/rcnewrl.d/
– Stop script in /etc/init.d/service
• Sxx link in /etc/init.d/rcnewrl.d/ and no Kxx link in
/etc/init.d/rccurrentrl.d/
– Start script in /etc/init.d/service
SUSE Linux Enterprise Server Administration (Course 3037)
19
Runlevel Basics (continued)
• Activate and deactivate services for a runlevel
– Use command insserv or YaST
– INIT INFO block at the beginning of script
• Determines in which runlevel the service should start or
stop
• Used by insserv
– Use insserv after editing the INIT INFO block
• To create the needed links and renumber the existing
ones as needed
– Use /etc/init.d/service stop, and then insserv -r service
• To remove all links for a service
SUSE Linux Enterprise Server Administration (Course 3037)
20
How to Change the Runlevel at Boot
• The standard runlevel is 3 or 5
• GRUP choices
– Linux
– Floppy
– Failsafe
• Entry Linux options
– root
– vga
– runlevel
• Example: root=/dev/hda4 vga=791 1
SUSE Linux Enterprise Server Administration (Course 3037)
21
How to Manage Runlevels from the
Command Line
• Change to another runlevel
– Using command init
• Stop the system
– Entering init 0
• Restart the system
– Entering init 6
• Ctrl + Alt + Backspace
– Restarts the X Window system
• Restart graphical system
– Enter init 5
SUSE Linux Enterprise Server Administration (Course 3037)
22
How to Shut Down or Halt the System
• System should always be shut down properly
• Command shutdown
– Controls the shutdown of the system
– Informs all users that the system will be shut down
– Does not allow other users to log in before it shuts
down
SUSE Linux Enterprise Server Administration (Course 3037)
23
How to Shut Down or Halt the System
(continued)
SUSE Linux Enterprise Server Administration (Course 3037)
24
How to Set Runlevels with YaST
• Steps
–
–
–
–
–
Start YaST Runlevel Editor module
Switch to the Expert mode
Select a new default runlevel (optional)
Select a service and runlevels associated with it
Select Start Now, Stop Now, or Refresh status
(optional)
– Enable, disable the service
SUSE Linux Enterprise Server Administration (Course 3037)
25
How to Set Runlevels with YaST
(continued)
SUSE Linux Enterprise Server Administration (Course 3037)
26
How to Set Runlevels with YaST
(continued)
SUSE Linux Enterprise Server Administration (Course 3037)
27
Exercise 5-1 Manage Run Levels
• In this exercise you will manage run levels
SUSE Linux Enterprise Server Administration (Course 3037)
28
Manage the Kernel
• Objectives
–
–
–
–
–
Kernel Module Basics
How to Find Hardware Driver Information
How to Manage Modules from the Command Line
modprobe Configuration File (/etc/modprobe.conf)
Kernel Module Loader (kmod)
SUSE Linux Enterprise Server Administration (Course 3037)
29
Kernel Module Basics
• Kernel is installed in directory /boot/
• Drivers can be compiled into the kernel
– Or be loaded as kernel modules
• Kernel modules are in lib/modules/version/kernel/
• Files and directories related to the kernel
–
–
–
–
–
/boot/initrd
/boot/vmlinuz
/proc/sys/kernel/
/proc/version
/usr/src/linux/
SUSE Linux Enterprise Server Administration (Course 3037)
30
How to Find Hardware Driver
Information
• Command hwinfo
– Detects the hardware of your system
– Selects the drivers needed to run this hardware
– Syntax
• hwinfo --hardware_type
• hwinfo --help (for a short introduction to the command)
SUSE Linux Enterprise Server Administration (Course 3037)
31
Exercise 5-2 View Information about
the Hardware System
• In this exercise, you do the following:
– Part I: View General Information about the Hardware
System
– Part II: View Information about Specific Hardware
SUSE Linux Enterprise Server Administration (Course 3037)
32
How to Manage Modules from the
Command Line
• lsmod
– Lists the currently loaded modules in the kernel
• insmod module
– Loads the indicated module into the kernel
• rmmod module
– Removes the indicated module from the kernel
• modprobe module
– Loads the indicated module into the kernel
• Or removes it (with option -r)
SUSE Linux Enterprise Server Administration (Course 3037)
33
How to Manage Modules from the
Command Line (continued)
• depmod
– Creates the file /lib/modules/version/modules.dep
• modinfo option module
– Displays information about the module indicated
SUSE Linux Enterprise Server Administration (Course 3037)
34
modprobe Configuration File
(/etc/modprobe.conf)
• /etc/modprobe.conf
– Configuration file for the kernel modules
• Command types
– install
• Lets modprobe execute commands when loading a
specific module into the kernel
– alias
• Determine which kernel module will be loaded for a
specific device file
– options
• Options for loading a module
SUSE Linux Enterprise Server Administration (Course 3037)
35
Kernel Module Loader (kmod)
• kmod
– Most elegant way to use modules
– Performs background monitoring
– Makes sure modules are loaded by modprobe
• Activate kmod
– Option Kernel module loader needs to be set to “y”
(yes)
• In the kernel configuration
• kmod is not designed to unload modules
automatically
SUSE Linux Enterprise Server Administration (Course 3037)
36
Exercise 5-3 Manage the Linux Kernel
• In this exercise, you view information about your
kernel, and load and unload kernel modules
SUSE Linux Enterprise Server Administration (Course 3037)
37
Manage the GRUB Boot Loader
• Objectives
–
–
–
–
–
What a Boot Manager Is
Boot Managers in SUSE Linux
How to Start the GRUB Shell
How to Modify the GRUB Configuration File
How to Configure GRUB with YaST
SUSE Linux Enterprise Server Administration (Course 3037)
38
What a Boot Manager Is
• Boot loader
– Loads the operating system kernel
• Which then loads the system
– Locates the operating system files on the hard drive
• And starts the operating system
• Boot manager
– Can handle several operating systems
• Two-stage architecture
– Stage 1: contains code to load stage 2
– Stage 2: contains the actual boot manager
SUSE Linux Enterprise Server Administration (Course 3037)
39
Boot Managers in SUSE Linux
• GRUB Boot Manager
– Standard boot manager in SLES
– GRUB features include
• File system support
• Interactive control
• LILO Boot Manager
– Configuration file is /etc/lilo.conf
– Structure similar to GRUB configuration file
SUSE Linux Enterprise Server Administration (Course 3037)
40
Boot Managers in SUSE Linux
(continued)
• Map files, GRUB, and LILO
– Kernel is a file within a file system on a partition
• Concepts unknown to the BIOS
– Maps
• Note physical block numbers on disk that comprise
logical files
– BIOS loads all blocks listed in maps
– LILO relies entirely on maps
– GRUB tries to become independent from maps at an
early stage
SUSE Linux Enterprise Server Administration (Course 3037)
41
Boot Managers in SUSE Linux
(continued)
• Additional information
– Linux system
• Manual pages and info file
• README files
– In the directory /usr/share/doc/packages/grub/
– In the directory /usr/share/doc/packages/lilo/
– Internet sites
• www.gnu.org/software/grub/
SUSE Linux Enterprise Server Administration (Course 3037)
42
How to Start the GRUB Shell
• From a running system
– Enter command grub as root
– Command find
• Finds out which partition contains the kernel
– Close GRUB shell by entering quit
• From the boot prompt
– From the graphical boot selection menu, press Esc
• A text-based menu appears
– Start the GRUB shell by typing c
SUSE Linux Enterprise Server Administration (Course 3037)
43
How to Modify the GRUB
Configuration File
• Edit file /boot/grub/menu.lst structure
• File structure
– General options
– Options for various operating systems
• That can be booted with the GRUB
SUSE Linux Enterprise Server Administration (Course 3037)
44
How to Configure GRUB with YaST
• Steps
–
–
–
–
Start YaST Boot Loader Configuration module
Add, edit, or delete an option
Display and edit the configuration files (optional)
Select additional boot options (optional)
SUSE Linux Enterprise Server Administration (Course 3037)
45
How to Configure GRUB with YaST
(continued)
SUSE Linux Enterprise Server Administration (Course 3037)
46
Exercise 5-4 Manage the Boot Loader
• In this exercise you do the following:
– Part I: Pass Kernel Parameters to the Boot Loader
– Part II: Configure Boot Managers
SUSE Linux Enterprise Server Administration (Course 3037)
47
Modify System Settings
• Tasks involved
– View and Change System Settings (/proc/sys/)
– Modify Kernel and Hardware Parameters with
Powertweak
– Configure /etc/sysconfig/ Files with YaST
SUSE Linux Enterprise Server Administration (Course 3037)
48
View and Change System Settings
(/proc/sys/)
• Files in /proc/ and /proc/sys/ are kept in memory
– Changes to these files are lost after a reboot
• View the current configuration
– Use cat and less to view files in /proc/sys/
– Use sysctl to view modifiable values below /proc/sys/
• Edit the current configuration
– Use echo to edit individual configuration values
• You can also use sysctl
– Use sysctl to load and set kernel parameters
• Execute script
– Activate it by entering insserv –d boot.sysctl
SUSE Linux Enterprise Server Administration (Course 3037)
49
Modify Kernel and Hardware
Parameters with Powertweak
• Steps
–
–
–
–
–
–
Start YaST Powertweak Configuration module
Create the Powertweak configuration file
Find a parameter
Select or enter the setting
Find and configure other setting (optional)
Review and save the changes
SUSE Linux Enterprise Server Administration (Course 3037)
50
Modify Kernel and Hardware
Parameters with Powertweak
(continued)
SUSE Linux Enterprise Server Administration (Course 3037)
51
Modify Kernel and Hardware
Parameters with Powertweak
(continued)
SUSE Linux Enterprise Server Administration (Course 3037)
52
Modify Kernel and Hardware
Parameters with Powertweak
(continued)
SUSE Linux Enterprise Server Administration (Course 3037)
53
Modify Kernel and Hardware
Parameters with Powertweak
(continued)
SUSE Linux Enterprise Server Administration (Course 3037)
54
Configure /etc/sysconfig/ Files with
YaST
• Changes to system configuration with YaST happen
in one of the following ways:
– Direct modification of configuration files
– YaST modifies the configuration files in /etc/sysconfig/
• Directory /etc/sysconfig/
– Saves majority of configuration settings for SLES
• Edit these files by using
– YaST modules
– YaST module /etc/sysconfig Editor
SUSE Linux Enterprise Server Administration (Course 3037)
55
Configure /etc/sysconfig/ Files with
YaST (continued)
• Steps
–
–
–
–
–
–
Start YaST /etc/sysconfig Editor module
Find a setting
Select or enter a setting
Find and configure other settings
Select Confirm Each Activation Command
Review and save changes
SUSE Linux Enterprise Server Administration (Course 3037)
56
Configure /etc/sysconfig/ Files with
YaST (continued)
SUSE Linux Enterprise Server Administration (Course 3037)
57
Configure /etc/sysconfig/ Files with
YaST (continued)
SUSE Linux Enterprise Server Administration (Course 3037)
58
Configure /etc/sysconfig/ Files with
YaST (continued)
SUSE Linux Enterprise Server Administration (Course 3037)
59
Exercise 5-5 Change the Power
Setting with YaST
• In this exercise you will change the power setting of
your SLES system using YaST
SUSE Linux Enterprise Server Administration (Course 3037)
60
Summary
• The boot manager starts the Linux kernel
• A Linux system is categorized using runlevels
• init daemon
– Loads and unloads daemons using its configuration file
/etc/inittab
• /etc/inittab file
– Runs scripts in the /etc/init.d/rcrunlevel.d
• View current runlevel
– Using the runlevel command
SUSE Linux Enterprise Server Administration (Course 3037)
61
Summary (continued)
• Start individual daemons
– By running script in the /etc/init.d with start argument
• Or by using the rcdaemonname start command
• Device drivers are either
– Compiled into the Linux kernel
– Loaded into the kernel as modules
• Linux kernel is loaded into memory during system
initialization
– By a boot loader or boot manager
SUSE Linux Enterprise Server Administration (Course 3037)
62
Summary (continued)
• LILO
– Traditional Linux boot manager
• GRUB boot loader
– Used by default in SLES
• /etc/lilo.conf file
– LILO configuration file
• /proc/sys/ directory
– Exists in memory
– Contains information and settings for a running system
SUSE Linux Enterprise Server Administration (Course 3037)
63