[SOLVED] Backing up MBR: Should I use 512 or 1024 or higher
Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
And on the contrary, except when testing the effect(s) of deliberately introducing boot level virii, I have never seen any sense in backing up just the MBR - or immediately following sectors.
Use something like s[fg]disk to backup the partition structure; having backed-up the data separately of course.
For the boot code, simply boot from a liveCD, then chroot and reinstall the loader of choice.
The MBR is still, as always, only 1 sectror of 512 bytes. The bootloader, however, does not fit into the few hundred bytes available within the MBR, so it takes about 29KB (GRUB2) additional space, usually in the follow-up sectors. You *may* backup the first 62 (or 63) sectors but you need to be careful, esp. when you restore this. Make dam sure that you do not write over the beginning of the first partition, like, for example, if the layout has changed meanwhile.
Running grub-install is much safer than such lowlevel stuff.
Backing up the first sector (512 bytes) is helpful because if you restore the MBR, sfdisk will know what kind of partition scheme it is dealing with when it's called to restore the (remaining) partition table. If you're not using an extended partition, you won't even need sfdisk because the (up to) 4 primary partitions are defined in the MBR itself.