Ubuntu 16.04 Grub Rescue Mode Repair Grub

Source: Internet
Author: User

A few days ago to tidy up the partition of the computer, merge and delete some partitions, the result is that grub was destroyed, Ubuntu can not go in, after the launch directly into the rescure mode. Then the next toss, finally repaired, and now summed up.

First talk about my system environment, I am Win7 + ubuntu 16.04 dual system, first installed Win7, after installing Ubuntu. Using the way Windows Boots Ubuntu, the tool used is "EASYBCD 2.3 people version". Ubuntu partition, the "/boot" is partitioned separately . Detailed partitioning is as follows: "/boot" partition, "/" Partition, "Swap swap space".

   It is also necessary to note that when I install Ubuntu, "boot device Installation" selects the partition where "/boot" is located.

The following formally begins the detailed explanation of the workaround:

When entering Ubuntu, the screen is as follows:


First, using the LS command to find the Ubuntu partition, the result of executing the LS command is as follows:
Ls


You will see the partition on your hard disk, for example (HD0,MSDOS1), (HD0,MSDOS2), and so on, where 0 of hd0 represents the 1th hard drive (the hard disk number starts at 0), and 1 in MSDOS1 represents the 1th partition.

Then call the following command in turn until you find the partition where Ubuntu is located, the command is as follows: LS (hdx,msdosy)
where x represents the hard disk number and Y represents the partition number.
Take my machine as an example and look at each partition in turn:
LS (HD0,MSDOS1) ls (hd0,msdos2) LS (HD0,MSDOS3) # ...
The results of the implementation are as follows:






After execution, Discovery (HD0,MSDOS5) and (HD0,MSDOS6) are the Ubuntu partition. Then execute the following command to determine the partition where grub is located:
LS (hd0,msdos5)/grubls (HD0,MSDOS6)/grub# if "/boot" does not have a separate partition, you need to execute the following command (to be verified): LS (hd0,msdos5)/boot/grubls (HD0,MSDOS6)/ Boot/grub


After execution, found (HD0,MSDOS5), there are grub.cfg files. Description (HD0,MSDOS5) is the boot partition we are looking for.

After that, execute the following command, repair the grub boot, and enter the GRUB2 boot screen:
Set root= (HD0,MSDOS5) set prefix= (hd0,msdos5)/grubinsmod normalnormal# if "/boot" does not have a separate partition, you need to execute the following command (to be verified): Set root= (hd0, MSDOS5) Set prefix= (hd0,msdos5)/boot/grubinsmod Normalnormal


After executing the above command, you can see the Ubuntu grub2 boot screen, you can enter the normal Ubuntu.


But you will find that if you restart the computer, the problem remains. That's because we haven't implemented the GRUB Update command yet.

Re-execute the above command to enter Ubuntu. Then update grub at the terminal by executing the following command:
sudo update-grub2sudo GRUB-INSTALL/DEV/SDA
   Note: do not add the partition number after/DEV/SDA, such as Sda1,sda2.
The results of the implementation are as follows:




At this point, grub is finally repaired. However, if you restart the computer at this point, you will find that the boot has become Ubuntu boot Windows. And before the fix was Windows boot Ubuntu.

To solve this problem, I used the method of first entering Win7, and then using "EASYBCD" to repair the MBR to solve this problem.

The way to do this is simple: Start EasyBCD, select "BCD Deployment" on the left, and then select "Install Windows vista+ in MBR bootloader" on the right, which is the default first item, and finally click the "Write MBR" button.

In this case, the grub repair is done directly, and Ubuntu can be booted with Windows. ——————————————————————————————————in general, someone may modify the grub configuration file " /boot/grub/grub.cfg" directly, but use " Sudu vim/boot/grub/grub.cfg" Notice that this is the system automatically generated files, not recommended to edit directly, but should be " /etc/grub.d" and " /etc/default/grub" to modify. " /etc/grub.d" is the operating system menu directory, generally generated by the system, we do not need to modify, the next step is to modify the " /etc/default/grub" file. Use the sudo vim/etc/default/grubcommand to open the configuration file. The " grub_default=0" is the default startup item that is set. Grub Startup items are indexed by using a number in the Start menu, starting with a number of 0. Combined with the previous System boot menu, we can see that the WINDOWS8 startup item is in item 5th, so here we need to change to 4 (because the first item is starting from 0)after the modification is complete, you will need to execute " sudo update-grub" to regenerate the Grub boot configuration entry after saving the exit. (After modifying the grub configuration, be careful to use the Update-grub Update launcher, otherwise the modifications will not take effect.) )

Resources:
http://blog.csdn.net/liangxanhai/article/details/7654478
http://my.oschina.net/junn/blog/135450

Ubuntu 16.04 Grub Rescue Mode Repair Grub

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.