Unable to restore Windows boot sector using dd
Peter Garrett
peter.garrett at optusnet.com.au
Fri Dec 8 09:19:27 UTC 2006
On Fri, 8 Dec 2006 11:40:03 +0530
"Shriramana Sharma" <samjnaa at gmail.com> wrote:
> 1. tar | gzip the contents of sda1 and save it to another safe
> partition (or DVD).
> 2. dd if=/dev/sda1 of=~/sda1-bootsector bs=512 count=1
/dev/sda1 is the first partition, not the MBR - I assume you wanted to
copy your MBR, which would be the first 512 bytes of /dev/sda
> 3. <something happens to crash the Windows installation>
> 4. reformat the partition using mkdosfs.
> 5. tar | gunzip from the backup.
> 6. dd if=~/sda1-bootsector of=/dev/sda1 bs=512 count=1
Your (6) puts the file on the first 512 bytes of the *first partition*
of /dev/sda ( /dev/sda1) - i think you have both dd commands wrong, as
below:
From
http://www.debianhelp.co.uk/ddcommand.htm
<quote>
MBR backup
In order to backup only the first few bytes containing the MBR and the
partition table you can use dd as well.
dd if=/dev/hdx of=/path/to/image count=1 bs=512
MBR restore
dd if=/path/to/image of=/dev/hdx
Add "count=1 bs=446" to exclude the partition table from being written to
disk. You can manually restore the table.
</quote>
In your case you would substitute /dev/sda ( rather than /dev/hdx )
As for the "mkdosfs" - I've never used it, but the man page suggests you
would need the -F option to set FAT32. Whether Windows will recognise the
file system thus created, I don't know. In any case FAT32 is a nasty
filesystem.... Also, using dd should not require a pre-existing file
system, since dd is very low-level and copies both the file system and
the data, if I understand correctly. On the other hand, as you are using
tar and gzip to back up, you are not mirroring the partition, so a file
system would be required for your method, if I understood it correctly.
Perhaps all this would be better done with something like "Ghost for
Linux" or some other tool that actually mirrors your partition ?
http://sourceforge.net/projects/g4l
Peter
More information about the ubuntu-users
mailing list