If you are a Ubuntu or Windows system, after you reinstall windows, only the Windows Startup option exists in the MBR. Without the grub of ubuntu, you cannot access the Ubuntu system, however, you can solve the problem as follows:
Start with Ubuntu livecd (that is, the installation disc), enter the livecd system, and open the terminal
Enter sudo grub
Enter
Then enter:
Grub> Find/boot/GRUB/stage1
Note: Here is the number 1, not the lower-case English L. The previous "Grub>" is the prompt, and you do not need to enter it, the same below
The output is as follows:
(Hd0, 1)
Note: Versions later than ubuntu7.04 may fail to find the result, probably because/dev/SDA is used to represent the partition, grub uses hd0 to indicate incompatibility. So you need to find the Partition Number of/boot by yourself. Open another terminal and run the following command:
Sudo fdisk-l
List all your partition numbers.
1. If/boot is not partitioned separately: you only need to know the Partition Number of/partition. For example, if the/Partition Number is/dev/hda5, the result is (hd0, 4 ).
2. If/boot is partitioned separately: You need to know the Partition Number of the/boot partition. For example, if the/boot Partition Number is/dev/hda8, the result is (hd0, 7 ).
Then enter:
Grub> root (hd0, 1)
Note: The content in the brackets is the output content or the Partition Number of the/boot partition you have found. The numbers are 0 and 1.
Grub> setup (hd0)
Note: The content in the brackets is the content before the comma in the output.
If the result is similar to the following, grub is successfully installed into MBR. (The partition number may be different from yours .)
Checking if "/boot/GRUB/stage1" exists... no
Checking if "/GRUB/stage1" exists... yes
Checking if "/GRUB/stage2" exists... yes
Checking if "/GRUB/e2fs_stage1_5" exists... yes
Running "embed/GRUB/e2fs_stage1_5 (hd0)"... 17 sectors are embedded.
Succeeded
Running "Install/GRUB/stage1 (hd0) (hd0) 1 + 17 p (hd0, 8)/GRUB/stage2/GRUB/menu
. Lst "... succeeded
Done.
Enter quit to exit grub mode.
Finally, you can see the familiar GRUB boot interface after removing the disc and restarting it, and then you can enter your Ubuntu system.