Copying MBR

I’ve been doing some disk partitions cloning between disks of different size. I needed to copy the master boot record (MBR), where LILO is, from one disk to another. I searched a bit and found a handy tutorial.

As the web-site explains, the MBR size has the following structure: 446B Bootstrap + 64B Partition table + 2B Signature = 512B. So, to copy the MBR to another disk, preserving its partitioning schema I did the following:

Copy the MBR to a file in /tmp:

dd if=/dev/sda of=/tmp/mbrsda.bak bs=512 count=1

Then, clone the image to the other disk with a different partition scheme:

dd if=/tmp/mbrsda.bak of=/dev/sdb bs=446 count=1

That’s it!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s