Restore windows MBR or ubuntu grub
Table of Contents
Restore windows MBR
- Boot your computer to the Windows 7 DVD
- Click the button for "Use recovery tools".
- select "Command Prompt".
- The command we will use, bootsect.exe, is in a folder (named boot)
on the DVD.
We need to know what drive letter has been assigned the DVD drive
to access the folder.
Type: diskpart Type: select disk 0 (zero) type: list volume
Assume the DVD is letter: G.
- use the DVD driver letter
Type: exit to close Diskpart Type: G: (use the letter of your DVD drive) Type: cd boot Type: dir
- To restore the "bootsector code":
bootsect /nt60 SYS /mbr Type: exit
or
bootsect /nt60 ALL
Bootsect 命令列選項
Restore Ubuntu1
- Boot with your ubuntu live CD and select try ubuntu
- Now say your linux file system exists in /dev/sda1 (use any
application like 'Disks', 'Gparted', 'fdisk' to find it) Mount all
the required folders to your linux file system.
$ sudo mount /dev/sda1 /mnt $ sudo mount --bind /proc /mnt/proc $ sudo mount --bind /sys /mnt/sys $ sudo mount --bind /dev /mnt/dev $ sudo mount --bind /usr /mnt/usr
- The key here is to change the working root to the one in your
installed linux
$ sudo chroot /mnt
If you get any error here like '/bin/bash not found.' , try:
$ sudo mount --bind /bin /mnt/bin $ sudo mount --bind /lib /mnt/lib
- update and install grub to replace the existing bootloader
$ grub-install /dev/sda $ update-grub or $ update-grub2 # If you get any error in the above step try this: $ grub-mkconfig -o /boot/grub/grub.cfg
- reboot