Q. How do I copy MBR from one hard disk to another hard disk under Debian Linux? I need to do this because of RAID 1 configuration.
A. To copy MBR simply use dd command. dd command works under all Linux distros and other UNIX like oses.
dd command to copy MBR
Type dd command as follows:
dd if=/dev/sda of=/dev/sdb bs=512 count=1
Above command will copy 512 bytes (MBR) from sda to sdb disk.
Featured Articles:
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- My 10 UNIX Command Line Mistakes
- 10 Greatest Open Source Software Of 2009
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- Top 20 OpenSSH Server Best Security Practices
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Linux Video Editor Software
Want to read Linux tips and tricks, but don't have time to check our blog everyday? Subscribe to our daily email newsletter to make sure you don't miss a single tip/tricks. Subscribe to our weekly newsletter here!
- Email FAQ to a friend
- Download PDF version
- Printable version
- Comment RSS feed
- Last Updated: 09/20/07



{ 6 comments… read them below or add one }
This is correct for EXACTLY the same partition sizes. In the case you want the MBR only on a drive that has a root partition of a different size then issue the same command with a smaller block size.
dd if=/dev/sda of=/dev/sdb bs=446 count=1
Thus preserving the partitioning schema.
Right… be VERY careful with doing this w/ two discs with different size partitions! In fact, the safest way to backup/restore JUST THE MBR:
dd if=/dev/sda of=mbrbackup bs=512 count=1
To restore the MBR (on to the same drive or any drive):
dd if=mbrbackup of=/dev/sdb bs=446 count=1
Caiken is right! BEWARE of using the above dd line on two discs that don’t have IDENTICALLY sized partitions! You will lose data!
Here’s what I do to copy just the MBR from a hdd:
dd if=/dev/sda of=mbrbackup bs=512 count=1
Now to restore the image to any hdd:
dd if=mbrbackup of=/dev/sdb bs=446 count=1
Thanks a lot, this was just the kind of short note I was looking for ,)
MBR is 512 or 446 bytes?
MBR is divided into 3 sections
1. Bootstrap . 446 bytes
2. Partition table. 64 bytes
3. Signature. 2 bytes