Introduction GRUB menu
For the Linux
operating system, the GRUB
( GRand Unified Bootloader
unified boot loader) is the most widely used multi-system boot program. After the transfer system control to GRUB, the boot menu will be displayed to the user to select and load depending on the option (or default value) Linux
kernel file, then the system control to the kernel. It should be noted that the CentOS 7
use of the GRUB2
boot loader.
GRUB menu recovery method
GRUB
Most Linux
operating systems use the default boot program, you can choose to enter a different operating system (if any) by way of the boot menu. When the configuration file /boot/grub2/grub.cfg
is missing, or the key to a configuration error, or a boot loader in the MBR gets damaged, it may only start after the Linux host “grub>”
prompt, unable to complete the boot process further. Here we have to practice to simulate the GRUB menu by damage and repair process. (Practice complete virtual machine in VMware 15)
1, open the VMware 15
virtual machine, start Linux
the system, open a terminal, the command to delete GRUB
the menu configuration file ( /boot/grub2/grub.cfg
), analog GRUB
menu damaged, restart the Linux
system to see if the system can start.
[root@localhost ~]# rm -rf /boot/grub2/grub.cfg //删除grub配置文件,模拟grub菜单损坏
[root@localhost ~]# init 6 //重启Linux系统
2, let's fix GRUB
menu, the system to boot, repair GRUB menu can be entered manually grub
configure the File menu to complete the repair, grub
many menu configuration file, manual input is very convenient, generally use this method we will not go, Another way is to use the CentOS 7
image files (CD-ROM) to boot into rescue mode, enter the command bash environment, reload the configuration file, the grub
menu configuration file recovery.
- First, the image file into CentOS 7 VMware 15 virtual drive, the drive connection and, then, restart the system, press the ESC key to restart the reading of the interface into boot mode select boot from the CD into the installation guide interface.
- Installed in the boot image file selection screen
Troubleshooting
into the emergency mode, and then selectingRescue a CentOS system
to enter the command mode of the mirror, this time the system will automatically load, loading is completed after the selection input1
selectingContinue
loaded into the system base image mode, the Enter key to entershell
the environment.
- In the
shell
input mode commandchroot /mnt/sysimage/
to load system image, this time will enter the bash environment,bash
enter the command environmentgrub2-install /dev/sda/
to rebuildsda
the disk, and then continue to enter the commandgrub2-mkconfig -o /boot/grub2/grub.cfg
to rebuildgrub2
the configuration file, enter theexit
command to exitbash
the environment.
- This time we enter the command reboot reboot the system to see whether the subject can boot normally.
After forget the root password reset method
In daily production environment, it is possible to forget root
the user password, or the transfer of work in the future and transfer root
generated user passwords and other circumstances, this time we need to reset root
your password.
In CentOS 7
the password reset method is relatively simple, we need to use the same CentOS 7
image file, and repair of the above grub
menu is similar to the way into emergency mode through the mirror installation guide, enter the command, the command mode input selection into the shell environment, the above has been explained how into the shell
environment here is not in the repeat.
1, the shell
input mode command to chroot /mnt/sysimage/
load the system image, this time will enter the bash
environment, bash
directly enter the command environment passwd root
command, and then enter the new password to change the root
password.
2, enter the command exit
to exit the bash
environment, and then enter the command reboot
to restart the system, and then select root
a user, enter the new password to see if it can enter the root
user interface.
Through the above practice successfully CentOS 7
repair the image file grub
menu and root
reset user passwords. I hope to be helpful! ! !
to add on
CentOS 7
System image file: https://pan.baidu.com/s/189yvb_WAYi8vrIhhxBwoXA extraction code:6crs