Page 1 of 5 123 ... LastLast
Results 1 to 10 of 41

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

  1. #1
    Join Date
    Aug 2005
    Location
    Huntsville, AL, USA
    Beans
    7,526
    Distro
    Ubuntu

    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.

    Background
    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:
    Code:
    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:
    Code:
    sudo dd if=/home/username/fakembr80.txt of=/dev/sda bs=512 count=1
    You should get output that looks like:
    Code:
    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:
    Code:
    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:
    Code:
    sudo apt-get install refit
    sudo gptsync
    Attached Files Attached Files
    Last edited by cyberdork33; December 16th, 2008 at 04:31 PM.

  2. #2
    Join Date
    Apr 2008
    Beans
    3,317
    Distro
    Kubuntu 9.10 Karmic Koala

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

    ssudo
    Is this a Mac command or a typo?

  3. #3
    Join Date
    Aug 2005
    Location
    Huntsville, AL, USA
    Beans
    7,526
    Distro
    Ubuntu

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

    Quote Originally Posted by meierfra. View Post
    Is this a Mac command or a typo?
    typo... and fixed. Thanks.

  4. #4
    Join Date
    Dec 2006
    Beans
    44

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

    Hi, your help is very appreciated, I think you're a great reference concerning the implementation of Ubuntu on Mac. In respect to this issue, maybe it's a good idea to specify that in the first post aren't described a series of steps to follow, rather they are alternatives the user can choose, except the first one which is mandatory. Greetings.

  5. #5
    Join Date
    Dec 2006
    Beans
    44

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

    And I should add that the first post works! at least in a Mac Pro 1 (four Xeon nuclei, Nvidia card and Leopard 10.5.3). Thanks once more for your help.

  6. #6
    Join Date
    Feb 2006
    Beans
    13

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

    a question for understanding: how can i resync with refit when the mbr is gone? i mean, can the system start refit after deleting the entire mbr? and what use does the backup copy have when i kill the entire mbr? how will you be able to access this backup then? i like the idea, but does it really work?
    Last edited by umbrAtrorum; July 4th, 2008 at 11:01 AM.

  7. #7
    Join Date
    Dec 2007
    Location
    Belgum - Antwerp
    Beans
    180
    Distro
    Ubuntu

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

    Hi guys. Hi Cyber

    I've a little question. I've been trying to install Debian. Wanted to try it cuz Ubuntus X was hanging or something like that. When i used up all my ram (1gig). Althou it was working ok with Fluxbox. I've been trying to test virtual network. XP and 2003 (DNS server). Also Debian is going to be secondary DNS. So i've decided to try Debian (the stable they say.
    So at one moment i've tryed to install elilo on mbr. And after that i've got two Tux icons in rEFIt but neither of them boots up. Also reinstalled grub via live cd on linux partition. One says booting "elilo.efi blah blah blah" and then nothing further. Another gives "grub>" prompt. Happily Mac still boots up.

    So, to the case. I guess my next thing to do is to try method explained above. But i have a question. If i
    sudo dd if=/dev/zero of=/dev/sda bs=446 count=1
    how does my system going to boot then?
    Waiting for your response.

    Have a nice day!
    Nikolai
    The truth will set you free!

  8. #8
    Join Date
    Jun 2007
    Location
    SP, Brazil
    Beans
    Hidden!

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

    Same situation here.

  9. #9
    Join Date
    Aug 2005
    Location
    Huntsville, AL, USA
    Beans
    7,526
    Distro
    Ubuntu

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

    Quote Originally Posted by Nikolai D. View Post
    So at one moment i've tryed to install elilo on mbr. And after that i've got two Tux icons in rEFIt but neither of them boots up. Also reinstalled grub via live cd on linux partition. One says booting "elilo.efi blah blah blah" and then nothing further. Another gives "grub>" prompt. Happily Mac still boots up.
    I don't know anything about elilo... as far as I know it is still quite a bit buggy to boot via EFI.

    Quote Originally Posted by Nikolai D. View Post
    So, to the case. I guess my next thing to do is to try method explained above. But i have a question. If i
    sudo dd if=/dev/zero of=/dev/sda bs=446 count=1
    how does my system going to boot then?
    Waiting for your response.
    That will clear the bootcode in the MBR. That means that if you do not have grub installed elsewhere (on a partition) then you will not be able to boot into Ubuntu (or whatever distro). But that is not to say that you cannot boot a livecd and reinstall GRUB how you like.

    the "elilo.efi" is a result of your elilo install. I do not know anything about it, so I cannot really help you there.

    On the second, since you are getting a grub prompt, then the stage1 installed appropriately (to wherever you installed it) but it likely cannot find the stage2 file and / or the menu.lst and such. This is likely a result of setting the wrong root partition during your manual install of grub.

    so what I think you need to do is try again on installing GRUB manually to the Linux boot partition. On the liveCD, run 'sudo grub'. Then:
    Code:
    grub> find /boot/grub/stage2
    You should get a result like (hdX,Y) where X and Y are numbers.
    Then do:
    Code:
    grub> root (hdX,Y)
    grub> setup (hdX,Y)
    That will install grub stage1 to the Linux partition, and point it to the linux partition to look for configuration.

  10. #10
    Join Date
    Dec 2007
    Location
    Belgum - Antwerp
    Beans
    180
    Distro
    Ubuntu

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

    Hi guys.

    Oke. Heres what i did.

    LiveCD
    sudo grub
    grub> find /boot/grub/stage2
    (hd0,2)
    grub> root (hd0,2)
    grub> setup (hd0,2)

    Rebooted in that linux partition pushing Alt key (i like it wothout rEFIt). And i get same "grub>" prompt. So i go for booting my MacOS from rEFIt. And i see there onemore partitionp appearred. Now there are three Tuxes Niether of them boots up (i guess ill go boot it up onemoretime and try all of the Tuxes, tobe sure).

    And next ill try now to DD ZERO my boot loader (only boot loader not whole MBR).
    Thats it.
    ill post after, how its going on.

    Thank you for help onemore time.
    Have a nice day.
    And see ya agane.
    Nikolai
    The truth will set you free!

Page 1 of 5 123 ... LastLast

Tags for this Thread

Bookmarks

Posting Permissions

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