linux usb/ide

I haven’t had a lot of luck using usb hard drive enclosures with Linux. I have about three of them. And they have all ended up in the bottom of a box because basically they never worked reliably with linux. The usual scenario is;

  • Buy cheap usb/ide enclosure
  • Plug hard drive in
  • Plug in to linux system. Device is recognised
  • Copy some small files around. All looks to be OK
  • Start copying some larger files to the enclosure and after a minute or two, I hear lots of strange noises from the drive, and dmesg shows me lots of ‘reset high speed USB device…’ type errors … and effectively the file copies stop until I basically pull the plug on the drive.

It’s all very sad, and of course the drive enclosure is basically useless at this point. Years ago when I bought my first USB/IDE enclosure, I did some googling and discovered that “Yes, I am an idiot for buying an enclosure based on the Genesys chipset” because basically they don’t work with linux. They work with Windows, but not linux.

Years later I buy another usb/ide enclosure that was cheap and sadly it too is a Genesys chipset. But I think maybe ther are some advancements in the newer linux kernels to get around this. Nope. Still does not work.

Years pass and I foolishly buy another usb/ide enclosure thinking surely the days of the Genesys chipset are behind me but NO, my latest 3.5″ enclosure (which admitedly was very very cheap) also is based on the Genesys chipset.

So this latest 3.5″ enclosure has been in the cupboard for a while and I swear to myself that it must stay there because it is evil, but hey its Easter, I have some free time, so I dig it out. I plug an old 8GB ide drive into it , and plug it into my T42 running Debian Lenny on Debian’s kernel 2.6.26.

It is detected, I can fdisk it, I can create a filesystem on it, I can copy some small files to it, but can I copy a lot of large files to it:


It dies on its arse again with those ‘reset high speed USB …’ errors. So having nothing better to do I google for a bit to see what the current state of the linux world is with regard to these types of enclosures. I find some interesting stuff in ubuntu bug 61235 (which seems to have been around for several years), and also some notes on the linux usb site about genesys chipsets. This last reference talks about reducing the max_sectors used when talking to a genesys device. I vaguely remember trying this years ago but it didn’t seem to help. But maybe this newer enclosure and newer kernel might help.

So I gave it a shot. I had a look at what the current max_sectors was set to;

cat /sys/block/sda/device/max_sectors

which said it was set to 240. That linux usb site reckoned that genesys devices should be set to 64 (but notes that the Windows driver uses 128 successfully). So initially I tried;

echo 64 >/sys/block/sda/device/max-sectors

And started copying some large files and amazingly it did not die. It actually kept on copying all the way to the end. I copied a good 7GB or so just fine. So then I tried it with 128;

echo 128 >/sys/block/sda/device/max-sectors

And did the copy again. That worked too. And I did it again , and again and I didn’t get any errors. Of course by reducing max_sectors you reduce the speed at which you can transfer data. Sadly, my 8GB drive was lucky to do over 10MByte/sec. But I had a newer 250GB 7200rpm drive. Surely that might go faster.

Nope. It was about the same speed or worse. 10MB/sec is hardly what you call a decent speed … but at least it doesn’t self corrupt itself.

So at the moment I’m repeately copying data to try and make it screw up. Talk about faith in hardware and drivers 😉

I’ve also added in a udev rule like the one on this linuxmint forum in order to set the max_sector count on any connected usb-storage device to the reduced number. I probably slow down all usb storage devices a bit by doing it this way.