14_01
Linux system startup process
Post (power on Self Test)-->bios (Boot Sequence)-->mbr (bootloader,446 (MBR reads only one, no longer reads second))-->kernel (typically compressed)-- (ROOTFS)/sbin/init (/etc/inittab)-->-->-->
The service started differently:
Operating level: 0-6
0:halt (OFF)
1:single user mode, directly into the administrator identity
2:multi user mode, no NFS
3: Multi User mode (text multi-user)
4:reserved (temporarily unused, reserved mode)
5: Multi User mode (graphical multi-user, graphic mode)
6:reboot ()
Verbose start-Up process: (Windows Bootloder does not recognize other systems, so if you first install Linux and then install Windows,windows bootloader will be the Linux bootloader cover out, Installing a dual system requires installing Windows first)
!! WIN8 will lock the MBR, so after installing the WIN8, the hard disk will not be able to install other systems
Linux bootloader (MBR)
Lilo:linux LOader (cannot boot 1024 cylinders after the partition kernel, does not support the disk after 8G, suitable for embedded)
Grub:grand Unified Bootloader
Stage1:mbr
Stage1_5:
stage2:/boot/grub/
Grub.conf
Default=0 # Sets the number of the default start title, starting with 0
Timeout=s # waits for the user to select the timeout length, in seconds
Splashimage= (hd0,0)/grub/splash.xpm.gz # Grub Background image
Hiddemenu: # Hide Menu
Title Red Hat enterprice Linux Server (2.6.18-308.el5) #内核标题, or operating system name, string, can be freely modified
Root (hd0,0) #内核文件所在的设备: For grub, all types of hard drives are HD, in the Format (hd#,n): hd#, #表示第几个磁盘: The last N indicates the partition of the corresponding disk;
kernel/vmlinxu-2.6.18-308.el5 ro root=/dev/vo10/root rhgb quiet #内核文件路径, and parameters passed to the kernel
initrd/initrd- 2.6.18-308.el5.img RAMDisk file path (generated by the last step of installing the SYSTEM)!!!! Version number to be consistent
,,,,
,,,,
,,,,
Kernel design style:
Core: Dynamic loading of peripheral kernel modules
Kernel:/lib/modules/"kernel version number named directory"/
Kernel itself name: vmlinux-x.x.x
/lib/modules/2.26.32/
Redhat5:ramdisk-->initrd
Redhat6:ramfs-->initramfs
Redhat,suse
Single core: simple design, Linux (thread in Linux is called, lightweight process--LWP. )
Core: KO (Kernel object)
So ()
Microkernel: Complex design, windows,solaris (threads)
Chroot: The directory in which to replace the root. : Chroot/psth/to/temproot [COMMAND ... ]
Chroot/test/virrot/bin/bash
Ldd/psth/to/binary_file: Displays the shared library since the binaries
The root is self-referencing.
10:0:wait:/ETC/RC.D/RC 0
rc0.d/
k*
Stop
s*
Start
/ETC/RC.D/INIT.D,/ETC/INIT.D
Service class Script:
Start
SysV:/ETC/RC.D/INIT.D
Start|stop|restart|status
Reload|configtest
Chkconfig (! Although Chkconfig and description are commented out, Chkconfig will still analyze the two lines. When we use the Chkconfig command, any script that has these lines can be automatically created for the connection)
#chkconfig: Runlevels SS (Start priority) KK (Close priority)
Runlevels: '-' indicates that there is no level, default is the connection at the beginning of s*;
If the ellipsis level is specified, the default is 2,345 levels or the current level;
When the Chkconfig command creates a connection for this script in the RC#.D directory, runlevels indicates that the connection is created by default for the beginning of the s*, and that all other levels are created by default for the connection beginning with k*;
The start priority at the back of S is the number represented by SS, and the number after K is closed in order of precedence for KK;
#description: Description of the simple function of this script; \, continue.
@@@ The first service is turned off, and the service that is turned on is turned off first because the service that is first opened may be dependent on the service behind it.
Chkconfig
--list NULL to see the start-up settings for all independent daemons, Independent daemons!
--list Service Name View specific services
Chkconfig--add service_name Creating a link file for/RC.D
Chkconfig--del Service Name Delete a link file under/RC.D
Chkconfig--level runlevels service name {On|off}
MYSERVICE.SH: Determine if a service is turned on by lock file
#!/bin/bash
#
#chkconfig: 2345 77 22
#description: Test Service
#
Lockfile=/var/lock/subsys/myservice
Status () {
If [-e $LOCKFILE]; Then
echo "Running ..."
Else
echo "stoped."
Fi
}
Usage () {
echo "' basename $ ' {start|stop|restart|status}"
}
Case $ in
Start
echo "Starting ..."
Touch $LOCKFILE
;;
Stop
echo "Stoping ..."
Rm-f $LOCKFILE &>/dev/null
;;
Restart
echo "Restart ..."
;;
Status
Status
;;
*)
Usage
;;
Esac
/etc/rc.d/rc.local: The system finally starts a service, exactly said, should execute a script;
S99loacl the last startup script when the system starts.
So some inconvenient to define as a service, or we can not easily write it as a script command, we may be written here!!!!!!
/etc/inittab's Mission:
1, set the default operating level;
2, run the system initialization script;
3. Run the script in the directory corresponding to the specified level;
4, set the operation of Ctrl+alt+del combination key;
5, define the UPS power supply in the power failure/recovery operation performed;
6, start the virtual terminal (2,345 level);
7, start the graphics terminal (5 level);
Daemon Type:
Independent Daemon Process
XINITD: Super Daemon (requires associated runlevel). The Super daemon is the agent of the Transient daemon (multiple Super Daemons)
Transient daemon: No need to correlate to runlevel (multiple transient daemons)
Core:/boot/vmlinuz-version
Kernel module (KO):/lib/modules/version/
Kernel design:
Single Core
Modular design
Micro-core
Loading module:
Insmod
Modprobe
www.kernel.org
kernel-2.6.17------2 (major version number). 6 (minor version number). 17 (fixed number)
How user space accesses and monitors the kernel:
/proc,/sys
Pseudo file System
/proc/sys: Many of the files in this directory are readable and writable
/sys/: Some files can be read and written
Method for setting kernel parameter values: (temporary)
echo VALUE >/proc/sys/to/somefile
Sysctl-w Kernel.hostname
Permanent (not effective immediately):/etc/sysctl.conf
Command immediately in effect: #sysctl-P-------notifies the kernel to reread sysctl.conf
SYSCTL-A: Show all kernel parameters and their values
Kernel Module Management:
Lsmod: Viewing the kernel modules used
Modprobe mod_mame; loading a module
Modprobe-r mod_mame; uninstalling a software module
Modinfo: View information about a module
insmod/path/to/module_file; loading module
Rmmod Mod_name;
Depmod /path/to/module_dir;
Post-->bios (Boot Sequence)--BootLoader (MBR)-->kernel (INITRD,INITRAMFS)-->init (/etc/inittab)
/etc/inittab:
Setting the default Run level
System Initialization (/ETC/RC.D/RC.SYSINIT)
Run a service script at the specified level
/etc/rc.d/init.d/
/etc/rc.d/rc#.d
Rc0.d--rc6.d
k*
s*
00-99: Run order
Start a virtual terminal
Start the graphics terminal
/etc/rc.d/rc.sysinit:
Detect and re-mount the root file system in read-write mode;
Set host name;
Detect and mount other file systems in the/etc/fstab;
Start swap partition;
Initialize the drive of the peripheral hardware device;
RHRL6:
Upstart-->init
/etc/inittab
/etc/init/*.conf
Kernel initialization:
16_01
Compile kernel:
1. Configuration
Make Menuconfig
Make Gconfig
Make Kconfig
Make Oldconfig
Make Config
Save As. config
2.
Make
Make Modules_install
Make install
Module Installation Location:/lib/modules/kernel_version/
How to implement partial compilation:
1. Compile only the relevant code under a subdirectory:
Make dir/
Make arch/
Make drivers/net/
2. Compile only some modules
Make m=drivers/net/
14_01~~14_04