1. How to boot from CD
In windows vm virtual machine:
After clicking to start the virtual machine, press the esc key when vmware appears on the interface, enter the boot device selection list, select CD-ROMDrive, that is, boot from the CD (because the startup process is very fast, so you need to concentrate )
If the hand speed is not fast enough, click the menu bar to select the option next to boot, select to enter the firmware when power is turned on, enter the boot interface, and select CD-ROMDrive (when selecting + means move up,-means move down, put this option The first one means to select it as the first startup sequence, press F10 to save and exit)
#But note that this method will make every time you enter to start from the CD, if you need to go back to start from the hard disk, you still need to enter and adjust. Just put the hard drive in the first one) In the
linux system:
enter virt-manager
2. When the system boot program is destroyed
fdisk -l #View device
#Here in /dev/sda represents the name of the device #dev/sda1, 2, 3 represent the partition, * represents the mbr record on the device
dd if=/dev/zero of=/dev/sda bs=446 count=1
#Interception command, if refers to the interception template, after of is the data location, after bs is the data size, and after count is the number of intercepted blocks
# Intercept a piece of data with a size of 446 bytes from the wireless 0 byte of the system and place it on the sda hard disk.
At this point, it will be found that the restart cannot be booted, because the system boot program is damaged and the system cannot identify where to start reading the data
Recovery:
1. At this time, you should shut down first, and then start from the CD.
2. First select Troubleshooting, enter to enter, and then select the second Rescue system, enter to enter the system rescue mode.
The four options you see at this time mean:
1) Enter the rescue mode
2) Read-only enter the rescue mode
3) Get the shell directly without mounting
4) Exit
4. Choose the first one
5. Enter
chroot /mnt/sysimage/ # to convert the system from the CD-ROM drive to the real disk.
6. Enter
grub2-install /dev/vda #install
mbr, where dev/vda is the name of the device with the boot partition, which can be based on your own The real situation of the host is determined.
# See no error reported to indicate success
7. Adjust the startup sequence and start from the hard disk. At this time, you can see the boot file indicating that the boot program has been repaired
Third, the boot file is missing
/boot/loader/entries/
#The directory where the sub-boot file is located, you can delete the sub-boot file xxxx.conf first
df
finds the system device where the root partition is located, and the system device where the boot partition is located.
At this time, grub appears after restarting,
indicating that the boot file is missing, and the boot information needs to be filled in
Repair:
1. Power on
2. Enter
set root='hd0,msdos1' #root specifies the boot device, hd0 specifies the location of the boot partition as the first hard disk
#msdos1 specifies the boot partition in the first partition of the first hard disk (These can be determined according to your own system) #The
overall is to specify the system boot partition
3. Enter (available tab) key to complete
linux16 /vmlinuz-4.18.0-193.el8.x86_64 ro root=/dev/vda3
#linux16 /vmlinuz -4.18.0-193.el8.x86_64 specifies the system kernel file, ro refers to read-only mount, root=/dev/vda3 refers to mount the root partition device
# The whole is the specified system boot kernel, read-only mount partition
4. Enter
initrd16 /initramfs-4.18.0-193.el8.x86_64.img #Load the
system initialization image
5. After the boot is complete, restart
boot
6. Uname -r #see the system kernel version
At this time, you can still see that there is still no boot file under /boot/loader/entries/
7. Use dnf whatprovides */bls.conf #Find
where the bls file is located
or copy
cp /usr/lib/modules/4.18.0 directly -193.el8.x86_64/bls.conf (tab complement) /boot/
8, kernel-install add 4.18.0-193.el8.x86_64 /boot/vmliunz-4.18.0-193.el8.x86_64 #Add boot File
9. It can be seen that the boot file is restored successfully, and the system is changed to the hard disk to start, there is no problem when restarting
/boot/grub2/grub.cfg #Total boot file
Accidentally delete the total boot file
Recovery: The
status after restart is the same as the status of deleting the sub-boot file, and manual boot is also required. After reboot,
execute grub2-mkconfig> /boot/grub2/grub.cfg in the system to restore
Fourth, delete the kernel file
vmlinuz- 4.18.0-193.el8.x86_64 # is the kernel file.
At this time, the system cannot boot due to lack of kernel files:
Repair:
1. Boot with the CD, enter the rescue mode, and then convert the system from the CD drive to the real disk
2. Type
mount /dev/cdrom /media/
#Mount the warehouse cd /media/BaseOS/Packages/
cp kernel-core-4.18.0-193.el8.x86_64.rpm /mnt/ #Copy the kernel installation package to /mnt/ Medium
3. cd /mnt/
rpm2cpio kernel-core-4.18.0-193.el8.x86_64.rpm | cpio -id #Unzip the kernel installation package
4. cd lib/
cd modules/
cd 4.18.0-193.el8.x86_64 /
ls #At this time, you can view the kernel file vmlinuz
6,
ls /boot/loader/entires/ #At
this time, you can view a .conf file (different for each computer)
cat /boot/loader/entires/xxxxxxxxxxx.conf
#View this file, you can see the name of the kernel file 7, cp /mnt/lib/modules/4.18.0-193.el8.x86_64/vmlinuz /boot/ the name of the kernel file
#Note the name of the kernel file filled in here The name, it should be exactly the same as the one you see above
8. Fill in the exit twice to exit, change it to the hard disk to start and restart, then the system can be started normally, you can check /boot/, there is already a kernel file
Five, delete the system initialization image
The system initialization image is under /boot/, and the name suffix is .img.
Repair:
1. You still need to enter the rescue mode and enter the real host.
2. You can directly ask for help
mkinitrd --help
3. Use the above to ask for help to directly generate
mkinitrd /boot/initrafms- 4.18.0-193.el8.x86_64.img 4.18.0-193.el8.x86_64 #Use the
command to directly generate
4. ls /boot/
can see the generated files
5. Change to the hard disk to boot, then it can be turned on normally
Six, system startup level
0 #Shutdown
1 #Single user
2, 3, 4 #Without graphics network mode
5 #With graphics network mode
6 #restart
/etc/systemd/system/
#Store system startup script
/etc/systemd/system/default.target #Script
link of system startup level
/etc/systemd/system/multi-user.target.wants #Start
script link of all services in the system
#When we set the service to start or not start, the system will be in /etc/systemd/system/multi-user.target Add or delete soft connection in .wants
#System startup service principle
Set the system to enter infinite restart mode after startup
systemctl set-default
reboot. After target reboot, it is found that the system has been restarting
repair:
1. Press e on the start page to enter the edit mode
2. You can see a total of five lines
in the editing interface. At the end of the fourth line, you can specify the startup level, enter 5 #change the
system startup level to five
Press ctrl and x
3. At this time, you can enter the system and execute
systemctl set-default grapical.terget
4. Restart at this time to see that the problem is solved
Seven, the super user forgets the password
Repair:
1. Shut down, still press e to enter the editing mode on the startup home page, in the fourth line, change ro to rw (from read-only mount device to read-write mount device)
rd.break #in the system After the kernel is loaded, terminate the system startup.
2. Press ctrl and x to enter the single-user mode (default root user login in this mode)
3. Execute chroot /sysroot/ to
enter the real system shell
4. Execute
echo westos | passwd --stdin root
#Change the password to westos
5, execute
touch /.autorelabel
# Let the kernel-level enhanced firewall (selinux) in the system, re-initialize, if selinux is not re-initialized after changing the password, it will prevent the new password from taking effect (note that this operation is only enabled when selinux is turned on When necessary)
6. Press exit twice to exit
7. At this time, you can enter the password you changed to enter the system