This site is now 100% read-only, and retired.

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 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:

  • Dell Latitude laptop
  • SanDisk 512 MB CompactFlash card
  • SanDisk PCMCIA CompactFlash PC Card Adapter

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
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.


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.




Re: Mounting a CF card via PCMCIA adapter
Posted by mcphail (62.6.xx.xx) on Thu 15 Jun 2006 at 10:53
You know, you could borrow my USB cable...

[ Parent ]

Re: Mounting a CF card via PCMCIA adapter
Posted by rob (72.192.xx.xx) on Thu 15 Jun 2006 at 17:48
[ View Weblogs ]
Kind of reminds me of the bad ol' days when I had to download pictures from my Olympus camera via serial cable and gphoto ,which was the only option I had at the time.

I finally got a usb multi(6)-card reader , enabled scsi support, scsi emulation and scsi disk support via modconf, of course. When I insert a media card type I haven't mounted before I check cat /proc/scsi/scsi to see on which of the 6 'disks' it is mounted, make a directory for the card under /mnt (/mnt/cf) and make it permanent in fstab (/dev/sdc1[the 'c1' part being the diskletter/number from proc] /mnt/cf auto user,noauto 0 0). Then I just copy the pictures from the mounted disk to a directory: cp /mnt/cf/bla-bla/.jpg ~/rob/pictures/.

[ Parent ]

Posted by Anonymous (70.26.xx.xx) on Fri 16 Jun 2006 at 13:00
If you have udev you don't need to bother with the dmesg step since the device will always be named the same thing. The named devices are in /dev/disk/by-id/ and will be named using the unique id obtained from the device.

This is what I have in my /etc/fstab:

/dev/disk/by-id/usb-Generic_STORAGE_DEVICE_0103112941-part1 /mnt/flash vfat user,noauto 0 0

There is also a way to have udev automatically generate mount rules and mount points in /media, but I have not done it. I think this used to be done by hotplug, but was recently moved to udev's domain.


[ Parent ]