Overview of the system boot process:
PowerUp--bios Initialize--GRUB2 disk boot phase--grub2 file Boot phase--Specify boot partition location-boot kernel, read-only/Mount device-start init program into initialization phase-start SYSTEMD initialization process-take/etc/ systemd/file-Start program-Start the landing environment.
System Startup process:
I. Power-ON
BIOS (in read-only storage on the motherboard, basic input or output system)
Role: Hardware detection, activating hardware
Two. Grub System boot (grub boot divided into two stages)
Stage 1 MBR (Master boot Record)
Master Boot Record 0 tracks on hard disk, one sector, 446 bytes
DD If=/dev/zero Of=/dev/vda bs=446 count=1 can empty MBR
Go to rescue mode, perform chroot/mnt/sysimage switch to real/environment,
and execute Grub2-install/dev/vda
experiment: MBR master boot partition damaged after repair method .
(1) Before the experiment, we must close SELinux.
Vim/etc/sysconfig/selinux
650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M02/9D/FE/wKioL1mJrGugtNYHAAC-OLrA88A741.png "title=" Screenshot from 2017-08-06 18-31-29.png "alt=" Wkiol1mjrgugtnyhaac-olra88a741.png "/>
Change it to disable, and then restart the system
(2) Destroy MBR master boot partition
DD If=/dev/zero Of=/dev/vda bs=446 count=1
650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M02/9D/FE/wKiom1mJra7DmcVlAAALVHIOjL8546.png "title=" Screenshot from 2017-08-08 20-09-36.png "alt=" Wkiom1mjra7dmcvlaaalvhiojl8546.png "/>
Failed to start after rebooting system
650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M01/9D/FE/wKiom1mJrheA0MggAAALAoh3T-Y339.png "title=" Screenshot from 2017-08-08 20-10-05.png "alt=" Wkiom1mjrhea0mggaaalaoh3t-y339.png "/>
(3) Set the optical drive to boot into rescue mode
650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M02/9D/FE/wKiom1mJrlvARwS_AACG_7pv7cY418.png "style=" float : none; "title=" screenshot from 2017-08-08 20-11-09.png "alt=" Wkiom1mjrlvarws_aacg_7pv7cy418.png "/>
650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M02/9D/FE/wKioL1mJrlzyB9D1AAATWQRIDm0038.png "style=" float : none; "title=" screenshot from 2017-08-08 20-11-37.png "alt=" Wkiol1mjrlzyb9d1aaatwqridm0038.png "/>
650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M02/9D/FE/wKioL1mJrlzCLD6RAAAYqHZtcIY699.png "style=" float : none; "title=" screenshot from 2017-08-08 20-11-58.png "alt=" Wkiol1mjrlzcld6raaayqhztciy699.png "/>
650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M00/9D/FE/wKiom1mJrlyD5tOtAAAeKxVY1aw410.png "style=" float : none; "title=" screenshot from 2017-08-08 20-12-35.png "alt=" Wkiom1mjrlyd5totaaaekxvy1aw410.png "/>
(4) If you enter 1, you will get a shell, then execute the DF command to view the root partition of your system, and then execute
chroot/mnt/sysimage/
Convert the root partition, then switch to the real root environment, and then execute
Grub2-install/dev/vda
Re-restore the MBR partition, and then exit two exits, after shutting down the virtual machine will start back to the hard drive boot, boot up and normal start.
650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M02/9D/FE/wKioL1mJr_3CDakjAABCvCTfKJA873.png "style=" float : none; "title=" screenshot from 2017-08-08 20-15-16.png "alt=" Wkiol1mjr_3cdakjaabcvctfkja873.png "/>
650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M00/9D/FE/wKiom1mJr_2hSoEEAABFqke7HXY232.png "style=" float : none; "title=" screenshot from 2017-08-08 20-16-20.png "alt=" Wkiom1mjr_2hsoeeaabfqke7hxy232.png "/>
2. Phase 2 Grub File boot phase
Locate the/boot partition
Read/boot/grub2/grub.cfg
File lost, Grub2-mkconfig >/boot/grub2/grub.cfg
Experiment: How to fix grub file after corruption
(1) Experiment before executing the DF command to view your own root and boot partitions
650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M00/9D/FF/wKiom1mJtdrxxULnAAAXUaGfOYE985.png "title=" Screenshot from 2017-08-08 20-39-30.png "alt=" Wkiom1mjtdrxxulnaaaxuagfoye985.png "/>
(2) Delete grub file boot
Rm-fr/boot/grub2/grub.cfg
(3) Restart Discovery failed to start
650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M02/9D/FF/wKiom1mJtgDQT_AnAAAdN3-ZHxU788.png "title=" Screenshot from 2017-08-08 20-42-32.png "alt=" Wkiom1mjtgdqt_anaaadn3-zhxu788.png "/>
(4) Manually enter the boot file
Where the set root= ' hd0,msdos1 ' boot partition is located
linux16/vmlinuz-3.10.0-327.el7.x86_64 ro Root=/dev/vda3 root partition is located
Initrd16/initramfs-3.10.0-327.el7.x86_64.img execution
Boot boot
650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M01/9D/FF/wKiom1mJtiOT-ONZAAAxiSGKo4Q862.png "title=" Screenshot from 2017-08-08 20-56-01.png "alt=" Wkiom1mjtiot-onzaaaxisgko4q862.png "/>
At this point can be turned on, but this is manual boot, for temporary effect, boot should be restored/boot/grub2/grub.cfg file
Grub2-mkconfig >/boot/grub2/grub.cfg
650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M01/9D/FF/wKioL1mJtjfCBUA4AAAxiSGKo4Q949.png "title=" Screenshot from 2017-08-08 20-56-01.png "alt=" Wkiol1mjtjfcbua4aaaxisgko4q949.png "/>
After recovering the file, the system recovers successfully.
Three. Boot kernel, read-only mount/device
Testing equipment
Initialize the device driver
Enter the system initialization phase
Kernel is missing, the new kernel installation package can be resolved
RPM-IVH kernel-xxxxx.rpm--force
Experiment: Fix kernel file after missing
(1) First check which files are needed for startup
Ls/boot viewing the file for the boot partition
(2) Reboot the kernel file after deletion
rm-fr/boot/vmlinuz-3.10.0-327.el7.x86_64 Deleting kernel files
Reboot
650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M02/9E/01/wKiom1mJy_HTUZ4PAAAHUQlwb8w763.png "title=" Screenshot from 2017-08-08 21-12-49.png "alt=" Wkiom1mjy_htuz4paaahuqlwb8w763.png "/>
(3) Restart after the discovery of a normal boot, the lack of kernel files
650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M01/9E/01/wKiom1mJzAvTU6pqAAAKDq5Lf_o504.png "title=" Screenshot from 2017-08-08 21-13-10.png "alt=" Wkiom1mjzavtu6pqaaakdq5lf_o504.png "/>
(4) Set the optical drive to boot, enter rescue mode, execute the DF command can see the root of the real system is/mnt/sysimage, and here the root is the ISO image root.
(5) Decompose kernel packages in ISO image and copy kernel files to/mnt/sysimage/boot/
rpm2cpio/run/install/repo/packages/kernel-3.10.0-327.el7.x86_64.rpm |cpio-id
cp/boot/vmlinuz-3.10.0-327.el7.x86_64/mnt/sysimage/boot/
650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M01/9E/00/wKioL1mJzDfSbJoyAAAhjSgibMU845.png "style=" float : none; "title=" screenshot from 2017-08-08 21-15-49.png "alt=" Wkiol1mjzdfsbjoyaaahjsgibmu845.png "/>
650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M02/9E/01/wKiom1mJzDiycAyaAAA5dNSrsxA003.png "style=" float : none; "title=" screenshot from 2017-08-08 22-26-08.png "alt=" Wkiom1mjzdiycayaaaa5dnsrsxa003.png "/>
(6) Exit and set the hard drive to start, reboot. Repair Complete Entry System
650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M02/9E/01/wKiom1mJzEuh__21AAAWzAK1Apc130.png "title=" Screenshot from 2017-08-08 22-28-06.png "alt=" Wkiom1mjzeuh__21aaawzak1apc130.png "/>
Four. System initialization phase
System initialization phase Load INITRD mirror
Open initialization Process Systemd
Start SELinux
Load Kernel parameters
Initialize the system clock, keyboard, host name
Re-read/write mount/device
Activating RAID,LVM
Activate quotas
Start all services in the multi-user.target.wants
Turn on the Virtual Console
Start graphics
initramfs-' Uname-r '. IMG Lost with: mkinitrd initramfs-' uname-r '. img ' uname-r ' recovery
Experiment: System initialization loading INITRD image corruption after recovery
(1) Delete initrd image file initramfs-3.10.0-327.x86_64.img
Rm-fr/boot/initramfs-3.10.0-327.x86_64.img deleting initrd image files
650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M00/9E/02/wKiom1mJ0wmDYme-AAAHPW6Y1fU161.png "title=" Screenshot from 2017-08-08 22-56-56.png "alt=" Wkiom1mj0wmdyme-aaahpw6y1fu161.png "/>
(2) Restart found unable to enter system
650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M01/9E/01/wKioL1mJ0yOTbarWAAAG_HkjO9w574.png "title=" Screenshot from 2017-08-08 22-57-50.png "alt=" Wkiol1mj0yotbarwaaag_hkjo9w574.png "/>
(3) Set the optical drive to boot, enter rescue mode, perform chroot/mnt/sysimage switch to the real root environment
650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M02/9E/02/wKiom1mJ0z2BuMPOAAAZ8yDAfHk983.png "style=" float : none; "title=" screenshot from 2017-08-08 23-00-41.png "alt=" Wkiom1mj0z2bumpoaaaz8ydafhk983.png "/>
650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M00/9E/01/wKioL1mJ0z2hyatUAAApD_1vK78197.png "style=" float : none; "title=" screenshot from 2017-08-08 23-03-05.png "alt=" Wkiol1mj0z2hyatuaaapd_1vk78197.png "/>
(4) mkinitrd/boot/initramfs-$ (UNAME-R). IMG $ (UNAME-R)
(5) ls/boot/Check whether the file is restored, exit two times after setting up the hard drive, the system is back to normal
650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M00/9E/01/wKioL1mJ016Cnh2PAAAIOHDhMhs934.png "title=" Screenshot from 2017-08-08 23-04-05.png "alt=" Wkiol1mj016cnh2paaaiohdhmhs934.png "/>
This article is from the "13122425" blog, please be sure to keep this source http://13132425.blog.51cto.com/13122425/1954643
Linux Cloud Automation Operations Basics 22 (System Recovery)