Grub. conf file loss and damage

Source: Internet
Author: User

Teach you a simple way to get it done quicklyGrub. confFile loss and damage

Lab environment:

GRUB is the default boot program used by most Linux systems. When "/boot/grub. if the conf configuration file is lost, the key configuration is incorrect, or the boot program in the MBR record is damaged, the "grub>" prompt may appear when the Linux host is started, how to fix the system

Tutorial principle:

Lab simulation:

1. The system/boot/grub. conf file is lost.

The following is a normal grub. conf configuration file. For more information, see.

Before the experiment, back up grub. conf to prevent errors. After the backup, delete the grub. conf file to simulate file loss.

After the system is restarted, go to grub> mode

Resume grub. conf. However, the following operations are temporarily written to the memory and will not be saved to the/boot/grub. conf file.

Operation Method:

If you do not know the location of the/boot partition containing the boot file such as the kernel, you can try to enter "root (hd0," and then press the Tab key, the code 0X83 is followed by a/root partition. (0X82 is a swap partition, so you don't have to try it)

After entering the information, press Enter. Then, enter the kernel/vm and press the Tab key. If the content is displayed, select the correct one. If not, continue to try again.

This article is from the UNIX/Linux Discovery blog, please be sure to keep this source http://dreamfire.blog.51cto.com/418026/1076824

After completing the kernel file, you also need to set the kernel loading permission to read-only ro and specify the location of the root partition device file through "root =. You can only try it one by one. Currently (hd0, 0) and (hd0, 2) are used. Remaining (hd0, 1) and (hd0, 3) [Remarks: (hd0, 1) =/dev/sda2 (hd0, 3) =/dev/sda4]

The following message is displayed, indicating that the selected root partition is incorrect. Turn off the power and continue.

After the power is turned off, start the system again. Because the content you just wrote is temporarily written into the memory, you need to write it again.

Enter the location of the temporary system image file used to start the kernel in the last line. You can also enter initrd/in and then complete the file using the Tab. You can use either of the following writing methods.


After the instance is restarted, the instance enters the system normally.

If you do not have the grub. conf file, you can only manually write the grub. conf file to prevent the next restart from entering the grub> mode.

The following are the default four lines, which must be clearly written. For more information, see the man grub. conf file.

This article is from the UNIX/Linux Discovery blog, please be sure to keep this source http://dreamfire.blog.51cto.com/418026/1076824

The fifth line begins to write the kernel File and uses some special commands to help you write the kernel File. In vim search mode, enter .! Command to append the result to the end of the document.

# Blkid/dev/sda4: displays the UUID information of the partition.

The configuration document for grub. conf has been written below.

Restart the system to see if it can enter the system

Access successful.

2. Damaged system/boot/grub. conf

Modify the grub. conf file, make the File corrupted, and restart the file. A black screen is displayed on the computer.

Restart and start. Press any key to enter GRUB mode. Press e to enter Edit

After an error is found and modified, press B to restart the instance.


The content changed in GRUB mode is only temporarily written to the memory and not written to the grub. conf configuration file. after entering the system, you must correct the configuration file. Then the system enters the normal mode.

This article is from the UNIX/Linux Discovery blog, please be sure to keep this source http://dreamfire.blog.51cto.com/418026/1076824

Conclusion: The entire experiment is actually very simple. You only need to remember several key words. The rest are done in the Tab completion mode. Of course, if you have a CD, you can also use the emergency mode to fix it.

This article is from the blog of "the Linux open source technology blog", please be sure to keep this source http://dreamfire.blog.51cto.com/418026/1076824


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.