Find the answer to your Linux question:
Results 1 to 6 of 6
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    How do I fix/mark bad block using dd?

    I have a partition with SuSE 9.3 formatted with a ReiserFS file system. I've been experiencing strange problems lately (DMA refuses to stay enabled on the drive, loooooong login times, hda errors showing up in syslog), so I ran reiserfsck on /dev/hda7, which identified a bad block. In the comments following the fsck, the output recommended using dd to attempt to write to the specific bad block to try to force the HD to remap the block to it's "reserve" blocks. (FWIW, it's a relatively low-use IBM Deskstar 60GXP drive)
    So my question is, what is the dd command that I use to do this? I mean what options/operators do I use? I read the manpage for dd, but I'm no linux expert, so I couldn't really make heads or tails of how to format my command.

  2. #2
    Linux Guru anomie's Avatar
    Join Date
    Mar 2005
    I am assuming you're referring to the backup superblock. If so, a dd command you can use is part of this howto:

  3. #3
    Thanks for the reply, but no, that's not what I'm talking about.
    The filesystem is ReiserFS, and there is a random bad block in the filesystem (I know the number of the block from the reiserfsck output). Not a superblock, just a bad block somewhere in the file system.
    The output of reiserfsck --fix-fixable told me to use the -B flag somehow to record the location of the bad block. But I couldn't get that to work. The output also mentioned using the dd command to try to write to the bad block, so that the HD firmware would recognize the bad block and remap that block to a block in a set of "reserve" blocks that modern HD's set aside for that purpose. Apparently HD's only do this on writes, not reads. Hence the need to use dd. However, I don't know the syntax for the proper use of the dd command to do this.

  4. $spacer_open
  5. #4

  6. #5
    Linux Engineer
    Join Date
    Jul 2003
    Stockholm, Sweden
    use the "badblocks" command

  7. #6
    dd if=/dev/zero of=/dev/hdz bs=BLOCK_SIZE count=1 seek=BLOCK_NUM

    Then run your superblock and/or rebuild-tree reiser utilities to ensure that the files affected by these corrupted blocks are restored. Note that deleted files, located in hard disk space that has not been overwritten yet, will likely be restored if you use rebuild-tree. I used it a few years ago when I accidentally deleted my mp3 collection ;3

    Use your file system's block size; reiser4 defaults to 4096 iirc. You can use reiserfstune to determine your file system's block size. This method worked for me earlier today, however I was unable to save my hard drive. It seems that countless blocks have gone non-operational in a sequence of (4,4,4,3), ie blocks 1001, 1005, 1009, 1013, 1016, 1020... would all need repair. I'm not sure exactly what causes this, but I'm certainly curious.

    If anyone has insight on the matter, preferrably on the atomic level, please come forward. This is one of those things that will keep me up for nights on end. xD

    Yes, I'm aware the post I'm replying to is 2 years old, however I found no decent tutorial to handle this problem. I wouldn't want someone else to go through all the man pages and examples that I did.

    Good luck to all others who encounter this~

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts