How do I restore my Master Boot Record?

Solution 1:

For this problem it's not actually an issue with the MBR. The AudoCAD forums you linked to had the following info:

It's not a change in MBR. grub bootloader put it's stage2 code into the 2048 sectors after the master boot record. this harddisk area is not used by operating systems and resides before the first partion. between byte 3585 (0x0E01) and byte 4096 (0x1000) autocad 2011 write some code in this area and destroy the grub boot stage2 code.

You're going to need to reinstall GRUB. According to the Super GRUB Disk Wiki, you can fix GRUB from within a Linux install if you use a LiveCD, or from the GRUB command prompt if you can get to stage 1, or by using said Super GRUB Disk to repair the bootloader. Depending on your version of GRUB, there are different choices for which recovery disk you should use; you can see them all here.

If you have access to stage 1 of the loader, use the following commands:

Find the partition where GRUB stage1 it is.

grub>find /boot/grub/stage1
grub>find /grub/stage1
Output from these commands might be:
  (hd0,1)
  (hd0,3)

Let's suppose that you want to restore GRUB from second partition on first hard disk, (hd0,1).

Just type these commands:

grub>root (hd0,1)

which prompts:

Filesystem type is ext2fs, partition type 0x83

and then:

grub>setup (hd0)

which prompts:

Checking if "/boot/grub/stage1" exists... yes
 Checking if "/boot/grub/stage2" exists... yes
 Checking if "/boot/grub/e2fs_stage1_5" exists...

yes Running "embed /boot/grub/e2fs_stage1_5 (hd0)"... 15 sectors are embedded. succeeded Running "install /boot/grub/stage1 d (hd0) (hd0)1+15 p (hd0,1)/boot/grub/stage 2 /boot/grub/menu.lst"... succeeded Done.

Now you can reboot your machine with the reboot command.

grub>reboot

Solution 2:

Before you do this, make sure you back-up your valuable data.

One potential solution to your problem is to use the Windows install media to try and repair the MBR. Put the DVD in the drive and it will guide you to an option to repair the install.

CODA

The other option is to grab a Super Grub .iso, burn it, and use that instead. It can repair broken MBRs.

Solution 3:

According to your link, AutoCad 2011 doesn't modify the MBR, but instead modifies the 2K bytes that follow it (which are usually unused, except by GRUB) therefore you need to reinstall Grub rather than restore the MBR. In any case, since it is an important question I will address what you actually asked - restoring MBR.

By Far the Easiest and quickest way to backup/restore the MBR is to use a linux live-cd and dd.

Simply boot into the livecd and perform:

dd if=/dev/sda of=MBR.bak bs=512 count=1

restore using the same command but with flipped of and if

dd if=MBR.bak of=/dev/sda

Make sure that /dev/sda refers to your primary hard drive, there is no need to specify blocksize and count since MBR.bak is 512 bytes already - NOTE THAT THIS WILL OVERWRITE YOUR PARTITION TABLE - avoid doing so by selecting bs=446 count=1 on the restore (last 66 bytes of the MBR is the table + signature)

To backup and restore the part that AutoCad overwrite replace count with 5 (to cover the first 512 and the 2k following it). Assuming of course that you did this prior to installing AutoCad. Although as Cody pointed out - any piece of software PARTICULARLY A TRIAL VERSION that modifies your hardisk on such a low level should be removed immediately