Mounting a CF card via PCMCIA adapter

Posted by int0x80 on Thu 15 Jun 2006 at 09:19

This article details the steps taken to transport photos from the compact flash card of my camera onto one of my systems for archival and display.

Both systems are running Debian GNU/Linux, one with a 2.6.11.6-grsec kernel, the other with a 2.6.10-grsec kernel. The actual kernel build is most likely inconsequential as long as you can access your PCMCIA devices.

[0x01] Hardware

We are equipped with the following hardware:

Additionally, my camera is a Canon PowerShot S400 (not that it matters).

[0x02] Kernel modules

The kernel config was modified like so for this situation:

Bus options (PCI, PCMCIA, EISA, MCA, ISA)  --->
	PCCARD (PCMCIA/CardBus) support  --->
		 CardBus yenta-compatible bridge support
		 Cirrus PD6729 compatible bridge support
		 i82092 compatible bridge support
		 i82365 compatible bridge support
		 Databook TCIC host bridge support 

Device Drivers  --->
	ATA/ATAPI/MFM/RLL support  --->
		 PCMCIA IDE support

File systems  --->
	DOS/FAT/NT Filesystems  --->
		 VFAT (Windows-95) fs support
		(437) Default codepage for FAT
		(iso8859-1) Default iocharset for FAT
		
	Native Language Support  --->
		(iso8859-1) Default NLS Option
		 Codepage 437 (United States, Canada)

Note these are being built as modules. You may need to run some additional commands or modify some files to load them at boot based on your distribution.

Running the following will build the modules and install them:

bash# pwd
/usr/src/linux
bash# make modules && make modules_install

Debian users should probably use make-kpkg to build the kernel and modules and end up with a .deb file.

[0x03] Filesystem

Now you can pop your PCMCIA card in, and check dmesg.

bash# dmesg
cs: memory probe 0xa0000000-0xa0ffffff: clean.
Probing IDE interface ide2...
hde: SanDisk SDCFB-512, CFA DISK drive
ide2 at 0x100-0x107,0x10e on irq 3
hde: max request size: 128KiB
hde: 1000944 sectors (512 MB) w/1KiB Cache, CHS=993/16/63
hde: cache flushes not supported
 /dev/ide/host2/bus0/target0/lun0: p1
ide-cs: hde: Vcc = 3.3, Vpp = 0.0
 /dev/ide/host2/bus0/target0/lun0: p1
 /dev/ide/host2/bus0/target0/lun0: p1

So we see that the device is being recognized as /dev/hde. Let's see which device we really want to mount:

bash# ls /dev/hde*
hde   hde1

Alright, /dev/hde1 it is. Easy enough. Let's make a mount point:

bash# mkdir /mnt/cf

And finally here is the line to append in /etc/fstab:

bash# grep 'hde' /etc/fstab | uniq
/dev/hde1 /mnt/cf auto defaults 0 0
[0x04] Mount

Now let's mount this card already.

bash# mount /mnt/cf
bash# grep 'hde' /proc/mounts
/dev/hde1 /mnt/cf vfat rw,nodiratime,fmask=0022,dmask=0022,codepage=cp437,iocharset=iso8859-1 0 0
bash# du -chs *
475M    dcim
8.0K    misc
475M    total

It appears my images are stored in the /mnt/cf/dcim/ directory. This probably varies based on the camera manufacturer and model. But using du and other commands should be able to give you a good idea of where things are.

[0x05] Transfer

Now we're going to move the pictures to another system. We'll do it over SSH,except we'll use Konqueror and fish so that we can just drag & drop. Load Konqueror, then in the address bar, enter your credentials.

fish://david@172.17.10.122

Then open another tab and go to your compact flash mount (/mnt/cf). Now you can simply highlight the pictures you want to transfer, and drag them to the other tab in Konqueror.

Don't forget to umount /mnt/cf when you're done!

[0x06] Closing thoughts

There were two major (in speaking relatively) stumbling blocks for me in this process.

First, I couldn't get my laptop to recognize the SanDisk PCMCIA CompactFlash PC Card Adapter. This was rectified by building PCMCIA IDE support as a kernel module.

The other problem was an error with the codepage when I'd try to mount the adapter. This was solved by adding NLS (Native Language Support) to the kernel, then building the Codepage 437 (United States, Canada) kernel module. Overall though, fairly simple and straightforward process.

[0x07] Credits

Thanks to Academic Underground. Also thanks to macabre for the PC Card Adapter and for showing me the Konqueror + fish trick to easily transfer the images.

David
int0x80.com


This article can be found online at the Debian Administration website at the following bookmarkable URL:

This article is copyright 2006 int0x80 - please ask for permission to republish or translate.