USB hard drive writes corrupt data under linux
I have a SATA hard drive in a USB HDD enclosure, which works well with Windows. Recently I started using it in Linux and something went wrong.
When I write a huge block of data into that drive, the writing process will report that everything is fine. But when I read it back, there is a data corruption about every several GBs, and sometimes even more. The kernel will report an I/O error and a USB disconnected event. The USB HDD enclosure then reconnects again, looks like it has restarted.
If I connect the hard drive to a internal SATA port and do the same read operation, I see a lot of SATA UNC errors.
I've done a lot of tests and here are my results:
-- If data is written while the hard drive is directly connected to an internal SATA port, there will be no data corruption.
-- If data is written while the hard drive is in the HDD enclosure, but under Windows, there will be no data corruption either.
-- Those sectors are not really physically broken. A correct overwrite operation (either with an internal SATA port, or under windows) will fix them.
-- This error is reproducible, although actual positions of broken sectors will be different. I can reproduce it with my debian laptop and Raspberry Pi. And data corruption happens regardless of whether writing is performed in a mounted ext4/NTFS filesystem or directly to the raw device.
I have no other HDD enclosures to test, and I'm not sure if it's a hardware problem or a driver bug.
Does anyone have experience with such problems before? What can I do to fix the problem? Or do I have to buy a new HDD enclosure?
I would mount it internally using a SATA port and run a SMART long test.
|All times are GMT -5. The time now is 11:44 PM.|