HOME > MISC > LINUX > DIGITAL CAMERA
Quick Search:

Return to Quick Linux Tips

How To Connect a Digital Camera to Linux (v1.2)
Last modified: Monday December 10, 2018

This is a quick primer on how to connect a digital camera and download images from it using Linux. This technique has been tested with Red Hat 7.3, 8.0 and 9 and is likely to work with a variety of distributions. It's been reported to work with kernels as old as version 2.2.25.

These techniques only work if the camera uses the USB Mass-storage driver. Alternatively, if your camera uses Compact Flash (CF) and you have a laptop there is a very easy method to downloading your pictures which is almost the same, and documented below. Cameras known to work with this method over USB include the following:

It is known to NOT work with the following cameras: Cameras that don't directly connected to the USB port with the mass storage driver will almost always work with the gtkam  or gphoto2 programs included in most Linux distributions. You can always use a USB card reader to read from the card directly which works just fine as well. Please make a comment below if you know of other cameras that work or don't work.

Connecting your camera via USB

You can also use one of the handy USB card readers instead of your camera directly. In fact, that's the only way I download my photos any more.

When you do connect your camera it's important to make sure the camera is turned OFF when connecting it as well as turning the camera OFF before disconnecting the camera from your computer. I'm not sure why but the Linux USB driver gets really pissed off otherwise. If you connect your camera and turn it on you should get something resembling the following in your /var/log/messages :

Jan 22 17:21:23 localhost kernel: hub.c: USB new device connect on bus1/1, assigned device number 2
Jan 22 17:21:23 localhost kernel: usb.c: USB device 2 (vend/prod 0x4b0/0x106) is not claimed by any active driver.
Jan 22 17:21:26 localhost /etc/hotplug/usb.agent: Setup usb-storage for USB product 4b0/106/100
Jan 22 17:21:26 localhost kernel: Initializing USB Mass Storage driver...
Jan 22 17:21:26 localhost kernel: usb.c: registered new driver usb-storage
Jan 22 17:21:26 localhost kernel: scsi1 : SCSI emulation for USB Mass Storage devices
Jan 22 17:21:27 localhost kernel:   Vendor: NIKON     Model: NIKON DSC E775    Rev: 1.00
Jan 22 17:21:27 localhost kernel:   Type:   Direct-Access                      ANSI SCSI revision: 02
Jan 22 17:21:27 localhost kernel: USB Mass Storage support registered.
If your output looks like this then you're in good shape. The USB driver will set up "SCSI emulation" on the device. What's most annoying is that nowhere does it tell you which device name was chosen for this. If you don't have any SCSI devices other other USB mass storage devices the device to use will be /dev/sda1 . Otherwise go down the line with /dev/sdb1 , /dev/sdc1 , etc. until you find the correct device name. To find out try to manually mount the device as root:
# mount /dev/sda1 /mnt
# ls /mnt
dcim  misc  nikon001.dsc
# umount /mnt
Assuming you got this far, you'll want to set up an automatic way of getting to the camera without needing to log in as root and mount it. At this point I want to remind you that it's vitally important to unmount the device before turning off the camera. Also, remember that you need to turn off the camera before unplugging the USB cable.

What I like to use is the automounter for this purpose. I've also set this up for NFS mounts from other servers as well as my CD-ROM and floopy drives. If you haven't used the automounter yet you'll want to edit your /etc/auto.master  file and add the following line:

/misc   /etc/auto.misc  --timeout=30
Adjust the timeout value to suit your needs. My default of 30 seconds works for me. This is how long the automounter will wait before unmounting the device. If you set it too high you'll be waiting a long time before you can safely unplug your camera.

Before you continue make sure to:

# mkdir /misc
to create the special directory the automounter will look at. Then create the file /etc/auto.misc  and put in the following:
# This is an automounter map and it has the following format
# key [ -mount-options-separated-by-comma ] location
# Details may be found in the autofs(5) manpage

cd              -fstype=iso9660,ro,nosuid,nodev :/dev/cdrom
floppy          -fstype=auto            :/dev/fd0
camera          -fstype=auto            :/dev/sda1
Leave out the lines for the floopy and CD-ROM drive if you'd rather not have those devices automounted as well. Now plug in your camera then turn it on. Restart the automounter to load in your new configuration and try it out:
# service autofs restart
# ls /misc/camera
dcim  misc  nikon001.dsc
# chkconfig autofs on  (If you want to make this permanent)
If you set it up you can also test /misc/cdrom  if you have a CD loaded.

Reading CF cards with PCMCIA

An alternate way to download pictures from a digital camera is to use a PCMCIA adapter for your memory card. I know this works great with Compact Flash (CF) cards, I'm guessing it'll work similarly with other media interfaces.

In my experience this method is FAR more reliable. Unlike the USB mass storage driver this driver seems to be quite reliable in Red Hat 7.3, 8.0 and 9. The PCMCIA driver is also a little easier to use as when you plug the card into your laptop you'll get output like this in your /var/log/messages :

Jan 24 13:01:09 localhost kernel: hde: PQI ATA Rev6.0, ATA DISK drive
Jan 24 13:01:09 localhost kernel: ide2 at 0x100-0x107,0x10e on irq 3
Jan 24 13:01:09 localhost kernel: ide-floppy driver 0.99.newide
Jan 24 13:01:09 localhost kernel: hde: 256000 sectors (131 MB) w/0KiB Cache, CHS=1000/16/16
Jan 24 13:01:09 localhost kernel:  hde: hde1
Jan 24 13:01:09 localhost kernel: ide-cs: hde: Vcc = 3.3, Vpp = 0.0
Jan 24 13:01:09 localhost cardmgr[769]: executing: './ide start hde' 
Notice the hde1  in the output above, your device name may be different. That's the file name you will configre in the /etc/auto.misc  file as below:
camera          -fstype=msdos           :/dev/hde1
Once you do that just restart the automounter like you did for USB support above.
# service autofs restart
# ls /misc/camera
dcim  misc  nikon001.dsc
# chkconfig autofs on  (If you want to make this permanent)

Other Useful Resources

I realize most of these are about Red Hat 8.0 but in reality besides the kernel not that much has changed between 8.0 and 9.
Raw Digital Photo Decoding - This guy wrote a great little utility for converting the RAW digital format used by many digital cameras to the standard PPM format. I've used it to process the Canon CRW format and it works, but takes a little bit of playing with the settings to get the colors and brightness right. In my opinion it's almost not worth using the raw format.



Comments From People Like You!
Connect a Digital Camera to Linux
Add a Comment add a comment

Please E-mail Me with any questions, comments or corrections.
All pictures and text are the property of Gregory Gulik unless otherwise specified. Please contact site owner if you would like permission to use these pictures for your own purposes or to make comments about anything you see here.