Deepgeek.us

Some kinda weird interweb geek playgound

Running Linux on Compact Flash


versions of this podcast
Download Podcast audio format OGG MP3Speex
External Link:Wikipedia Article on Compact Flash

So, what is CompactFlash, which I will also refer to as CF, since it is kinda their trademark. Well, CF is a form of flash media, you know, like what some people call a thumb drive, or sometimes a pen drive. What makes CF different from thumb drives is that on the inside of the CF card, it is like an ATA disk drive. This makes it easy to use it as computer disk drive with inexpensive adapters. Another difference is the speed, which is to say, in a word, faster. So, what we are talking about is using a fast thumbdrive-like media as a disk on our computer to make things go faster.

So lets talk about something we all have in our computers, which is a disk hard drive. You might ask yourself, aren’t these fast media? They plug right into the motherboard for speed, don’t they? Well, yes, they are fast, and they have a very high rate of transfering data to the motherboard, once they get at it.

Diagram of Rotational Delay

You see, there are three things that cause time delay in a hard disk, and they are head seek time, which is the time it takes for the disk head to move. Rotational delay is the second one, this is how long it takes for the data on the disk platter to rotate into position under the disk head. The third is the transfer to the motherboard. This is why “enterprise disks” have faster heads, smaller and more platters, and higher rotational speeds.

So it is a little disconcerting to experiment with this technology, and find that a fast flash chip that can put out data at say 45mbs can beat a disk drive that can transfer data in bursts of 300mbs, but that is a burst, not the average. It turns out that if you eliminate the seek time, and eliminate the rotational delay, which is what you do when you eliminate moving parts by going to flash chips, that you can get more speed out of the flash media.

Is this a panacea? No, with that speed comes cost. When you begin shopping for CF with specific speeds, the fastest speeds go for about $10/gigabyte. Nice thing is that you can get a two gig CF card for $20. I also priced a fast solid state drive, and at 64 GB it was a little over $600, and I also found a 16 gb CF card for about $160. Interestingly enough, while researching for this episode, I got an ad in the mail for a thumb drive from tigerdirect.com, and it talked a lot about the speed of the port of a 64 gb thumb drive. I knew that 64gb should be much more than that, and saw through the ad copy.

Now a good chunk of our listenership at HPR is in the know about linux, and this is something that the Windows crowd is just left out of. As you may know, windows wants to be on one disk, and that disk certainly should not be a 2 GB disk. However, with Linux, you can get kinda surgical about what goes where on which disk. Getting all the boot time stuff, and your software onto two gigabytes is quite doable in Linux.

So, lets get a little specific about the advantages. I have a Western Digital disk with an average seek time of 20 ms. Now it used to take me six seconds to kick off firefox, now it takes me two. Some screens I used to see a flash of I don’t see any more. For example, logging into the computer, there used to flash a “successful” between the login and the window manager kicking in. Now that I don’t see any more. Lastly, I find that mousing around the menu system feels a lot more sensitive, because everything is just quicker.

