Originally posted by LinuxGeek
I was wondering how you could back up your MBR in case it is overwritten, for example. I know the command:
dd if=/dev/hda of=/root/mbr bs=512 count=1
but the shortcoming with this approach is that the partition table for only the primary partitions is saved. What would I do if I wanted the partition tables of the logical partitions to be saved. Would I do something like:
dd if=/dev/hda4 of=/root/mbrlogical bs=512 count=1
This will (probably) achieve what you are looking for.
IMHO a bit pointless, but that's o.k.
The "logical" part table(s) within each logical partition are chained (forward chain only). A single sector per logical partition should be sufficient.
Let's hope your root isn't mounted on the disk you are trying to salvage ...
Note that the MBR backup will also have the data for the extended partition in addition the the primary/primaries.
Go with sfdisk as suggested by david_ross.
better option - hadn't seen that use of it.