GRUB and Linux system repair (version 2)
GRUB configuration Parsing
The configuration file is saved in/boot/grub. conf [/boot partition should be separated]
The soft link is saved in/etc/grub. conf.
1. grub. conf file Analysis
Default # Start the system by default
Timeout # default wait time, in seconds
Splashimage # defines the GRUB startup background image
# (Hd0, 0) # specify the partition where/boot is located-> the first hard disk, the first partition
Hiddenmenu # Hide a menu
Title CentOS (2.6.32-358. el6.i686) # Name of the menu item, whose content can be modified
Root (hd0, 0) # defines the root device of GRUB, that is, the partition where the kernel is located, that is, the/boot Directory, which represents the partition where all startup devices are located.
Kernel/vmlinuz-2.6.32-358.el6.i686 ro root = UU... # define the location of the kernel, note: Here/does not represent the root partition, but indicates the/boot directory
Initrd/initramfs-2.6.32-358.el6.i686.img # load the image file. For more information, see <CentOS 6. X Startup Process> This blog
Single-user mode Application
Case: the root password is missing, and the system suffers an abnormal power failure.
1. When the system starts, Press Esc to enter the GRUB menu
GRUB function key:
E: edit the current menu item // edit
C: Enter the command line mode of GRUB // command
B: Start the current menu item // boot
D: delete the current row // delete
Esc: Return to the GRUB Startup menu interface to cancel any modifications made to the current item.
2. Click a line in the kernel, press e to edit the startup level, and add the corresponding startup and running level at the end of the line, for example, 1 or s. Press enter and press B to enter the single-user mode.
Passwd root # change the root password
# Other settings can be made, such as file system repair after power failure.
Set GRUB Password
Step 1: Set and copy the ciphertext
Method 1. Use the grub-md5-crypt command that comes with GRUB
Method 2. Use the md5crypt command on the GRUB interactive command line interface
Step 2: modify the configuration file/boot/grub. conf
Add: password -- md5 $1 $ EszU60 $ Mc2BwxeWUH/8q3iqbRknz0 # -- md5 indicates that it is encrypted with md5. [It is best to write the password in global mode, for example]
After restart
OK, all done!
GRUB repair
Case: After the instance is started, go to the grub interface, but there is no menu. There is only one grub> prompt left.
Solution:
Grub> cat/grub. conf # An error is found.
Manual guide to Linux:
Grub> root (hd0, 0)
Grub> kernel/vmlinuz-2.6.18-14 ro root = LABEL =/3 # if an error occurs at this time, pay attention to the prompt
Grub> initrd/initrd-2.6.18-14.img
Grub> boot # Use the Tab command to complete
For more details, please continue to read the highlights on the next page: