Write To or Read From a Given Sector Using dd

This comes in handy when trying to troubleshoot a drive. If you’re met with an error message like “I/O Error: Bad sector 40003”, then you can use ‘dd’ to verify that it’s bad. For example, to write to a given sector/block, use the following command:

dd if=/dev/urandom of=/dev/sdb seek=<sector_number> count=1 bs=512

To read from a given sector/block, use the following command (skip instead of seek):

dd if=/dev/sdb of=/dev/null skip=<sector_number> count=1 bs=512

Feel free to donate if this post prevented any headaches! Another way to show your appreciation is to take a gander at these relative ads that you may be interested in:

There's 4 Comments So Far

  • Yakov
    April 4th, 2012 at 4:46 am

    Does it work if your sector size differs from 512 byte?

  • JC
    July 1st, 2012 at 1:27 pm

    If your sector size differs you’ll have to change bs=(your sector size).

  • TecnoFocus
    January 25th, 2013 at 12:56 pm

    Thanks!! exactly what i m looking for!

  • W. R. Knight
    June 20th, 2014 at 6:40 pm

    Tried reading the mbr using the dd command above which writes to of=/dev/null. There was no response, no output, can’t read /dev/null and I have no clue what was in the record.

Share your thoughts, leave a comment!