2_ 8, Boot process and boot repair of Linux system

Enter system rescue mode with CD

Open the virtual machine graph and power down the virtual machine
Add an optical drive to the light bulb and select the mirrored file package

Adjust the optical drive priority, boot the optical drive first, and mount the problematic system on the optical drive
Enter this interface
Select Troubleshooting
Then select Rescue a Red Hat Enterprise Linux system
Press 1 OK and enter to give you a shell
Executing chroot /mnt/sysimage
df view into the damaged system
We followed up with troubleshooting and correction

1. Power on

2.bios initialization

Hardware detection
Initialize hardware clock

3. Disk boot

mbr = master boot record = 0 track 1 sector 446
Function: record the location of grub2 boot file
When mbr data is lost, the system will stop starting because the boot partition cannot be found
Problem simulation mode

System disk / dev/vda

#0-446 is empty. It's stupid. I don't know what to do

When mbr Data loss system

        dd if=/dev/zero of=/dev/vda bs=446 count=1                      ##Clear mbr data on system / dev/vda

        Recovery method:
                 Enter system rescue mode with CD
                 chroot  /mnt/sysimage
                 grub2-install  /dev/vda 
                 exit
                 exit   #Exit is important. No exit, no save                               ##Reinstall grub2 on the system hard disk

                        Update priority restart

After the problem!It's stuck

4.grub2 file boot

rhel8 software
/boot/grub2/grub.cfg
/boot/loader/entries/xxxxxxxxx.conf

Specify / boot location
Specifies the file name to be loaded when the system starts

 Question 1 10  rm -rf /boot/grub2/grub.cfg                      ##Delete / boot / Grub2 / grub If the boot file of CFG is lost, an error will be reported when restarting 
   11  cd /boot/grub2
   12  ls
   13  grub2-mkconfig  > /boot/grub2/grub.cfg           ##To repair, delete, repair and restart, you need to repair with the help of the optical drive. The same command
   14  uname -r   #Current kernel version number
   15  cd /boot/loader/entries/                         ##These two files are the option to select the version. If the file is lost, an error will be reported when restarting
   16  ls
 Question 2 17  rm -rf /boot/loader/entries/*
		Restart error
      #   When you encounter grub > Restart, you need to type the command to manually boot the file
        set root='hd0,msdos1'
        linux16 /vmlinuz-4.18.0-193.el8.x86_64 ro boot=/dev/vda3
        initrd16 /initramfs-4.18.0-193.el8.x86_64.img
        boot                            #start-up
        
18  kernel-install --help                            ##**Bold * * see the instructions for kernel install. Examples can be used directly
   19  kernel-install add 4.18.0-193.el8.x86_64 /lib/modules/4.18.0-193.el8.x86_64/vmlinuz      ##The restore boot option is deleted at that time and repaired at that time. You can manually boot into the graphical interface system or boot the CD-ROM drive to execute the same command

Query the current kernel version number #uname -r  4.18.0-193.el8.x86_64

Questions 1 and 2

Enter set... The boot will enter the system, and we will repair it

5. Kernel loading

Loading kernel function: / boot/vmlinuz-$(uname -r)
System initialization hardware device
Read only hanging on / device

   38  ll /boot/vmlinuz-4.18.0-193.el8.x86_64                   #file location
   39  rm -rf /boot/vmlinuz-4.18.0-193.el8.x86_64               #Deleting files and restarting will fail
                restart     The optical drive is not used to adjust the priority of the optical drive U disc
                1       enter
                        enter
                chroot  /mnt/sysimage

                cp /lib/modules/4.18.0-193.el8.x86_64/vmlinuz /boot/vmlinuz-4.18.0-193.el8.x86_64       #Copy backup files

                 cp /lib/modules/4.18.0-193.el8.x86_64/vmlinuz /boot/vmlinuz-$(uname -r)  #Copying backup files is faster

Kernel reload will be less/boot/grub2/grub.cfg Add files to

                        Update priority restart

                       

The problem is that the kernel version number is not filled completely. Fix it with the CD-ROM drive

6. System initialization image

File: / boot / initramfs-4.18.0-80 el8. x86_ 64.img
Load system clock
Load selinux
Load system host information
Load the disk hanging policy in the / etc/fstab file
Load disk quota
Initialize the system program and start the startup service
Open virtual console
Open graphics

file location  /boot/initramfs-4.18.0-193.el8.x86_64.img
   rm -rf /boot/initramfs-4.18.0-193.el8.x86_64.img             #delete
                               Restart the CD-ROM drive to start debugging and recovering files
   mkinitrd /boot/initramfs-$(uname -r).img $(uname -r)         #recovery
                                    Adjust priority restart

7. System startup level

Shutdown 0
Single user 1
No graphics network mode 2
No graphics network mode 3
No graphics network mode 4
With graphical network mode 5
Restart 6

[root@westoslinux ~]# cd /etc/systemd/system/multi-user.target.wants #Service link to start up

[root@westoslinux multi-user.target.wants]# ls -l
Problems arise:   systemctl set-default reboot.target

[root@westoslinux ~]# systemctl set-default reboot.target
Removed /etc/systemd/system/default.target.
Created symlink /etc/systemd/system/default.target → /usr/lib/systemd/system/reboot.target.     ##The system will always restart
[root@westoslinux ~]# ls -l /etc/systemd/system/default.target
lrwxrwxrwx 1 root root 37 Jul 27 14:01 /etc/systemd/system/default.target -> /usr/lib/systemd/system/reboot.target


Recovery:
Press in the boot selection interface<e>Enter boot file editing mode  #Don't press up or down, just press e
 Add boot level 5 at the end of kernel load selection
ctrl+x

systemctl set-default graphical.target                  ##Set graph model


Press enter to enter the lower interface, and then return to the upper interface later

8. Forget the root password

Press in the boot selection interface to enter the boot file editing mode
Delete to ro -- "RW rf break
ctrl+x

chroot /sysroot

passwd # the password or ehco westos | --stadio

touch /. Autorealable # must be established. If it is not established, there may not be a problem. If it is established, there must be no problem. If the command is correct

Keywords: Linux

Added by ludachris on Mon, 03 Jan 2022 04:42:54 +0200