Russell's Blog

New. Improved. Stays crunchy in milk.

Converting an IBM X40 to Flash

Posted by Russell on February 21, 2008 at 7:02 p.m.
The Hitachi 1.8" hard drive in the IBM X40 is probably the worst data storage product I've ever used. It is expensive, excruciatingly slow, irritatingly loud, and non-standard. There are basically no options for replacement except to just buy another one. And, as I discovered to my sorrow, it is also fragile and unreliable. So, I decided to replace it with a Compact Flash card.

You may have heard something about Solid State Drives (SSDs), such as the one available as an option for Apple's MacBook Air. You can think of this project as sort of a poor-man's version of these products.

While most CF drives are relatively small and expensive, there are a few products that seem to sacrifice speed for capacity. This may seem sub-optimal, but the drive it will be replacing is astonishingly slow to begin with. According to hdparm, it can do buffered reads at 18 MB/sec, but in practice that seems pretty optimistic.

If I understand correctly, the Compact Flash interconnect standard is basically a subset of IDE. So, you just need a little passive adapter board, and you can plug a CF card directly into an IDE port. I used a D44MIDECF adapter card from Addonics. At $20, it's a little overpriced. There are no active components, and the board contains only the CF plug, the 44 pin IDE pinout, a jumper, a surface mount resistor, a surface mount capacitor, and a surface mount LED. On the other hand, it is something of a specialty part, so I suppose I should be happy that they bothered to sell it to me at all. For the CF card, I found this monster on NewEgg.

The X40 doesn't have removable media (other than the SD/MMC reader). I've always hated fiddling around with boot floppies and installers anyway. Supposedly, Debian has gotten their installer in better shape since I last played with it. That was more than five years ago. I just skipped that whole process, and built out a minimal Debian install by hand. I popped the CF disk into my SanDisk USB Flash reader, and did the following :

sudo fdisk /dev/sdc 
   # created a 31 GB primary partition tagged as Linux [id 83]
   # and a 1 GB primary partition tagged as Linux Swap [id 82]
sudo mkfs.ext3 /dev/sdc1
sudo mkswap /dev/sdc2
sudo mount /dev/sdc1 /mnt/flash
sudo debootstrap sid /mnt/flash/ http://linux.csua.berkeley.edu/debian
sudo chroot /mnt/flash
vi /etc/apt/sources.list
apt-get update
apt-get dist-upgrade
apt-get install linux-image-2.6.24-1-686 grub sudo 
mkdir /boot/grub
update-grub
vim /boot/grub/menu.lst
exit
sudo grub-install --root-directory=/mnt/flash --recheck /dev/sdc
Then, pop the CF card in its little adapter board into the drive bay, and boot. Hooray! Here is how hdparm identifies the CF disk :
/dev/hda:

 Model=, FwRev=20070912, SerialNo=CF CARD 000040D9
 Config={ HardSect NotMFM Fixed DTR>10Mbs }
 RawCHS=16383/15/63, TrkSize=0, SectSize=576, ECCbytes=4
 BuffType=DualPort, BuffSize=1kB, MaxMultSect=1, MultSect=off
 CurCHS=16383/15/63, CurSects=15481935, LBA=yes, LBAsects=63438848
 IORDY=no, tPIO={min:120,w/IORDY:120}, tDMA={min:120,rec:120}
 PIO modes:  pio0 pio1 pio2 pio3 pio4 
 DMA modes:  mdma0 mdma1 *mdma2 
 AdvancedPM=no

 * signifies the current active mode
The default IDE settings for the CF drive result in very slow performance, so some tuning is in order. I edited /etc/hdparm.conf accordingly :
/dev/hda {
        write_cache = on
        io32_support = 3
        dma = on
        lookahead = on
        interrupt_unmask = on
}
Here is the output of the script :
Setting parameters of disc:
/dev/hda:
 setting 32-bit IO_support flag to 3
 setting unmaskirq to 1 (on)
 setting using_dma to 1 (on)
 setting drive read-lookahead to 1 (on)
 setting drive write-caching to 1 (on)
 IO_support    =  3 (32-bit w/sync)
 unmaskirq     =  1 (on)
 using_dma     =  1 (on)
 look-ahead    = not supported
 write-caching = not supported
  /dev/hda.
The result is actually a little faster than the Hitachi hard drive :
sudo hdparm -Tt /dev/hda

