Restore windows MBR or ubuntu grub

Table of Contents

Restore windows MBR

  1. Boot your computer to the Windows 7 DVD
  2. Click the button for "Use recovery tools".
  3. select "Command Prompt".
  4. 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.

  5. use the DVD driver letter
    Type: exit
    to close Diskpart
    Type: G: (use the letter of your DVD drive)
    Type: cd boot
    Type: dir
    
  6. To restore the "bootsector code":
    bootsect /nt60 SYS /mbr
    Type: exit
    

    or

    bootsect /nt60 ALL
    

Bootsect 命令列選項

Restore Ubuntu1

  1. Boot with your ubuntu live CD and select try ubuntu
  2. 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
    
  3. 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
    
  4. 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
    
  5. reboot

Footnotes:

Author: Shi Shougang

Created: 2015-03-15 Sun 18:18

Emacs 24.3.1 (Org mode 8.2.10)

Validate