MBR Backup and Restore
You can back up your MBR with a Linux Live CD such as a ubuntu 'desktop'
Live/Install CD or Knoppix or similar before you begin your Linux
installation.
You can use any media you like to copy the MBR backup file to and store it
on. In this example I used a USB disk. You may use a floppy disk or a CD-ROM
just as easily.
It isn't compulsory to name your MBR file 'OLDMBR.img', you might be better
off naming it something like 09june06_MBR.img instead. I find having the date
as part of the file-name can be quite handy at times when it comes time to
find my old files and i need to decide which one is the one I really want to
use and which ones to delete to the trash.
To USB disk:
1) Plug in USB disk cord or check to see that it is already plugged in.
2) Boot your Live CD. (Ubuntu Desktop in this example).
3) Choose Start or Install Ubuntu
4) After boot-up, USB disk icon(s) should appear on the desktop.
5) Open a terminal (Applications, Accessories, Terminal)
6) code:
sudo dd if=/dev/hda of=/home/ubuntu/OLDMBR.img bs=446 count=1
7) quote:
1+0 records in
1+0 records out
446 bytes copied, 4.3e-05 seconds, 10.4 MB/s
8) Open /home/ubuntu directory, locate file named OLDMBR.img
9) Open USB drive (FAT32 partition), drag and drop OLDMBR.img there somewhere.
10) Carry on with your Ubuntu Install.
Warning:
You can make a backup copy of your MBR with the entire 512 bytes, which
includes the entire MBR meaning the partition table and 55 aa signature.
That may be useful for some purposes, but be sure you destroy that copy of
your MBR if you decide to re-partition your disk later. If you accidentally
restore your MBR backup with an out of date partition table, it will not
match your new filesystems. It will cause your disk to be unreadable. Unless
it is very important data you will probably have to give it up and reformat
and repartition your disk and loose all your data and have to start again.
If you only want the to make a backup copy of the bootloader code, you only
need the first 466 bytes of the MBR, so it will not include the partition
table. That is much safer. That is what I do, and what is shown here.
11) Restore command:
code:
sudo dd if=/home/ubuntu/OLDMBR.img of=/dev/hda bs=446 count=1
Where: ubuntu is your username (it is the default username for the live CD),
and where: OLDMBR.img is the name of your MBR backup file.