Fix Grub2 after Windows and Ubuntu systems are reinstalled with WIN7

Source: Internet
Author: User
Windows and Ubuntu systems have been used all the time (this is probably the case for many linuxer systems ). Some time ago, Windows 7 was reinstalled, and then started without selecting the system and directly entering Windows. The reason is that the Windows boot program overwrites the MBR and does not use grub boot at startup. As for the solution, the following is a summary. There are many specific solutions to this problem, but the overall thinking is actually two steps: Step 1, do everything possible to enter linux; Step 2, in the linux environment

Windows and Ubuntu systems have been used all the time (this is probably the case for many linuxer systems ). Some time ago, Windows 7 was reinstalled, and then started without selecting the system and directly entering Windows. The reason is that the Windows boot program overwrites the MBR and does not use grub boot at startup. As for the solution, the following is a summary.

There are many specific solutions to this problem, but the general idea is actually two steps: Step 1, try every means to enter linux; Step 2, re-Override MBR with grub in linux.

The first step is to use grub4dos.

First download grub4dos, which can be found at any time. It is estimated that many people have used grub4dos when installing linux.

Copy grub.exe and grldr to the root directory of drive C after decompression. Note that there is a grldr in the C drive of win7, which is a hidden system file. You must back up the data during replication and use it later. The online solution also needs to copy menu. lst. In fact, this is not necessary and can solve the problem without it.

Then restart the system. Grub4dos's grldris used to boot grub.exe. During boot, it will automatically search for menu. lst. If it cannot be found, it will enter the command line mode. Then start linux in the command line of grub4dos. This is easier.

Grub> root (hd0, x) (x indicates the number of the/boot partition)

Grub> kernel/vmlinuz-x.xx.xx-xx-generic root =/dev/sdaY (xx indicates the kernel version, you can use the ls command to see what the file name under/boot is; at the end, Y is the/Partition Number. Note that when the (hdo, x) representation is used, the number starts from 0. When/dev/sdaY is used, the number starts from 1)

Grub> initrd/initrd-x.xx.xx-xx-generic (xx is the same as in the previous command, both of which are kernel versions)

Grub> boot

At this time, you should be able to enter linux.

Step 2 overwrite MBR with grub

This step is simpler. First Update grub so that it can recognize win7

Sudo update-grub

After the update, enter the command to overwrite the MBR. The specific commands vary with grub versions. I use ubuntu10.10 and grub2. It only requires one sentence.

Sudo grub-install/dev/sda

If you are prompted that the installation is successful, you are done. Restart the computer and you will see the familiar grub selection interface.

For grub1 (for versions earlier than ubuntu9.10), you must first Mount/to/mnt. If there is a/boot partition, Mount/boot to/mnt/boot. Then execute the command

Sudo grub-install -- root-directory =/mnt/dev/sda

I have not actually tried the grub1 method, but it is only listed here.

Related Article

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.