0

I'm getting frequent and recurring ext4 "bad header invalid magic" errors on an apparently healthy, brand new (few months old) external USB drive (WD MyBook 1230) connected to a Raspberry Pi running Raspbian 7, kernel 3.18.5+. The USB drive is powered separately, i.e. not by the Pi. The dmesg errors look like this:

EXT4-fs (sda1): last error at time 1457814321: ext4_ext_check_inode:495: inode 67294

The errors are produced whenever some certain files are read. When this happens the hard produces a distinct (and rather unsettling) clunk every few seconds, which sounds like a head load/unload or something, but the files seem to be read just fine. I'm mostly using the device as a music library storage, and everything still works, I get uninterrupted playback, can add/remove files, the OS has not ever crashed and does not automatically unmount the device.

Running fsck reports and fixes some errors and makes the ext4 partition clean again, but the same errors are produced when the files are read again. I've tried copying the offending files to another device, deleting the source, and copying them back to the same location and this would stop them causing the bad header errors. I'm guessing they've been moved to a different inode. But I can't just do this for ever file that's giving an error.

Running smartctl shows no errors. The same drive was used for a few months formatted as NTFS in the same setup with no problems, but was reformatted to ext4 for finer permission control and better performance.

Has anyone ever encountered anything like this? Any debugging suggestions? What is happening and how do I fix these errors?

  • You probably need more power getting to the drive. Use a powered hub, or a more powerful usb supply to the pi. You can get cheap inline usb power meters that will show you the volts and amps used by a usb device. – meuh Mar 14 '16 at 8:49
  • Does anything appear in the system logs? (Look for changing files in /var/log) – Gilles 'SO- stop being evil' Mar 14 '16 at 22:18
  • The drive is powered separately from a AC adapter. Also, the drive worked fine in NTFS, so power problems are unlikely. The "bad header" errors are reported by dmesg. That's normally where I would look. Should I inspect all modified files in /var/log? (I've updated the question to clarify these points.) – solarsd Mar 15 '16 at 12:44
  • Since you have SMART, you can try asking the drive to run a long selftest with smartctl -t long /dev/sdx. It will report how long it will take (maybe hours). Afterwards, you can get the result out of the drive log with smartctl -l selftest /dev/sdx. Be careful with wrong smartctl args, it can overwrite data. – meuh Mar 15 '16 at 19:41
  • Both the short and long SMART self tests proceed without error. – solarsd Mar 18 '16 at 4:48
1

The drive is "apparently" not healthy. You very likely have some bad sectors. Try to run a disk test program (e.g. Seagate's "SeaTools", better whatever WD offers, as you have a WD drive).

Don't set too much trust in smartctl.

| improve this answer | |
  • By apparently I meant that it worked fine when formatted in NTFS and problems started right after the switch to ext4. I've ran WD's Data Lifeguard Diagnostics v1.29 and both the long (~10 hour) and short test reported no errors. Although it looks to me that it just did the standard 'short' and 'long' SMART tests, so it's just like using smartctl. – solarsd Mar 16 '16 at 22:20

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.