- System startup process
- Bios
- Mbr
- Grub
- KERNEL
- Init
- Single-User change root password
- GRUB Encryption
System startup process
- Bios
- Mbr:boot Code
- Execute Bootstrapper-GRUB
- Load kernel
- Execute init
- RunLevel
Bios
- Basic Input Output System, typically stored in the motherboard's BIOS chip
- Run the BIOS first when the computer starts, check the hardware and look for bootable devices
- Bootable devices are defined in BIOS settings, such as USB, CDROM, HD
Mbr
Different systems have different MBR
- Boot code is executed after the BIOS has found a bootable device
- The boot code is the first 446 bytes of the MBR
Grub
MBR generally acts as a jump, starting a more complex boot program, such as Grub
- Grub is now the mainstream boot program for Linux use
- Can be used to boot almost all of the operating systems now, PE is also grub boot
- Grub related files are saved in the
/boot/grub
directory
Stage1 (MBR), xxx_stage1_5 (file system driver), Stage2
- The Grub configuration file is
/boot/grub/grub.conf
- Configuration format:
default=0 # 第一个引导程序timeout=5 # 停留时间splashimage=(hd0,1)/boot/grub/splash.xpm.gz # 引导界面背景hiddenmenu # 默认隐藏菜单title CentOS # 操作系统名称 root (hd0,1) # 操作系统所在分区,第一块硬盘第二个分区 # 内核以及传递给内核的参数(ro root=...),用空格分开 kernel /boot/vmlinuz-2.6.32-431.el6.x86_64 ro root=... # initial ram file system,内核模块打包文件 initrd /boot/initramfs-2.6.32-431.el6.x86_64.img
KERNEL
- The MBR boot code will be responsible for locating and loading the Linux kernel
- The Linux kernel is saved in
/boot/vmlinuz-2.6.32-431.el6.x86_64
- Kernel module Packaging files are also typically loaded:
/boot/initramfs-2.6.32-431.el6.x86_64.img
- Linux to keep the kernel of the simplification of some of the less common drivers, functions compiled into a module, when needed to dynamically load, and these modules are packaged to save as a Initramfs file
- Earlier versions of Linux use the Initrd file, Initramfs is a initrd alternative optimized version, more space-saving and more flexible than INITRD
- Command
dmesg
or /var/log/dmesg
file to view the output information of the kernel at the start of this boot
Init
- Init (
/sbin/init
) is the first process running in a Linux system, the parent process of all processes.
- The call
/etc/rc.d/rc.sysinit
is responsible for initializing the system, mounting the file system, and starting the corresponding service based on the RunLevel
- Linux RunLevel (runlevel):
- 0
Shutdown
- 1
Single-User mode
- 2
Multi-user mode with no network
- 3
Multi-user mode
- 4
Not used
- 5
X11 Graphical mode
- 6
Restart
/etc/inittab
The default runlevel can be modified through the configuration file
etc/init/
The files under are other configuration information
- Each level corresponding to the startup service is saved in the
/etc/rc.d/rc[0-6].d/
runlevel
can display current and previous RunLevel
init
Available to change the current run level
Single-User change root password
- Pass parameters to the kernel
1
or single
enter single-user mode
- No services are started in single-user mode
- Single-user mode log in directly with the root user and require a password
- You can use passwd to modify the root password
GRUB Encryption
- By adding the following parameters to the boot configuration in grub.conf
password --md5 $1$aoWpTe$/MWUUYbBIF.2RUZK8nbWU0
- The encrypted password can be generated by the
grub-md5-crypt
Alternatively, you can refer to Nanyi's blog:
- How the computer is started
- Linux Start-up process
Linux Introduction-8 Linux system boot details