[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: restoring MBR



On Sun, Jul 31, 2011 at 04:50:35PM -0400, Stephen Powell wrote:
> On Sun, 31 Jul 2011 11:30:38 -0400 (EDT), Camaleón wrote:
> > ...
> > But regardless the option the user select at install time (do not install
> > any bootloader, install it in a partition or another place or just
> > putting it into MBR), it would be nice the installer makes a copy of the
> > original MBR and leaves it under "/boot".
>
> Sometimes restoring a backup copy of the master boot record can be
> even more dangerous than wiping it out.  The master boot record contains
> the master boot record boot program, but it also contains the partition
> table.  If any partition changes were made during installation (partitions
> were created, deleted, moved, resized, etc.) then simply replacing the
> master boot record with an older copy will not only restore the old
> master boot record boot program but will also restore the old partition
> table.  This can lead to permanent data loss.  One must be very careful
> about how one goes about restoration in such cases.  In most cases, one
> doesn't want to restore the entire 512-byte sector, but only a portion of
> it: up to, but not including, the partition table.

It's not that difficult, if you understand haw MSDOS partitioning is setup
under GNU/Linux. The first 446 bytes are your boot loader. The next 64
bytes are your partition table. If you wish to backup just the bootloader,
it's easy with dd(1):

    # dd if=/dev/sda count=1 bs=446 of=/tmp/boot.img

I generally tell my students that if they are using flat partitions, rather
than LVM or something else, then they should save a hard copy of their
partition table. Sholud you wipe that out, if you know the starting and
ending of each partition, you can recreate the table, and get back at your
data. This can be easily accomplished with fdisk(8):

    # fdisk -l /dev/sda > /tmp/partitions.txt

It doesn't hurt to backup the entire MBR, all 512 bytes worth, and save
that elsewhere on disk, as it's trivial to restore, and it contains your
partition table:

    # dd if=/tmp/mbr.img of=/dev/sda

Just some thoughts about the "difficulty" of managing the MBR and
partitions.

--
. o .   o . o   . . o   o . .   . o .
. . o   . o o   o . o   . o o   . . o
o o o   . o .   . o o   o o .   o o o

Attachment: signature.asc
Description: Digital signature


Reply to: