[Home]Install To CompactFlash

LinuxCNCKnowledgeBase | RecentChanges | PageIndex | Preferences | LinuxCNC.org

Showing revision 2
Difference (from revision 2 to revision 2) (minor diff, author diff)
(The revisions are identical or unavailable.)

Installing to a CompactFlash solid state drive

CNC machines operate in a harsh environment often with vibration, damp and severe temperature swings so hard drives have a tendency to fail. Nowadays decent size CompactFlash cards are pretty cheap. CF cards can be used as hard drives with the aid of a simple and cheap adapter. This page was created 12/23/08 and as technology changes, parts of it may go out of date.

1.1. Selecting a CF to IDE adapter

Not all adapters are made equal. Older CF cards can't handle DMA and UDMA so many adapters don't have the extra two DMA lines connected. Using a later card in a non-DMA adapter usually results in the Linux kernel crashing as it tries to mount the card. An earlier card will work fine in a dma adapter. If you have a very fine soldering iron and good eyesight it is possible to convert an older adapter but it is hard work and not usually worth the effort. When you buy the adapter, make sure it is DMA compatible. If it doesn't say it is, it probably isn't. If you don't have a spare IDE slot you can also get CF to SATA adapters. As far as I know all SATA adapters can handle DMA.

1.2. Selecting a CF card

Get a good quality card by a known brand and from a reputable supplier. Preferably get one with a speed of 100x or greater. Beware of eBay cards as a lot of them are fake. Probably 90% of Sandisk cards on eBay are fakes. They tend to be a lot slower than advertised and are often unreliable. Some are actually much smaller cards that incorrectly report their size. A full install of Ubuntu 8.04 takes around 2.5GB so 4GB is an ideal size.

1.3. CF advantages and disadvantages

CF cards have a few limitations. Their write speed is noticeably slower than hard drives and they have a limited number of write cycles. Internally the cards are divided into blocks. Each block can only be written a limited number of times before it starts to fail. The card firmware will automatically spread these writes around spare blocks to even out wear but if you keep writing to the card you will eventually wear it out. However by changing a few settings we can drastically reduce the number of times Linux writes to the card. A life of 15+ years should be easily achievable. CF cards have very low access times so reading small files is much faster than a hard drive. For this reason, CF based systems tend to boot very quickly.

1.4. Swap file

To swap or not to swap. When Linux starts to run out of memory it tries to shift unused data onto the hard drive. This is called swapping. A normal Linux installation uses a fairly large swap file and on systems with limited memory it can write to the file on a regular basis. This is obviously not what we want. One solution is not to use swap space. This is fairly obvious and if you have 512M or more it works well. However if you do run out of memory, Linux will grind to a halt. Not ideal for machine control. If you have less than 512M you will probably have to have a swap file. If you are really paranoid you can install a hard drive just for the swap file but it rather defeats our aim for reliability and no moving parts.

1.5. Installation methods

There are two ways of installing Linux on a CF card. The first is a standard hard-drive install. The CF card is used just like an ordinary hard drive. The disadvantage is that you will write to the card more often and it takes up quite a lot of space. Another method is to effectively copy the live CD onto the card. It will then boot as a read-only drive just like the live CD. I won't describe this method as it is quite complex and you cannot then easily upgrade. Some distros such as [DamnSmallLinux] have automated installers to do this but they don't support emc.

1.6. Installing EMC on your card

Right, let's install Ubuntu on a card. Fit the card in it's adapter and plug it into the computer in place of the hard drive. Some adapters plug into a hard drive cable and some plug directly into the motherboard. I personally prefer to plug directly into the motherboard but it doesn't really make much difference. Stick your Ubuntu live CD in the CD drive and boot the computer. When the boot menu appears, select 'Install Ubuntu'. If the computer then drops into an emergency shell with lots of cryptic messages, you probably have an adapter that doesn't support DMA. The only solution is to replace it.

Once Ubuntu starts up you will be asked to enter your locale and keyboard type. Next it will ask you if you want to partition the drive. If you have less than 512M of RAM then use the 'Guided - use entire disk' option. This will set up some swap space. If you have 512M or more, select the manual option. To manually set up a partition, first delete any existing partitions then create a new partition. Set the file system to Ext3 journaling file system and the mount point to / . Click on OK then Forward. You will now have to answer a few questions about your login details. Once the installation has completed, take out the CD and reboot the computer. If all goes well the computer should now boot into Linux. However we aren't finished yet. Normally Linux stores a number of temporary files on the hard drive. We don't want to do that so we need to move them onto a RAM drive. This way we can drastically reduce the number of writes to the card.

Run a terminal (Applications->accessories->terminal) and enter this:

sudo gedit /etc/fstab

You will then need to enter your password. In fstab you should see a line something like this:

UUID=8037fd09-ea0d-4c28-a348-1fbdf9fb0b92 / ext3 relatime,errors=remount-ro 0 1

Add the noatime option. Normally every time you read a file, the time is written back to the drive. The noatime option disables this.

UUID=8037fd09-ea0d-4c28-a348-1fbdf9fb0b92 / ext3 relatime,noatime,errors=remount-ro 0 1

Now add the following lines. They move most temporary files to a ram disk.

tmpfs /tmp tmpfs defaults,noatime 0 0

tmpfs /var/run tmpfs defaults,noatime 0 0

tmpfs /var/log tmpfs defaults,noatime 0 0

tmpfs /var/lock tmpfs defaults,noatime 0 0

tmpfs /var/tmp tmpfs defaults,noatime 0 0

tmpfs /var/lib/dhcp3 tmpfs defaults,noatime 0 0

If you use Firefox a lot, you may want to move it's cache to ram as well. Your fstab line will look something like this:

tmpfs /home/les/.mozilla/firefox/vkuuxfit.default/Cache tmpfs defaults,noatime 0 0

Save the file and reboot. You should now have a fully working system that only does the absolute minimum of writes to the card.


LinuxCNCKnowledgeBase | RecentChanges | PageIndex | Preferences | LinuxCNC.org
This page is read-only. Follow the BasicSteps to edit pages. | View other revisions | View current revision
Edited December 23, 2008 1:17 pm by LesNewell (diff)
Search:
Published under a Creative Commons License