LKBEN11001: Howto backup the master boot record and restore or delete it afterwards


Symptom

You need delete the master boot record or just want to backup and restore it

Cause

You might need this when your computer does not boot properly

Solution

To backup of the master boot record can be done with dd. This tool can be used for all tree operations. (delete, backup and restore) An easy way to do this is to use a life CD from Knoppix, ubuntu or kubuntu and open a shell. (You can also use Debian installation CD / DVD and go the the second console window)

To backup you can use:

dd if=/dev/hda of=/home/lubby/mbr_backup bs=512 count=1

Please note that in your case the /dev/hda could be another device like hdb, hdc, sda, sdb, ...

This will restore the MBR:

dd if=/home/lubby/mbr_backup of=/dev/hda bs=512 count=1

If you want to delete your master boot record you can use:

dd if=/dev/zero of=/dev/hda bs=512 count=1

If you want to kill the MBR but leave the partition table intact then you need to change 512 to 446.

dd if=/dev/zero of=/dev/hda bs=446 count=1

in this case the partition table is kept. It is in the last 66 bytes of the MBR.

Disclaimer:

The information provided in this document is intended for your information only. Lubby makes no claims to the validity of this information. Use of this information is at own risk!

About the Author

Author: Wim Peeters - Keskon GmbH & Co. KG

Wim Peeters is electronics engineer with an additional master in IT and over 30 years of experience, including time spent in support, development, consulting, training and database administration. Wim has worked with SQL Server since version 6.5. He has developed in C/C++, Java and C# on Windows and Linux. He writes knowledge base articles to solve IT problems and publishes them on the Lubby Knowledge Platform.