Back to Homepage

Mounting an sd card with Linux

Having bought an hp49g+ in October of 2003 (from hp's website) I also bought a Panasonic 64Mb Secure Digital card to go with it, for $24. You can get a 128MB card for this price now. However, I had no sd card reader, so I bought one also, a singe-slot sd/mmc reader, for $10, since I had no other kinds of flash memory from cameras or other things. Almost any usb flash reader will work as long as it is Mass Storage Device compatible.

My hp49g+ recognized the sd card right away, and it worked great. After installing the driver for Windows 98, I was also able to read the card on a pc, and transfer files this way.

Then, since I am an avid Linux user (Slackware 9.0), I decided to make the card reader work for Linux, too.

First, you must make sure that usb is enabled on your box; add any necessary modules (usb will most likely be enabled already). You should have at least the 2.4 kernel. Then, you must load the usb-storage module (unless you have it compiled in your kernel). To load the usb-storage module, just type (as root) modprobe usb-storage. You should now be able to plug in the device and have it work properly.

Now, it would be helpful to add the device to the /etc/fstab to make it easy to mount our happy little sd card. My computer detects my flash reader as a scsi disk, /dev/sda, as Linux does with all flash memory. If you reboot with the flash reader plugged in, you can usually tell from dmesg which device it is detected as. Therefore, I added this line to my fstab:

/dev/sda   /mnt/sd   vfat   noauto,noatime,user   0  0

So I can just type   mount /dev/sda or   mount /mnt/sd to mount the sd card in /mnt/sd/. It is always a good idea to umount /dev/sda before removing the sd card. The entry noatime in my fstab is to prevent device fatigue (because sd cards don't last forever). Every time you would even do an ls on a directory, the file times would be updated, causing writing to the sd card. This is not desirable, because sd cards can only be written so many times; the noatime option prevents this writing.

NOTE: I have not really figured out why sometimes /dev/sda works, and other times it is /dev/sda1. My compact flash card mounts as /dev/sda1. I think that this has to do with your card, your reader, and your kernel version. You will have to experiment a little to make it work.




updated 20050214

1