Guidance process and service control and three error analysis

1. Overview of the boot process

Insert picture description here

2. System initialization process

1. The init process
(1) The /sbin/init program is loaded and run by the Linux kernel;
(2) The init process is the first process in the system;
(3) The PID (process tag) number of the init process is always 1

2. Systemd
(1) Systemd is a kind of init software of the Linux operating system;
(2) CentOS7 adopts a brand-new Systemd startup method to replace the traditional SysVinit;
(3) The first init process running in CentOS7 is /lib/ system/system

Three, Systemd unit type

Insert picture description here

Fourth, the Systemd target corresponding to the run level

Insert picture description here

5. Repair MBR sector failure

1. Reasons for failure:
(1) Destruction caused by viruses, Trojan horses, etc.;
(2) Misoperations such as incorrect partition operation, disk read and write, etc.

2. Fault phenomenon:
(1) The boot program cannot be found, and the startup is interrupted;
(2) The operating system cannot be loaded, and the screen goes black after booting

3. Solutions:
(1) Make a backup file in advance;
(2) Boot into the emergency mode with the installation CD;
(3) Restore from the backup file

Operation steps to simulate MBR sector experiment

Add a hard disk to experiment.
Enter the system and check the disk
fdisk -l ##See if there is sdb
mkfs.ext4 /dev/sdb ##Format sdb
mount mount /dev/sdb /opt

1. Backup MBR sector data
dd if=/dev/sda of=/opt/mbr.bak bs=512 count=1

2. Simulate MBR sector failure
dd if=/dev/zero of=/dev/sda bs=512 count=1

Restart to see if there is a problem.
Boot from the CD, enter the emergency mode, and prompt the operation
. Recover the MBR sector from the backup file. The
steps are as follows:
1. Load the CD and select troubleshooting on the CD boot interface.
2. Enter the troubleshooting menu and select Rescue a centos system
3. To enter the boot, you can press Enter, or wait
Press "1", then press Enter to enter sh-4.2#
4. Mount sdb in emergency mode
mkdir /sdd
mount /dev/sdb /sdd
cd /sdd ##Query the backup Whether the file exists
5. dd if=/sdd/mbr.bak of=/dev/sda count=1 bs=512
6. Reboot and enter the system to test whether it is normal

Fix GRUB boot failure

1. Reasons for failure:
(1) The GRUB boot program in MBR is damaged;
(2) The grub.conf file is missing, and the boot configuration is incorrect

2. Trouble phenomenon:
(1) The system boot stalls and the "grub>" prompt is displayed;

3. Solution:
(1) Try to manually enter the boot command;
(2) Enter the emergency mode, rewrite or restore grub.conf from the backup;
(3) Rebuild the grub program into the MBR sector

Grub repair:
cd /boot/grub2 ##Enter grub
rm –rf grub.cfg ##Delete grub.cfg, simulate failure
init 6 ##Restart

There is a failure, as follows:
"grub>"

The repair is as follows:
1. Boot the emergency mode, load the system image
chroot /mnt/sysimage/

2. Re-establish and load the sda ​​partition
grub2 --install /dev/sda

3. Rebuild the grub menu configuration file
grub2 --mkconofig --o /boot/grub2/grub.cfg

4, exit bash environment
exit

5. Restart
reboot

Forgot root password

sh-4.2# chroot /mnt/sysimage ##Load system image
bash-4.2# passwd root
new:
retry:
exit bash environment: exit
restart: reboot

Guess you like

Origin blog.csdn.net/yuiLan0/article/details/108440354