当前位置:网站首页>12、 Start process

12、 Start process

2022-07-06 22:13:00 Lyon-w

Introduction to the startup process

Modern computer system startup is a complex combination of hardware and software . Start from the defined endpoint , To run with a login prompt
System , It requires a lot of hardware and software to work together . The following list provides a high-level overview of the tasks involved in starting the system .
x86_64 The list of virtual machines is roughly the same .

rehdat 5、6、7 Differences at startup

Start up process list
1、 The computer is powered on . System firmware ( modern UEFI Or older BIOS) Run post (POST), And start
Initialize part of the hardware .
Use system BIOS or UEFI Configuration screen ( Get up early and press F2 Accessible settings )
2、 The system firmware will search for bootable devices , May be in UEFI Start the , It may also follow BIOS Search the master boot record on all disks in the order configured in (MBR)
Use system BIOS or UEFI Configuration screen ( Get up early and press F2 Accessible settings )
3、 The system firmware will read the boot loader from the disk , Then give control of the system to the boot loader . Red hat enterprise edition Linux8 in , The boot loader is GRand Unified Bootloader version2(GRUB2)
Use grub2-install Command to configure , It will install GRUB2 As the boot loader on the disk .
4、GRUB2 Will be taken from /boot/grub2/grub.cfg The file loads the configuration and displays a menu , From which you can choose the kernel to boot .
Use /etc/grub.d/ Catalog 、/etc/default/grub Document and grub2-mkconfig Command to configure , To generate /boot/grub2/grub.cfg file .
5、 Select after the kernel timeout expires , Boot loader loads kernel and... From disk initramfs, And put them in memory .initramfs It's an archive , It contains the kernel modules of all necessary hardware at startup 、 Initialization scripts and so on . stay redhat8 in ,initramfs Contains the entire system available to itself .
Use /etc/dracut.conf.d/ Catalog 、dracut Command and lsinitrd Command to configure , To examine initramfs file .
6、 Start the loader and give control to the kernel , This passes any options specified in the kernel command line that starts the loader , as well as initramfs Location in memory
7、 The kernel can be found in initramfs Find all the hardware of the driver in , The kernel initializes these hardware , And then as a PID1 from initramfs perform /sbin/init. stay redhat8 in /sbin/init It's a point systemd Link to .
8、initramfs Medium systemd The process will execute initrd.target All units of the target . This includes... On disk root The file system is mounted on /sysroot Catalog .
Use /etc/fstab To configure
9、 The kernel will root File system from initramfs Switch back to the /sysroot Medium root file system . And then ,systemd Will make the disk installed systemd Copy to re execute .
10、systemd Will find the default target passed from the kernel command line or configured in the system , Then start or stop the unit , In a configuration that meets this goal , So as to automatically solve the dependency relationship between units . Essentially ,systemd A process is a set of units that the system should activate to achieve the desired state . These processes usually launch a text-based login or graphical login screen
You can use /etc/systemd/system/default.target and /etc/systemd/system/ To configure .

Restart and shut down
To turn it off restart
1 init 0 init 6
2 poweroff reboot
3 systemctl poweroff systemctl reboot
4 shutdown -h 20:00 shutdown -r 0
poweroff and reboot yes systemctl poweroff and systemctl reboot Link file for

choice systemd The goal is
systemd Processes are the first loaded processes when the system starts , It can help us choose which interface to enter directly when starting up
graphical.target Multi user gui
multi-user.target Multi user , Text interface
rescue.target Rescue interface
emergency.target Emergency rescue mode ( The read-only form is attached to / On )

View the graph startup service dependencies
systemctl list-dependencies graphical.target | grep target

The state of the service in the dependency
systemctl list-units --type=target --all

Switch between text and graphical interface
systemctl isolate multi-user.target
or
systemctl isolate graphical.target

[[email protected] ~]# systemctl cat graphical.target 
 /usr/lib/systemd/system/graphical.target
 SPDX-License-Identifier: LGPL-2.1+
 This file is part of systemd.
 systemd is free software; you can redistribute it and/or modify it
 under the terms of the GNU Lesser General Public License as published by
 the Free Software Foundation; either version 2.1 of the License, or  (at your option) any later version.
[Unit]
Description=Graphical Interface
Documentation=man:systemd.special(7)
Requires=multi-user.target
Wants=display-manager.service
Conflicts=rescue.service rescue.target
After=multi-user.target rescue.service rescue.target display-manager.service
AllowIsolate=yes    # We can only choose to set here as yes Switch Services 

Select the default interface at startup
[[email protected] ~]# systemctl get-default
graphical.target
[[email protected] ~]# systemctl set-default graphical.target or multi-user.target

Select login interface when starting
When starting, set the position in the kernel function , find linux Press end Space after ,systemd.unit=multi-user.target after ,ctrl+x perform .
1、reboot
2、 The up and down arrow cursor stays at the kernel selection position ,
3、 Press e Key edit , find linux Press... On the first line end key
4、 Editing systemd.unit=multi-user.target
5、ctrl+x perform

Reset root password
1、reboot
2、e
3、rd.break console=tty0
4、mount -o remount,rw /sysroot
5、chroot /sysroot
6、echo mima | passwd --stdin root
7、touch /.autorelabel
exit
exit

Check the log
By default, the system log is saved in /run/log/journal Directory , It will be cleared after restart

原网站

版权声明
本文为[Lyon-w]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/187/202207061413316589.html