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

Re: dd question



On Sun, Jul 01, 2001 at 02:09:49PM +0200, Joerg Johannes wrote:
> 1.) Just to be sure:
> dd if=/dev/zero of=/dev/sda1
> will overwrite any data on sda1 with zeroes, but leave sda2, sda3 and
> the mbr untouched?

It should, yes.

> 2.) To backup my mbr I do 
> dd if=/dev/sda of=/flopyy/mbr.sda bs=512 count=1

Ack.

>  and to put it back
> dd if=/floppy/mbr.sda of=/dev/sda bs=512 count=2

Reset.

"The first 446 (0x1BE) bytes of the MBR are used by the loader program. They 
are followed by the partition table, with a length of 64 (0x40) bytes. The 
last two bytes contain a magic number that is sometimes used to verify that 
a given sector really is a boot sector."

This is from /usr/share/doc/lilo/Manual.txt.gz, please read it.

So there are three items in these 512 bytes, of which two are easily
restorable from defaults, the loader as mbr.b in the lilo package,
and the magic number trivially.  The other one, the partition table,
can only be restored from backups, or by careful inspection of raw disk
blocks, if you're lucky (and have a lot of spare time on your hands).

Also, you would be zapping a block too many, thereby nuking the partition
table of /dev/sda1.  8-(

> Will this be enough to get lilo back after windos new install?

Generally, the cure for this is to boot into linux with a boot floppy,
if you have to, and to run lilo again.  Most lilo installations are set
to put lilo in the mbr.

But lilo's Manual.txt also documents:

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

Before you try any of this, be sure to keep an extra backup of the current
situation, as well as of the old situation you are trying to put back.

> 3.) During all this dd'ing, /dev/sda must be *completely* unmounted?

Yes and no.  You must of course not have anything on /dev/sda1 mounted
when you are wiping it.  As long as your actions are limited to /dev/sda1
and the mbr, which is only mapped in /dev/sda, filesystems on other
partitions on /dev/sda may remain mounted during operations.

Reading tfm in /usr/share/doc/lilo/Manual.txt.gz is always worth your
while, especially if you have to manage different operating systems on
one disk.

Cheers,


Joost



Reply to: