backing up and restoring boot sector

ZIYAD A. M. AL-BATLY zamb at spymac.com
Wed Apr 20 11:36:03 UTC 2005


On Wed, 2005-04-20 at 19:35 +0900, toyfactory wrote:
> On Wed, 20 Apr 2005 18:13:02 +0900, "toyfactory" <toyfactory at xsmail.com>
> said:
> > 
> > While playing around with different multi-boot options I sometimes screw
> > things up.  Things are (fingers crossed) working fine at the moment but
> > I would like to be able to make a back-up of the MBR and boot sector for
> > when I decide to install MS-DOS 5.0 again or whatever.  Finding out how
> > to back-up the MBR was straightforward Googling:
> > 
> > dd if=/dev/hda of=mbr.bin bs=512 count=1
> > 
> > Restoring the MBR brought Grub back to life but not the Windows 2000
> > boot menu.  Resurrecting that required me to hunt down the Windows CD,
> > boot to the Recovery Console and run fixboot.exe to repair the partition
> > boot sector.  So, my question - is there a simple way to back-up and
> > restore the 'partition boot sector' in Linux.
> 
> Sort of guessing at the answer to my own question here, but if I think
> of the MBR as the 'boot sector' for the whole hard disk and copy the
> first 512 bytes from /dev/hda, then wouldn't the 'partition boot sector'
> I'm after be the first 512 bytes copied from /dev/hda1?
> 
> Nick
> 
Yes. MBR is not the only way to boot the system.  Be default, the BIOS
will see if it can load the MBR into the memory. If that succeeded, then
the BIOS job ends there. If that fails, it will search in the partition
table for the first partition that is marked boot-able (from the
boot-able device in the BIOS settings) and load the first 512 Bytes into
the memory. If that fails, it try for the next boot device (the second
hard-drive, for example, or the CD-ROM, or whatever) and so on until it
fails to load anything, then you'll see the "No boot device found,
insert a boot disk in A: and hit enter" or whatever you BIOS is
configured to report.

Microsoft historically never used the MBR.  All their OSes clear the MBR
and set a boot-able partition (usually the first one, or "C:") and put
the boot code in there (msdos.sys (or io.sys, I forgot which one, I'm
too old) for DOS and Windows 9x/Me, and ntloader.something for Windows
NT/2000/XP/2003).

I hope this enlighten you a little.
Ziyad.





More information about the ubuntu-users mailing list