Results 1 to 10 of 41

Thread: HOW TO: Backup and clear MBR (uninstall GRUB)

Threaded View

  1. #1
    Join Date
    Aug 2005
    Huntsville, AL, USA

    HOW TO: Backup and clear MBR (uninstall GRUB)

    Try at your own risk.
    WARNING: The following commands can easily wipe out your entire hard drive if you are not very careful (make a typo). Please make sure you have everything backed up before proceeding.

    If you happen to be one of several people that somehow end up with two different icons in rEFIt that boot GRUB for Ubuntu, then this will show you how to remove one of them.

    The issue is that the Ubuntu installer by default installs GRUB to the MBR of the Hard Drive. This is OK for most PCs as this will make it easiest to dual-boot with Windows. On Macs, however, We usually use rEFIt or Hold the Option Key at startup to select which partition to boot from, and having GRUB in the MBR means that you have to use both rEFIt and GRUB to get to windows (for a triple-boot), so most guides tend to install GRUB to the Ubuntu partition and that is OK, but with the advent of a installer bug. The MBR becomes corrupted and many users unknowingly reinstall GRUB to the Ubuntu partition after it has already been installed to the MBR, and thus you get two instances of GRUB to boot.

    Before we begin, it is a good idea to make sure that refit is installed and working so that you can access its tools in the boot menu if needed.

    Now, the Good Stuff
    Before you do any of the following, make a backup of the entire MBR and save it to a thumbdrive or other external media so that you can restore it from a LiveCD if anything goes wrong.
    Do this by opening a terminal and running:
    sudo dd if=/dev/sda of=/home/username/mbr_backup bs=512 count=1
    replace "username" with your Ubuntu username. This will create the file "mbr_backup" in your home folder. Copy this somewhere safe where you can get to it if you are left with an unbootable machine!

    Now we will write over your current MBR with a new dummy version that has no real information in it, but will still allow you to boot your system. Download the "fakembr80.txt" file attached to this post (thanks pxwpxw) to your home folder.

    Now we will right the binary contents of this file to your MBR:
    sudo dd if=/home/username/fakembr80.txt of=/dev/sda bs=512 count=1
    You should get output that looks like:
    1+0 records in
    1+0 records out
    512 bytes transferred in 0.350948 secs (1459 bytes/sec)
    If you don't, try this procedure from the Ubuntu LiveCD (no need to backup again).

    If you have issues after clearing a portion of the MBR. This command shows you how to restore it from the backup file that you made:
    sudo dd if=/home/username/mbr_backup of=/dev/sda bs=512 count=1
    Anytime you write to your MBR, you should resync the partition tables. You can do this with rEFIt's "Partition Tool" in the main rEFIt boot menu or you can use the gptsync utility in Ubuntu:
    sudo apt-get install refit
    sudo gptsync
    Attached Files Attached Files
    Last edited by cyberdork33; December 16th, 2008 at 04:31 PM.

Tags for this Thread


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts