UNIX / Linux keyboard.

Digital Cameras, Linux, and BSD

Using Your Digital Camera

How to use your
Samsung Galaxy
Android smart phone
with Linux and BSD

Attach the camera to the USB port, verify that it's seen

The kernel should detect the USB device.

On Linux, lsusb should display a line showing the device.

On OpenBSD, use usbdevs.

With either command, add the -v option for verbose output and many more details.

Linux% lsusb
Bus 003 Device 003: ID 046d:c404 Logitech, Inc. TrackMan Wheel
Bus 003 Device 002: ID 051d:0002 American Power Conversion Uninterruptible Power Supply
Bus 003 Device 001: ID 0000:0000
Bus 004 Device 006: ID 04cb:01d2 Fuji Photo Film Co., Ltd
Bus 004 Device 003: ID 05e3:0760 Genesys Logic, Inc. USB 2.0 Card Reader/Writer
Bus 004 Device 001: ID 0000:0000
Bus 002 Device 005: ID 045e:00db Microsoft Corp. Natural Ergonomic Keyboard 4000 V1.0
Bus 002 Device 004: ID 03f0:5511 Hewlett-Packard
Bus 002 Device 001: ID 0000:0000
Bus 001 Device 001: ID 0000:0000 
OpenBSD% usbdevs
addr 1: EHCI root hub, Intel
 addr 2: 802.11 n WLAN, Ralink
addr 1: EHCI root hub, Intel
 addr 2: USB PTP Camera, Fuji Photo Film
addr 1: UHCI root hub, Intel
addr 1: UHCI root hub, Intel
addr 1: UHCI root hub, Intel
addr 1: UHCI root hub, Intel
addr 1: UHCI root hub, Intel
addr 1: UHCI root hub, Intel 

usbview may provide a detailed graphical user interface for examining USB devices.

Fuji FinePix digital camera with USB cable.

Fuji FinePix digital camera with USB cable.

Use the device

There are two entirely different methods of data storage on digital cameras:

If your camera behaves as a mass storage device, it will appear as a SCSI disk. Mount it with something like the following:

% mount /dev/sda1 /media/camera 

The device will be something like /dev/sd0i on OpenBSD.

How can you tell what the device name is? It will probably be the first partition of some SCSI/SATA device, but how do you get the specific name? If you can't just guess, on Linux you could ask for your partition tables as root:

# fdisk -l 

You could also see what the kernel has recently noticed:

% dmesg | grep 'sd[a-z]' 

How can you allow an ordinary user to mount removeable file systems? Specify this in /etc/fstab:

% grep media /etc/fstab
/dev/sda1  /media/camera  auto  user  0  0 

If, on the other hand, your camera uses PTP, as seems more common on newer cameras, use some user-space tools.

The Konqueror browser part of the KDE desktop, understands PTP. Just bring up a Konqueror browser and change the location to camera:/

That should let you browse the camera's storage. The URL ends up being something like this:

camera://USB%20PTP%20Class%20Camera@[usb:004,006]/store_10000001/DCIM/101_FUJI

Of course, that 004,006, indicating USB bus #4 and device #6, will depend on where you attach your camera. See the lsusb output above for how you can figure out in advance what this will be.

However, Konqueror will give give you icons to click on:
USB PTP Class Camera, then
store_10000001, then
DCIM, then
101_FUJI (or however your camera identifies itself).

To download the pictures from the command line, simply use:

% cd /path/to/desired/storage/area
% gphoto2 -P 

See the gphoto2 manual page for far more.

Recover Deleted Images

recoverjpeg is a very nice tool. Get it from rfc1149.net or from free(code).

If your camera works as a USB mass storage device, you can simply find its device name (it will appear as if it were a SCSI or SATA disk, use fdisk -l to figure out its name). Then you can image the camera's memory into a file, and extract images from there:

$ cd
$ dd if=/dev/sdb of=camera-image bs=1M
$ recoverjpeg camera-image 

Or you could simply recover the JPEG image files directly, there is no real need to save an image of the camera's memory:

$ cd
$ recoverjpeg /dev/sdb 

If, on the other hand, your camera uses the Picture Transfer Protocol, or PTP, then as far as I know you will have to put the memory card into a reader so it appears as a USB mass storage device. I don't think there's a way of using the PTP interface to directly access or copy the memory. See the gphoto2 manual page for far more, maybe there's a way to image or directly access the memory.