Linux command to read MBR

MBR (Master Boot Record) is the first 512 bytes of data on a bootable storage device such as a hard disk.

The command to read the MBR in hex is:

sudo dd if=/dev/sda ibs=512 count=1 | hexdump -C

    Command explanation:

  • “sudo” is used to gain super user privileges,
  • “dd” is a program to convert/read/write/copy a file
  • “if=/dev/sda” is our hard disk that contains the MBR
  • “ibs=512″ is the number of bytes to read at a time
  • “count=1″ is the number of “sectors” to read (count=2 would read 1024 bytes)
  • “hexdump -C” will display the MBR in HEX with a nice character table on the right

The command to save the MBR in a file called “mbr”:

dd if=/dev/sda of=mbr bs=512 count=1

You can even get more info about the MBR with “file” command:

file mbr

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>