2016-10-06

This is from the “learn something new every day” category. I’ve been using CompactFlash cards together with IDE adapters for several years now. It’s a terrific way to manage storage for vintage PCs. CF cards are cheap, fast, (relatively) capacious, and widely supported. It’s trivial to plug a CF card into a modern PC (typically using a USB adapter), copy files, and plug it into an old 486 or Pentium.

I’ve been using CF cards with DOS, Windows 3.x, and Windows 9x and never noticed much difference. Just recently I also tried using CF cards with Windows XP. The results were interesting.



Industrial (left) and consumer (right) CompactFlash cards.

The first card I tried was a weird 16GB Unigen Enterprise CF card. The card works, but it has very undesirable performance characteristics. Basically the card is very fast… except for writing small blocks. In practice it means that performance kind of sucks, but XP had no trouble using it.

The second card was SanDisk Ultra 32GB. This one subjectively performs much better, no doubt because writing small blocks isn’t penalized nearly as much. But the card had very very strange problems with XP. Straight after installation, XP kept complaining that it didn’t have a swap file, and it was impossible to create one.

After some head scratching, I realized that XP thought it was installed on a removable drive, and refused to create a swap file. OK, I understand the logic of not wanting to have removable-media swap files, but then again the boot drive isn’t really going to be removed, is it. Anyway, clearly the two CF cards were behaving differently—XP considered the SanDisk a removable drive, but the Unigen was fixed. But why?

Let’s not discuss whether it makes sense to report a CF card in IDE mode as a removable device; the fact is that some do it and some don’t. There are two questions: How to fix it, and why it is happening at all.

The first question has numerous answers all over the web. I landed on this page which actually deals with USB devices and Windows 7, but it is just as applicable to CF cards in IDE mode and Windows XP. The short story that Hitachi ran into the same problem with their Microdrives, and developed a filter driver which removes the removable bit (so to speak) in order to placate Windows.

Installing the filter driver involves editing the INF file to include the exact signature of the drive, but it does work. With the filter driver, XP is able to create a swap file and no longer complains. Good.

So why is this happening, and how to tell which CF card is which? Someone clearly thought it was a good idea. For CF cards used with, say, cameras, it makes sense to report them as removable. For CF cards intended as hard disk replacements, it makes sense to report them as fixed.

The practical problem is of course that when purchasing a CF card, this is the kind of information that is impossible to find. CF cards billed as “industrial” are likely to not report themselves as removable, but that is a very rough guide. In some cases, the type can be changed by updating the card’s firmware, but that is far from a generic solution.

ATA Bits

The “removable” bit is reported in bit 7 of word 0 of the IDENTIFY DEVICE command response. This is an old interface, and it was already defined in the first ATA standard (early 1990s). It was intended for removable-media devices such as ZIP drives.

Note that there is a significant difference between removable-media IDE drives and ATAPI devices such as CD-ROMs. Removable-media drives are regular IDE hard disks with a few additional commands to address media lock/unlock and media change tracking. ATAPI devices use a completely different command set (SCSI, basically) and typically support a whole host of other capabilities beyond simply reading and writing sectors.

It makes sense to report CF drives as removable when using the PCMCIA interface. It’s questionable how much sense it makes when using the IDE interface, because there is normally no hot-plugging supported. But the reality is that many CF cards report themselves as removable, and it makes a difference to operating systems.

There is a good chance that the removable bit has an impact on ThinkPads, both when booting off of a PCMCIA drive, and specifically for the ThinkPad 701 when booting off of IDE hard disk. To recap, unlike other ThinkPads, the 701 refuses to boot from most CF cards using an IDE adapter. I now strongly suspect that the 701 requires the CF card to not report itself as removable.

SD vs. CF

I have no first-hand experience with using SD cards as IDE storage. What I do know is that the situation there is different and much more straightforward. CF cards are also IDE devices and CF-to-IDE adapters have no logic in them; therefore, the behavior depends strictly on the CF card.

SD cards are not IDE compatible at all. What that means is that SD to IDE adapters must contain protocol translation logic, and that logic will decide whether the IDE drive seen by the host reports itself as removable or not. In other words, the behavior depends on the adapter and not the card.

TODOs

It would be nice to have some quick way of identifying whether CF cards report themselves as removable or not. That may be doable when using a CF to USB adapter, but  then again maybe not. Suggestions?

Show more