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,
"/boot" is a separate partition。 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:
Shell Code
- 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:
Shell Code
- 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:
Shell Code
- LS (hd0,msdos5)/grub
- LS (HD0,MSDOS6)/grub
- # if "/boot" does not have a separate partition, execute the following command (to be verified):
- LS (hd0,msdos5)/boot/grub
- LS (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:
Shell Code
- Set root= (HD0,MSDOS5)
- Set prefix= (HD0,MSDOS5)/grub
- Insmod Normal
- Normal
- # if "/boot" does not have a separate partition, execute the following command (to be verified):
- Set root= (HD0,MSDOS5)
- Set prefix= (HD0,MSDOS5)/boot/grub
- Insmod Normal
- Normal
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:
Shell Code
- sudo update-grub2
- sudo grub-install/dev/sda
Note:/DEV/SDA back
Don'tAdd a partition number, 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.
References:
http://blog.csdn.net/liangxanhai/article/details/7654478
http://my.oschina.net/junn/blog/135450
Win7 +v Ubuntu 16.04 Grub Rescue Mode Repair Grub