0

I have an image that I know was ok. (image.jpg)

A few days later when I open, image.jpg was corrupt. (not displaying properly)

How to check if bit in hard disk drive where image is located is failing?

I am ok with permanent destruction of image.

Can I dd over file with all ones wait a few days and check if any of the bits have flipped?

If it matters, I am on standard Ubuntu installation.

  • What type of file system are you on? Most have an fsck like facility to discover and possibly correct such things. Crc can also be used, if you save crc info of correct file in advance – Dani_l May 12 '18 at 4:59
  • Filesystem: ext4 – wjwrpoyob May 12 '18 at 5:00
  • Please add that info to the question and try to run fsck on the volume – Dani_l May 12 '18 at 5:01
  • 1
    If you have any suspicion of a corrupt drive, I would recommend checking the entire drive. – Tigger May 12 '18 at 5:04
  • 1
    Look at the SMART values of your harddisk (smartctl). Besides the harddisk failing, some faulty program may also have overwritten some part of the image. – dirkt May 12 '18 at 7:13
1

Try badblocks, which seems to work on regular files provided the files aren't open:

badblocks -b 512 -vn image.jpg 

Example on a real 13K file:

sudo badblocks -b 512 -vn \
               /usr/share/texlive/texmf-dist/tex/latex/mwe/example-image.jpg

Output:

Checking for bad blocks in non-destructive read-write mode
From block 0 to 25
Testing with random pattern: Pass completed, 0 bad blocks found. (0/0/0 errors)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.