/dev/hda:
 Timing cached reads:   1474 MB in  2.00 seconds = 737.30 MB/sec
 Timing buffered disk reads:   44 MB in  3.13 seconds =  14.06 MB/sec
So far, I'm pretty happy.
Frames on February 23, 2008 at 6:09 p.m.

Good to know that at least the X40 does not force you to use proprietory IBM 1.8'' drives with the stupid error 2010. I ALMOST bought a X41 two days ago.

BTW, Aren't you afraid of tearing up that CF card by using ext3's journaling, swapping, the normal logging writes, and not using noatime on /etc/fstab and ? A regular CF should only take about 10.000 write cycles. A current SSD will take 1 million.

Russell on February 23, 2008 at 9:36 p.m.

I use a similar type of CF card for the boot volumes in my Soekris boxes. They've each been running for about three years without complaint, and I didn't bother to take any special measures to reduce wear-and-tear on the Flash chips.


Out of curiocity, I've actually deliberately tried to wear out the smaller CF card that serves as the boot disk for my router / Asterisk host. It's been getting hammered on for 18 months now, and I haven't seen any evidence of damage.


I think that the write-cycle burn out for Flash must be a bit of an urban ledgend, or at least exaggerated. Maybe newer Flash chips are just more durable, or something. In any event, my experience is that CF cards last at least as long as hard drives under similar loads. My two CF cards obviously don't constitute a statistically significant sample, so maybe I just got lucky.

Frames on February 24, 2008 at 10:14 a.m.

That's good to know! I might try that, too in the near future.

BTW, I take it you got rid of that annoying noise by using the CF card. But can I ask if you have noticed less heat is produced now? Any significant improvements regarding battery live?

Thanks!

Russell on February 24, 2008 at 4:31 p.m.

The heat reduction is pretty significant. I noitce that the fan almost never switches on now. I think the CPU and the drive bay share the same heat spreader in the X40.


There are two possible reasons for the decreased fan operation. It could be credited to less heat production, or it could be because now that the drive bay is mostly empty, it is effectively an extra radiation/convection surface for dissipating the CPU's heat.


I have definitely noticed an increase in battery life -- maybe as much as 30%. I don't have measurements for it yet. This is a very well-used laptop, so obviously the battery is not in great condition.

Frames on February 24, 2008 at 5:39 p.m.

Thanks for taking the time to respond.


Seems like you have just revamped your notebook at a decent price. And sorted out a couple of issues at the same time.

All the best.

Russell on February 24, 2008 at 6:10 p.m.

No trouble!


I remember just enough Spanish to sort of follow your blog -- it's been almost ten years since I've used it! Do you have an Eee PC yourself?

Jamie Kitson on June 04, 2008 at 12:44 p.m.

Aren't most CF cards actually hard drives, not solid state flash? And I don't think hdparam is a very reliable speed test, try bonnie++

Jamie

atreyu on July 04, 2008 at 9:02 a.m.

Remember 100000 Flash Cycles and you CF is history.

Regards

Jeff on July 05, 2008 at 6:44 a.m.

