how to backup MBR with dd?

Using applications, configuring, problems
Post Reply
Message
Author
User avatar
cb88
Posts: 1165
Joined: Mon 29 Jan 2007, 03:12
Location: USA
Contact:

how to backup MBR with dd?

#1 Post by cb88 »

how can I backup my MBR with dd and restore it later with dd?

assume that i have a flash drive to save the image to running from the livecd...
Taking Puppy Linux to the limit of perfection. meanwhile try "puppy pfix=duct_tape" kernel parem eater.
X86: Sager NP6110 3630QM 16GB ram, Tyan Thunder 2 2x 300Mhz
Sun: SS2 , LX , SS5 , SS10 , SS20 ,Ultra 1, Ultra 10 , T2000
Mac: Platinum Plus, SE/30

Bruce B

#2 Post by Bruce B »

backup
cd to your flash drive
dd if=/dev/hda of=backup.mbr bs=512 count=1

restore
cd to your flash drive
dd if=backup.mbr of=/dev/hda count=1

User avatar
cb88
Posts: 1165
Joined: Mon 29 Jan 2007, 03:12
Location: USA
Contact:

#3 Post by cb88 »

so i guess that means dd if=infile and of=outfile bs=512 (512 byte bootsector) count=1 (not sure)

that makes sence thanks
Taking Puppy Linux to the limit of perfection. meanwhile try "puppy pfix=duct_tape" kernel parem eater.
X86: Sager NP6110 3630QM 16GB ram, Tyan Thunder 2 2x 300Mhz
Sun: SS2 , LX , SS5 , SS10 , SS20 ,Ultra 1, Ultra 10 , T2000
Mac: Platinum Plus, SE/30

Bruce B

#4 Post by Bruce B »

cb88 wrote:so i guess that means dd if=infile and of=outfile bs=512 (512 byte bootsector) count=1 (not sure)

that makes sence thanks
I'm glad it makes sense, because dd doesn't follow Linux conventions for parameters very closely.

In this example count=1 says, "Start at the first sector and take the amount of data defined in bs=, and quit after doing it one time."

In common language it says, "Write (copy) a file containing the first 512 bytes on the first sector of /dev/hda, which happens to be the MBR, and that's because we know in advance where the MBR is located and how big it is."

If count=10 it would start at the first sector and copy 512 bytes sequentially up the sectors ten times. The file size would be 5120 and it would contain more than just the MBR.

User avatar
Flash
Official Dog Handler
Posts: 13071
Joined: Wed 04 May 2005, 16:04
Location: Arizona USA

#5 Post by Flash »

Thanks for that explanation Bruce. It demystifies the dd command somewhat. :)

Post Reply