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

Re: restoring MBR



On Sun, 31 Jul 2011 18:52:53 -0400 (EDT), Aaron Toponce wrote:
> On Sun, Jul 31, 2011 at 04:50:35PM -0400, Stephen Powell wrote:
> > 
> > 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.

I never said it was *difficult*.  I said it can be *dangerous*
(if you don't know what you're doing).  Firing a gun is easy,
not difficult.  But if you're aiming at your foot, it is dangerous!

-- 
  .''`.     Stephen Powell    
 : :'  :
 `. `'`
   `-


Reply to: