LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   dd question (https://www.linuxquestions.org/questions/linux-software-2/dd-question-394683/)

shanenin 12-19-2005 07:06 PM

dd question
 
I have read man dd, but still am unsure of what it means. look at this line of code
Code:

dd if=/dev/zero of=/dev/hda bs=512 count=1
with having the count=1 option, will it only do the mbr? I have used that command before and it seemed to format the WHOLE drive.

homey 12-19-2005 07:38 PM

That clears the MBR. The partition table is located in that space also, so it will appear to format the drive.
However, that's only an illusion as you can restore a saved MBR and the partitions and data will re-appear if you haven't actually formated anything.

I use dd or sfdisk to save and restore the mbr.
For example:
dd if=/dev/hda of=/mnt/images/mbrfile bs=512 count=1
dd if=/mnt/images/mbrfile of=/dev/hda bs=512 count=1

or

sfdisk -d /dev/hda > mbrfile
sfdisk /dev/hda < mbrfile

( man sfdisk )
-d Dump the partitions of a device in a format useful as input to
sfdisk. For example,
% sfdisk -d /dev/hda > hda.out
% sfdisk /dev/hda < hda.out
will correct the bad last extended partition that the OS/2 fdisk cre-
ates.

shanenin 12-19-2005 07:50 PM

Thanks, that clears it up :-)


All times are GMT -5. The time now is 06:00 PM.