That's cool! Nothing I'm in any rush to do on my laptop (it's my most powerful/fastest machine right now and serves as a test bed), but tempting for my tower! Thanks to NFS, it's not like I'd need any more space.

Also, @Frames:
A few years back, IBM sold its hard disk drive division to Hitachi. So the 1.8" Hitachi drive in Russel's X40 is probably identical to the 1.8" IBM drive in the X41 you were looking at.

James on July 17, 2008 at 9:33 p.m.

err jamie no a cf card is solid state are you thinking of the microdrive? thats a hard disk

Gene on August 19, 2008 at 8:25 p.m.

The link you gave to the Addonics D44MIDECF adapter card now points to a 2.5" device. The name is still the same -- but is this the same device as you used? Or did they dump the 1.8" version?

anthony on August 19, 2008 at 9:40 p.m.

re Gene above, I am also unsure regarding 1.8" or 2.5". Will the the 2.5" adapter fit into the X40 or should I be looking for a 1.8" adapter?

jh on September 18, 2008 at 7:34 p.m.

thanks! i got the 32gb CF and will put it in my CF card adaptor in the PCMCIA port. the external hard drive is too annoying to bring around and i need more space. found this site when googling how to replace hard drive, but will add on with the CF card instead.

Hans on September 19, 2008 at 11:02 a.m.

Ebay offers the adapter for USD 1,99.
Search for:
CF as 44-pin 1.8" IDE Lenovo IBM X40 X41 HDD Adapter.
Any experience with Windows XP ?

lost customer on October 29, 2008 at 12:51 a.m.

it is really irritating that when reading comments looking for more information about a topic I read comments that are essentially advertising products or services for sale. I warrant that I will never spend money with persons or companies that commit such acts regardless if such products are 100% brand new or even .05% new (is that possible?, yes I'm sure it is)

True on November 01, 2008 at 4:18 p.m.

True

Matt J. on November 01, 2008 at 4:38 p.m.

Hi,

I've recently modded my X40 with a CF-44pin adapter.

It's this one here: http://allegro.pl/item466614417_przejsciowka_ata_kazde_cf_i_microdrive.html

I put in a Pretec x233 16GB flash card, installed Ubuntu, works ok.

I have issues when trying to use hdparm however:

sudo hdparm -f -c3 /dev/sda

/dev/sda:
setting 32-bit IO_support flag to 3
HDIO_SET_32BIT failed: Invalid argument
IO_support = 0 (default)

Seeing what comes out of /dev/sda when looking at it:

sudo hdparm /dev/sda

/dev/sda:
IO_support = 0 (default)
readonly = 0 (off)
readahead = 256 (on)
geometry = 1949/255/63, sectors = 31326208, start = 0

I'd suppose it should work real slow.

However, that is not the case:

sudo hdparm -tT /dev/sda

/dev/sda:
Timing cached reads: 862 MB in 2.00 seconds = 430.19 MB/sec
Timing buffered disk reads: 108 MB in 3.03 seconds = 35.64 MB/sec

It would all be peachy, however, my x40 seems sometimes very unresponsive, whenever (I think, since I have no hd led now) there is some disk activity going on.

From what hdparm shows, I don't know if DMA is enabled, however udma is definetly on (dmesg and hdparm -Ii say so).

What configuration tweak could I be missing?

Also, have you in any way managed to get the normal hd led (below the tft screen) working with the cf adapter?

If it involves any soldering, I guess I could manage.

I know the pinouts for 40-pin IDE (which is essentially the same as 44-pin IDE, but without the power), pin 39 is responsible for LED signaling - however, I do not know what exact value should it signal.

I know there is a led soldered onto my CF adapter, so maybe if I soldered a small wire from pin-39 to that led, more or less, I'd get the wanted effect?

Cheers,

Russell on November 04, 2008 at 10:43 a.m.

lost customer --

Believe me, I agree! I've deleted the ad robot posts. If I've mistaken a comment by a real person for ad robot spam, I'm sorry. I'm not against off topic comments, but it is sometimes difficult to tell them apart from comment spam.

Russell on November 04, 2008 at 10:49 a.m.

Gene & anthony --

The part linked in the original post is (still) exactly what I'm using now. The actual board is not 2.5 inches, and will fit in a 1.8" bay without difficulty.

I think the reference to 2.5" drives is simply there because 1.8" drives and 2.5" drives use the same connector, and the 2.5" form factor is much more common. They are talking about the type of connector, not the size of the board.

Russell on November 04, 2008 at 10:59 a.m.

Matt J --

Huh. I'm not sure why your HD light isn't working. Mine works just as you'd expect it to. I know that there are some kernel hacks for controlling those LEDs, and maybe an ACPI driver. Possibly you have those enabled by accident?

I also get the halting during heavy activity problem. I think this is because you're not in DMA mode, and the disk activity is starving your machine for interrupts. If you have a high quality CF disk (like the San Disk Ultra Uber Super Duper XXICV Plutonium, or whatever), try building a small bootable linux image. Probably, you won't be able to use one of these as your main disk because they are expensive. See if you still get the halting effect.

It was recently brought to my attention that I could have bought the dual bay adapter that Adonics makes (for only two bucks more), and put two CF cards in there. Then, I could have used a high quality CF card for my boot volume, and kept data on a larger, slower CF card.

I'm kicking myself!

Matt J. on November 05, 2008 at 5:08 p.m.

Yea, I'd think it should've "just worked" too, but it doesn't.

I don't know why exactly. I think it just passes the led data onto the on-soldered led, so there is no activity on pin-39.

As regards ACPI modules, no, I know there's acpi modules for it too, but it doesn't work that way afaik.

Besides, had it been an ACPI module issue, the led would work during startup :-)

Also, about the DMA issue... yea, I think it could be that, however hdparm suggests that DMA is enabled.

Oh well. We'll see. I guess there's some way of forcing DMA onto a device with the hd module.

xenonn on November 13, 2008 at 11:17 a.m.

Below's the link to the test performed on cf cards I found while googling for a cf ssd solution.

http://www.hjreggel.net/cardspeed/cs_udmacf.html

Those super duper sandisk cards don't seem to be the best anymore. Take a look for yourself.

PaulGreg on November 28, 2008 at 4:05 p.m.

Thanks Russel for that post !

I'll do that mod too on my X40 with a dual Addonics adapter and 2 CF :
- a Transcend 8 Gb x300 for the Os, Ubuntu (that card, by the way, supports S.M.A.R.T which is very cool to prevent failures)
- and a second Transcend 32 Gb x133 for my data.

Jesse on December 14, 2008 at 8:22 p.m.

Matt J,

I am also using a Pretec 233x 4gb card and was having 'this system is hanging' problems.

First I was using a slower card, Kingston 133x 8gb. This was awful. I upgraded to the faster Pretec card and the problem was less noticable.

The problem seemed worse with ubuntu 8.10 and less noticable with 8.04. It was the most noticable when using firefox3.

I have solved the problem by (i think) installing openbox and using openbox/gnome as my 'session'.

Also, made adjustments to /etc/fstab and /boot/grub/menu.lst which i'd found after searching for 'speed up ubuntu boot'.

David Markle on January 04, 2009 at 5:19 p.m.

Sir:

You are a prince among men.

For the record, I got a SanDisk Extreme III 16GB card and the Addonics dual-slot adapter, and it's BIZARRE. For the past 5 years I've been living with a noisy, clicky, dodgy laptop, and now it's eerily quiet and fast. It's almost unnerving!

-Dave

Matt Sellers on February 09, 2009 at 11:07 p.m.

Could this be done with windows xp installed on it? would i just be able to run the cd or would i have to do special formatting of the disc?

taiji_jian on April 18, 2009 at 4:05 p.m.

Hi Russel,

I found this post from last year to be a useful reference while trying to duplicate your feat. However, I've run into some problems which I have posted about over at the Ubuntu forums. If you're not too busy I was hoping you could take a look:

http://ubuntuforums.org/showthread.php?t=1129173

MarkWilson on April 23, 2009 at 3:47 a.m.

I wondered if this mod can be used and still retain the hard drive cover with everything fitting inside!

Russell on April 26, 2009 at 8:26 a.m.

Matt --

I don't see why it wouldn't, but of course, the installation process would work differently. I've been careful to avoid learning anything about Windows for about ten years now. The X40 doesn't have a CD-ROM drive, so you'll have to figure that out on your own. The nice thing about using the adapter board is that it appears to the hardware as a hard drive. So, no special drivers and whatnot.

MarkWilson --

Yep. That was the whole reason I did this in the first place. I couldn't find a replacement hard drive that would fit, but the CF card and adapter board fit just fine. I took the little plastic doodad off of the drive sled and used it by itself to seal the hard drive bay. You can't tell that it was modded.

Dave Markle on April 27, 2009 at 4 a.m.

Guys:

I just found out that there's a company that makes actual SSDs for the X40, in China. And I got one, and can give you a bit of a comparison between it and the SanDisk Extreme III CompactFlash card I've been using. First off, it's called a KingSpec SSD (KSD-PA18.1-032MJ) and it's made to fit the X40 perfectly. (its actually a bit thinner than the Hitachi, so it IS possible to miss a row of IDE pins if you're not careful). I got some stutters from my whole system with the SanDisk and the CF -> IDE adapter, but that does not happen with the KingSpec drive. It's smoother than the non-UDMA flash drives out there (I tried to get an Extreme IV UDMA card to work, but I couldnt get it to boot) AND it's recognized by Windows as a regular non-removable HDD, so you don't have to hack your way around it. Don't know about linux. So far, the thing is very fast and I've been very happy. Much nicer than the CF solutions. Oh and BTW, I got it off EBay. Hope this helps!

Calogero on August 13, 2009 at 1:03 a.m.

Hi I have a probem for converting !
can you help me ?
Calogero

Ignore this field:
 optional; will not be displayed
Don't put anything in this field:
 optional
Don't put anything here:
Leave this empty:
URLs auto-link and some tags are allowed: <a><b><i><p>.