1. How to boot from CD (in windows vmware)
-
1) When the vmware logo appears, press esc to enter the system device selection list and select cd-rom to boot from the CD to enter
-
2) Click the green start button at startup, choose to enter the firmware when the power is turned on, enter the BIOS, choose boot, shift+continue, you can choose cd-rom to enter, and continue to press f10 to enter (when the shortcut key is not available, directly press [esc] to enter the save Yes) (This method is permanent, booting from the CD every time)
Cancel: Click the green start button when starting, choose to enter the firmware when the power is turned on, enter the BIOS, choose boot, re-adjust, and choose hard disk as the entry method
-
3) (LINUX virtual machine)
Super user opens the virtual machine, clicks on the light bulb, adds CD-ROM, add hardware, device, selects cd-rom, type: sata, click boot options, selects sata cdrom, apply, and then starts from the CD at boot
Second, the disk boot
- mbr=Master Boot Record=0 Track 1 Sector 446
- Role: record the location of the grub2 boot file
3. When mbr data is lost, the system will stop starting because it cannot find the boot partition
Problem simulation method:
-
fdisk -l ##View device
-
/dev/sda ##There is mbr record on the device
-
dd if=/dev/zero of=/dev/vda bs=446 count=1
dd ##Interception command if=/dev/zero##Draw template of=/dev/vda ##Store data location bs=446 ## Data block size count=1 ##脱取块个数
##Intercept 446 bytes of data from wireless 0 bytes, put them into the /vda hard disk, and intercept one block in total
-
Cannot boot to disk after the interception is complete
The system boot program is damaged and the system cannot identify where to read data from
- Recovery method solution
1. Shut down
2. Boot from the CD
Select troubleshoting Select rescue system rescue mode
Rescue system rescue mode option meaning:
1) Continue to enter the rescue mode 2) Read only 3) Get the shell, do not mount 4) Exit the
conversion system from CD drive to the real disk
chroot /mnt/sysimage ##Switch to the real system
grub2-install /dev/sda ##Yes*The device where the partition is located,
exit
exit,
it means success if you see no error - Restart still boot from the CD, change the settings, boot from the disk, it can be started and the repair is successful
Fourth, the grub2 file is missing
- There was a problem in the file boot phase
- System boot file location: /boot/loader/entries/
- Manual boot experiment:
1) Boot file is missing: rm-fr * ##Delete boot file, boot file is missing
/ ##The name of the device where the root partition is located:
/boot ##The system device where the boot partition is located
reboot ##Cannot automatically boot
2) Enter grub ##The boot file is missing, unable to complete the automatic boot - 1.set root=“hd0,msdos1” ##Specify the location of the boot partition hd0 ##Specify the location of the boot partition as the first hawk msdos1 ##Guide the partition in the first boot partition of the first hard disk
- 2.linux16 /vmlinuz-4.18.0-193.el8.x86_64 ro root=/dev/sda3
Linux16 /vmlinuz-4.【tab】##kernel file
ro ##read-only mount/
dev/sda3 ##root partition Device
##Start the kernel read-only mount the root partition - 3.initrd16 /initramfs-4.18.0-193.el8.x86_64.img
##Start the mount image
boot (not really repaired, this operation is required every time)
3) Restore the boot file:
kernel-install add "kernel version ""Root Partition Mirror"
uname-r ##Kernel version
4) Restore the boot file and report that the file is missing
dnf whatprovides /bls.conf ##Find the bls file and
copy the cp /usr/lib/modules/ /bls.conf /boot/ # #Directly copy the kernel version
kernel-install add "kernel version" "root partition mirror"
boot file recovery is successful
reboot ##View
Five. Kernel loading
-
Kernel file: cd /boot/
-
Delete core files
-
Type CD boot, rescue mode
chroot /mnt/sysimages/ ##进入真实主机
mount /dev/cdrom /media ##挂载镜像
cd /media/BaseOS/Packages/
cp kernel-core-4* /mnt/ ##复制内核文件
cd /mnt
rpm2cpio kernel-core* -id ##解压缩
cd lib/
cd modules/
cd 4.【tab】/
cat /boot/loaders/entries/b* ##此文件中记录了内核文件名称
cp /mnt/lib/modules/4.18.0_193.el8.x86_64 /boot/vmlinuz-4.18.0_193.el8.x86_64
exit
exit ##两次后系统重启,调整硬盘从硬盘启动
Six, the system initialization image is lost
- Manual simulation operation
cd /boot
rm -rf initramfs-4.18.0-193.el8.x86_64.img ##Delete mirror - Select the disk boot mode to enter the system
- In the rescue mode, enter mkinitrd --help and follow the prompts to enter mkinitrd /boot/intramfs-4.18.0-193.el.x86_64.img ls /boot/ to save successfully
Seven, the system enters infinite restart mode
-
cd /etc/systemd/system
default.target##System startup level link
multi-user.target.wants ##Start script link of all system services
-
When setting the service to start or not start, the system will
create or delete a link in /etc/systemd/system/multi-user.target.wants/sshd.server
-
systemctl set-default reboot.target ## will enter infinite reboot mode
-
Recovery:
e ##Edit the
fourth line plus 5 ##Specify the startup level as 5
CTRL+x to enter the system
-
Manually set the startup level systemctl set-default graphical.target
Seven, the super user password is lost
- ro ----> rw +rd.break
rw #Change from read-only mount device to read-write device mount
rd.break #stop the system after loading the system kernel
- Enter the single-user mode, in the current mode, the root user is used by default to log in chroot /sysroot #Switch to the real device
- echo westos | passwd --stbin root ##Set password
touch /.autorelabel ##Kernel-level enhanced firewall reinitializes, if sdelinux is not reinitialized after changing the password, it will prevent the new password from taking effect
***This operation is only required when selinux is turned on