[info in the next paragraph was not in the original podcast

Another benefit I did not mention in the podcast is the highly portable nature of the medium. Kevin Mitnick told a story once on the “Off The Hook” radio show about having his computer searched at customs coming into the United States. He had Splashtop on his computer system (a ROM-based instant on linux) and customs agents looked thorugh that installation, missing a CF card he had elsewhere in his laptop luggage. I’m an old fan of Cyberpunk literature, and the images from “Johnny Mnemonic” about data smuggling filled my head. I made sure to photograph with a dollar bill for sake of scale for this article, so you could get a feel for the size of the device.

So what is the nature of flash media? Well, first of all it is chiefly limited by the number of writes. Basically 100,000 writes before a portion of the memory dies. But reading is unlimited. Interesting to note that CF, when it fails, fails on the write. This is contrasted to disk drives, where the write goes through, and the subsequent reads can fail. I talked a lot about speed, and flash media is rated just like your CD drive. You know, 52x as a speed. Well, to compete with hard disks, we need to buy the fastest CF media we can, which is 300x speed. This is about 45mbps.

Enough theory, let’s get into how to do this. First let’s talk converters. The converter will be the go between your CF card and the disk bus on the motherboard. The exception will be if you are building a new computer, in which case you can get a motherboard with a CF card reader on the motherboard. I chose a startech.com model that where you can easily change the card either in the rear of the case or in the front in a panel that fits into a floppy slot. Mine plugged into the SATA bus. The startech.com model also comes in a ide model. It takes it’s power from a floppy power cable from the power supply. It’s a matter of screwdriver turning. Now there are some cheap IDE converters that stand up in an ide slot on your motherboard, they are priced really cheap and you would have to open the computer case to change the card. The cheapest of these support only the old PIO mode of data transfer, avoid this, you want the faster UDMA support. lastly, there are also special converters with the form factor of a laptop hard drive, for those of you who might want to replace your laptop drive with this. BTW, I haven’t tried it, but these cards should use less power than a disk drive, you might get more batter life on a laptop with this technology.

Converter as shipped

Converter unpacked

Convertor and CF card on original expansion slot

CF inserted in convertor

Convertor in floppy disk enclosure

I bought a slow memory card with the converter, then I went to a memory specialist called memoryx.net and got the proper 300x card. It is a major difference.

After opening the case, twisting scredrivers and plugging in plugs, it was installed.

The hardware is the easy part, lets talk about installing Debian Linux on this. You can use a linux of your choice of course, but the manual debian installer gives me complete control, you may have to install, then change settings manually in your /etc/fstab file.

For the purposes of this installation, we are going to need a root partition, a /usr partition, a /var partition, and a special partition I call /home2. Here is the rational

Since it is the number of writes that shorten the life of this media, we are going to put all the data files and all the log files on a regular hard disk. Now I really like this so down the road I might get a 16 gig CF card and fire my hard disk, but the jury is still out on that, I want the read-only files on CF. I created a 500 megabyte root directory on the CF card. This root partition has a standard /home directory. I wanted to keep this for an important reason, I want all those personal configuration files to be on that CF disk for fast access. I make a /home2 on my hard disk for my data, all my videos, oggs, etc. It only takes a little getting used to. I also put the /var on a hard disk, as well as a swap on the hard disk. This puts my frequently writable files on the hard disk.

Here is an example /etc/fstab file

# /etc/fstab: static file system information.
#
# proc /proc proc defaults 0 0
/dev/sdb5 / ext2 noatime,errors=remount-ro 0 1
/dev/sda10 /home2 ext3 defaults 0 2
/dev/sdb6 /usr ext2 noatime 0 2
/dev/sda7 /var ext3 defaults 0 2
/dev/sda9 none swap sw 0 0

The software directory, /usr, I created as a 1.5 gig partition on the CF card. My software is about a gig, so I have a little play room. If you need more, you can use the squash filesystem to compress it. You would have to have a bigger, like three gig partition on your hard disk, and then make a squash of it, and use the “DD” command to copy it onto the CF disk. If you want to check the size of your current /usr, you can use the command “du” to find out it’s size. Now I have to do an aside here, you guys know I do the lightweight apps series. I found that I absolutely need to have firefox, Konqueror, and k3b. Now those last two, bring in a lot of the kde environment with them, so in some cases some dependencies of other KDE apps are already satisified. This means that to have a small system, I chose heavier KDE apps in some cases where other lightweight apps would have used more disk space with their dependencies than a kde app sharing a dependency with Konqueror or k3b. (wow, that was a long geeky sentence.)

With the standard debian installer, you can choose this partition scheme all on the install (except if you need squash filesystem.) Now with each of CF disk partitions you choose the the ext2 over the ext3 filesystem. You do this because you are setting up mainly to read, and jorneling is just not needed. Jounaling also increases the writes to the media, undesirable here. For the same reason you set the mount option called “noatime.” Every time you use a file, Linux updates atime- the last access time, we just don’t need to do this writing to the CF disk.

Then it is a matter of letting the installer finish the install and you can enjoy your new faster system.

I have to acknowledge Klaatu’s series “the Bad Apples,” as a heavy influence on this episode. In the episodes where he discusses Splashtop, a on motherboard linux that ASUS motherboards have, and the File Hierarchy Standard, I could see the path of research needed to pull this off. Shouts to Chung of Nextech systems also.

deepgeek.us