| HOME > MISC > LINUX > DIGITAL CAMERA |
|---|
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:
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 :
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:
Before you continue make sure to:
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 :
It is known to NOT work with the following cameras:
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.
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.
/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.
# 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.
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
daajaa
22-Feb-2006 11:03
Certains cameras are not working with 2.6.x with x<=12, but which worked with 2.6.0-test11 and 2.4.xx with xx<=23. This is all about the usb-storage mount, on various linuxes (SuSE, gentoo, debian, mandrake ...)
Here is a list I gathered (not complete) :
DMC-LC40 ('MATSHITA:DMC-LC40:0x3000' Panasonic DMC-LC40), Nikon Coolpix 2000 (NIKON DSCE2000:0:0:0p1), Panasonic DMC-LC33, Canon Rebel 300D, Argus DC3200, HP Photosmart 720 USB (HP Model: PhotoSmart M407), Sony Mavica CD-1000 (SONY Model: DSC DDX-G2000), LEICA Model: Digilux 1.
The cause may be the misinterpretation of the command "SCSI_REMOVAL_ALLOW" by these cameras : they power off their SD-card instead of the normal action. Then, when asked for the card, the usb-storage module relay this unavailability with the message "mount: No medium found", hard to debug.
There is a patch for linux-2.6.x/drivers/scsi/sd.c skipping this command, at
http://www.mail-archive.com/linux-usb-devel@lists.sourceforge.net/msg18614.htmlhref="http://www.mail-archive.com/linux-usb-devel@lists.sourceforge.net/msg18614.html">http://www.mail-archive.com/linux-usb-devel@lists.sourceforge.net/msg18614.html> from Alan Stern.
===== sd.c 1.59 vs edited =====
--- 1.59/drivers/scsi/sd.c Fri Oct 24 14:53:37 2003
+++ edited/drivers/scsi/sd.c Tue Jan 6 11:16:41 2004
@@ -431,8 +431,10 @@
goto error_out;
if (!sdkp->openers++ && sdev->removable) {
+#if 0
if (scsi_block_when_processing_errors(sdev))
scsi_set_medium_removal(sdev, SCSI_REMOVAL_PREVENT);
+#endif
}
return 0;
@@ -462,8 +464,10 @@
SCSI_LOG_HLQUEUE(3, printk("sd_release: disk=%sn", disk->disk_name));
if (!--sdkp->openers && sdev->removable) {
+#if 0
if (scsi_block_when_processing_errors(sdev))
scsi_set_medium_removal(sdev, SCSI_REMOVAL_ALLOW);
+#endif
}
Other versions of this patch can be found on :
http://forums.gentoo.org/viewtopic.php?t=120038&highlight=2+6+usb+camera (for kernel linux 2.6.3-r1, said to work on 2.6.x with x<6)
http://marc.theaimsgroup.com/?l=linux-usb-devel&m=107325816324195&w=2 (same as above shown patch)
http://www.mail-archive.com/linux-usb-devel@lists.sourceforge.net/msg18571.htmlhref="http://www.mail-archive.com/linux-usb-devel@lists.sourceforge.net/msg18571.html">http://www.mail-archive.com/linux-usb-devel@lists.sourceforge.net/msg18571.html> (early version of this patch).
Phil
10-Jul-2005 13:31
Sony DSC-W12 (DSC-W1 with black case) with Slackware 10.1 (current June 20th) and 2.6.12 kernel. Only had to compile SCSI into the kernel.
H C Grant
29-Jun-2005 08:11
I use MDK10.2 and I added the following line to fstab :
>> none /mnt/camera supermount dev=/dev/sda1,fs=auto 0 0 <<
This brings up a folder on the desktop named "camera" which,if I open after connecting and then switching on the camera, displays the photos. The camera is a Fujifilm S5000.
Joe Fenton
24-Jun-2005 15:18
I'm using a Vivitar ViviCam 3715 in Fedora Core 3 with the 2.6.11 kernel. The camera memory automatically mounts on the desktop. Just plug it into the USB, turn on the camera, and the memory pops up on the desktop. Just copy the images, then turn off the camera and the memory automatically dismounts. It's really easy and convenient.
slack---line
19-Jun-2005 15:58
thank you, a v.useful howto.
This method (with a bit of tweaking as described by collin (23-March-2004)) worked fine for the Casio EX-S100 under gentoo (see details below of tweaks).
$ uname -R
2.6.11-gentoo-r5
$cat /etc/fstab
/dev/sdb1 /mnt/usb vfat auto,owner,users 0 0
(/mnt/usb and the above entry already existed for a flash drive).
I added autofs to start on boot by...
$ rc-update add autofs default
...and the results from dmesg are...
$ dmesg
usb 4-1: new full speed USB device using uhci_hcd and address 15
usb 4-1: configuration #1 chosen from 2 choices
scsi13 : SCSI emulation for USB Mass Storage devices
usb-storage: device found at 15
usb-storage: waiting for device to settle before scanning
Vendor: Casio Model: QV DigitalCamera Rev: 1000
Type: Direct-Access ANSI SCSI revision: 02
SCSI device sdb: 124160 512-byte hdwr sectors (64 MB)
sdb: assuming Write Enabled
sdb: assuming drive cache: write through
SCSI device sdb: 124160 512-byte hdwr sectors (64 MB)
sdb: assuming Write Enabled
sdb: assuming drive cache: write through
sdb: sdb1
Attached scsi removable disk sdb at scsi13, channel 0, id 0, lun 0
Attached scsi generic sg1 at scsi13, channel 0, id 0, lun 0, type 0
usb-storage: device scan complete
Thanks again for the article, and for your posts collin.
slack---line
maddox
13-Jun-2005 20:03
this works great with Ubunto Hoary, kernel 2.6.10 and my Benq DC S40 Digital Camera. Thanks a lot for the tip!!!!
vino
14-Feb-2005 00:06
one more thing, I don't have any /dev/sda
vino
14-Feb-2005 00:03
I have an S30 and Gentoo 2004.3 with Linux 2.6.9
When I plug in the camera to USB, it turns on, which I take to be a good sign. However lsusb returns nothing.
I have this from dmesg:
root> dmesg | grep usb
usbcore: registered new driver usbfs
usbcore: registered new driver hub
usbcore: registered new driver usb-storage
any ideas?
tomas
30-Jan-2005 09:23
Worked fine for my Minoltra X20/Slackware4 Linux 9.1 config. To.
The non-chalant
23-Dec-2004 23:45
I use Gentoo Linux (kernel 2.6.9) and ur procedure works great with Nikon 2500. Thanks.
CR
14-Nov-2004 00:09
Your procedure works fine with my Fuji A205 ?on Debian Woody, bf2.4 kernel, with one slight modification:
I kept getting ?"/dev/sdax is not a valid block device" ?- ?reason was that
the usb-storage module wasn't loaded.
My complete basic procedure (that works) is:
Connect Fuji A205 into USB and switch it on
(In a terminal window): ? ?su to root
/sbin/modprobe usb-storage
mount /dev/sda1 /mnt
(images appear as files in /mnt/dcim/100_fuji - copy in the normal way)
When finished: ?umount /mnt
Switch off A205 & unplug
(I'll worry about refinements like automounting and file permissions later)
keltik
10-Nov-2004 19:17
It works quite fine on Debian Sarge // kernel 2.6.9 and a Benq DC C40.
Thanks a lot!
Simon Bridge
10-Nov-2004 16:50
Method unsuccessful with Sony DSC P-73
Same system OK with P-32
Only difference from the P-72 is the "memory stick pro" bit.
What is memory stick pro? How is it sifferent from the normal memory stick?
Simon
igghibu
10-Nov-2004 11:43
YOPER with 2.6.8.1 kernel image
Fujifilm Finepix F700
A piece of cake
Still have to try the supermount thing but i guess it'll be easy.
BTW I think you should speciffy to use the -o option with the mount command to be able to have the right permissions for the everyday user. i.e. (my specific case)
su -
<$password>
mkdir /mnt/finepix
mount -o uid=1000,gid=100 /dev/sda1 /mnt/finepix
THX & Cheers.
Jay
25-Sep-2004 21:26
My system didn't automatically recognize my camera, then I found your page and now everything is happiness! :-)
I have: Konica-Minolta Dimage Z3 (z-three)
I'm running SuSE 9, kernel 2.4.21-243-athlon
Thanks!
Jake
13-Sep-2004 18:39
Sony DSC-S30 works fine using this method, with Debian Sarge (kernel 2.4.26). Mounts as /dev/sda1 on my system (no other usb storage devices installed).
subbu
12-Sep-2004 13:22
I am using Kodak Dx6490 on RH9. I am able to use gtkam as root and copy the images. But, I am unable to find the device. I went from sda1 to quite a distance before I got irritated.
Andrew
04-Sep-2004 22:20
Hi, my Samsung DigiMax V4 worked fine with the USB Mass storage driver, although when it comes to mounting it I have to provide the filesystem type, I found this is only on certain distros, but it is most often vfat.
Gibran
23-Aug-2004 18:34
I have this message:
Aug 13 21:09:14 localhost /etc/hotplug/usb.agent: ... no modules for USB product 54c/4e/150
My camera model is sony DSC-P32 .
Jonathan
21-Aug-2004 12:42
I had trouble getting 2.6 to work where 2.4 was jsut fine. It turned out I had to compile and modprobe sr_mod
Jan Fader
14-Aug-2004 21:29
Hi Folks,
I get my Sony DSC-S 70 to work.
Thank You
With kindly regards
John Wyles
16-Jul-2004 17:07
I have written a detailed HOWTO for getting your Sony DSC-W1 to work in Linux. Most of the information is rather obvious but is there just in case you need it. It can be found here:
http://www.johnwyles.com/archives/2004/07/16/sony_dscw1_in_linux.php
-John Wyles
Udayan
15-Jul-2004 11:53
hi
i tried the instruction but the out put of var log messages at my machine is very different.
Jul 15 22:19:01 localhost kernel: hub.c: new USB device 00:0b.1-2, assigned address 4
Jul 15 22:19:01 localhost kernel: usb.c: USB device 4 (vend/prod 0x54c/0x10) is not claimed by any active driver.
Jul 15 22:19:04 localhost /etc/hotplug/usb.agent: ... no modules for USB product 54c/10/450
then i tried the /dev/sda1 ,sdb1,sdc1 but in all the cases it give the error message that sda1,etc are not valid block devices.
please help me my camera model is sony dscP32 .
Jo Vark
30-Jun-2004 09:19
Hi,
I used your instructions to connect my Fuji Finepix S7000 to RH 9.0 and it worked great!
Leonardo Uribe
28-May-2004 13:37
Thanks for the help. Fuji Fine Pix S3000 works fine with these instructions. I use Knoppix v3.3 with the 2.4.24 kernel.
Truls SOEbstad
25-May-2004 06:01
My wife's camera: Minolta DImage X20, Secure Digital memory card. Vector Linux 4.0 (kernel 2.4.22). Works fine as usb mass storage device.
Had to enable usb-uchi and usb-storage in /etc/rc.d/rc.modules.
Created the directory /mnt/camera and made an entry in /etc/fstab to reflect this
/dev/sda1 /mnt/camera vfat noauto,rw,user 0 0
Changed permissions:
chmod 666 /dev/sda1
chmod 777 /mnt/camera
Mounted camera with mount /mnt/camera and the pictures was available (ls /mnt/camera).
This is briefly according to my "real" memory, which can appear unstable at times... (too much Windows XP I assume, muhaha) :-) :-)
Roger Browne
04-May-2004 15:53
Olympus mju 400 (also known as Stylus 400) using Fedora Core 1.
Worked fine - thanks for these instructions.
Christopher A. Shamis
29-Apr-2004 18:41
Everything works *FINE* in kernel 2.4, doesn't work at *ALL* in 2.6
Insert my card into the camera, attach camera to linux, and:
From the kernel 2.6.5 message log:
Apr 29 19:12:55 Ziggy kernel: usb 2-3: new full speed USB device using address 4
Apr 29 19:12:55 Ziggy kernel: scsi0 : SCSI emulation for USB Mass Storage devices
Apr 29 19:12:55 Ziggy kernel: Vendor: LEICA Model: Digilux 1 Rev: 0050
Apr 29 19:12:55 Ziggy kernel: Type: Direct-Access ANSI SCSI revision: 02
Apr 29 19:12:55 Ziggy kernel: SCSI device sda: 124161 512-byte hdwr sectors (64 MB)
Apr 29 19:12:55 Ziggy kernel: sda: assuming Write Enabled
Apr 29 19:12:55 Ziggy kernel: sda:<7>usb-storage: queuecommand called
Apr 29 19:12:55 Ziggy kernel: Attached scsi removable disk sda at scsi0, channel 0, id 0, lun 0
7:37pm /root# mount /dev/sda1 /mnt
mount: No medium found
7:37pm /root# cat /dev/sda
cat: /dev/sda: No medium found
What happened to /dev/sda ?????? The kernel still thinks it's there, but when you try to read it, you get an error.
Adam Monsen
06-Apr-2004 13:27
Want your device to be automatically mounted when you plug in your USB Mass Storage device? Check this out:
http://www.buberel.org/linux/usb-automounter.php
I wrote this version based on info provided at the above link:
http://perlmonks.org/?node_id=343052
Collin
28-Mar-2004 17:39
I should amend the comment above to include an additional hoop I have to jump through. If I have used the camera previously without reloading the uhci-hcd module, I get something like the following in /var/log/messages after connecting the camera via USB:
Mar 28 08:56:15 freak drivers/usb/host/uhci-hcd.c: bf80: host system error, PCI problems?
Mar 28 08:56:15 freak drivers/usb/host/uhci-hcd.c: bf80: host controller halted. very bad
Furthermore, the camera won't mount. I then turn off the camera, reload the uhci-ucd module via
rmmod uhci_hcd
modprobe uhci_hcd
then turn the camera back on again and everything seems to work just fine. I have no idea why this is the case.
Collin
23-Mar-2004 16:24
I recently got a Sony DSC-P32 working under Gentoo with the 2.6.3-gentoo-r1 kernel. Thought I might relay a gotcha in case it's helpful to other Gentoo users.
I used genkernel to build the kernel and though usb-storage was compiled into the kernel via option
Device Drivers --> USB support --> USB Mass Storage support
the module was not loaded on boot. Without it I got a bunch of these in /var/log/messages:
drivers/usb/host/uhci-hcd.c: bf80: host controller halted. very bad
To get it working, I did a
modprobe usb-storage
then added the following line to /etc/fstab
/dev/sda1 /mnt/camera vfat user,noauto,umask=0 0 0
After a
mkdir /mnt/camera
I just needed to plug in the camera, turn it on, then
mount /mnt/camera
Without the line in /etc/fstab, you can just mount it with
mount -t vfat /dev/sda1 /mnt/camera
Then a simple
cp /mnt/camera/dcim/101msdcf/*.jpg .
got the pics over to my laptop.
mike
19-Mar-2004 00:46
I can mount and transfer files as root thus far, which is more than I could do before. I got as far as setting up the /misc and the config's.
Just dont quite understand how to restart the automounter. Is there something Im not reading correctly or do I do something different in the slackware 9.1 distrobution?
Ben
03-Feb-2004 22:49
Olympus E-20 connected just fine using your mount/umount process.
Too a while to move 200 megs of images, but it did it... :)
Thanks for posting this. I had no idea where to even start. This was easy.
Ben
Rafael V. Aroca
19-Jan-2004 09:04
I have a Tron Digitron 200 that is compatible with Benq DC2300 , wich workeg great as a mass storage device.
Wally
14-Jan-2004 14:57
I have a vivicam 3340 and it works good as a mass storage device, but the other option on the camera under USB is 'PC Cam' . With that other O$, I could use this camera as a webcam. Baron wrote on Dec 30:
"This also works for HP PhotoSmart 812 but only after setting the USB config on the camera to "Disk" instead of "Camera"."
This must be the same feature as the vivicam, any idea how to make this work? All I know about it is the output is AVI.
Bora Okumusoglu
06-Jan-2004 16:28
Thanks to tips above, Sony P72 cam has connected to my FUJITSU notebook, which has Fedora installed on, via USB port.
Though the special Memory Stick slot, which is probably acting like a PCMCIA, is not working. I have such an message in /var/log/messages when I plug the M.S. in the slot:
kernel: udf: registering filesystem
kernel: UDF-fs: No VRS found
kernel: i8253 count too high! resetting..
Here is a photo of the slot:
http://www.fmworld.net/product/hard/pcpm0305/biblo_loox/nb/image/image05.gif
Anyway USB satisfies the need :) Thanks again.
Baron
30-Dec-2003 00:45
This also works for HP PhotoSmart 812 but only after setting the USB config on the camera to "Disk" instead of "Camera". This makes the camera look like a external hard drive to the computer. I believe most HP PhotoSmart cameras have this option and it should probably work on all other brands with the same feature.
Also, on RedHat 9, /var/log/messages does show the SCSI device it picks. In my case, it was sda1:
Dec 26 15:51:25 baron kernel: scsi1 : SCSI emulation for USB Mass Storage devices
Dec 26 15:51:25 baron kernel: Vendor: Model: Rev:
Dec 26 15:51:25 baron kernel: Type: Direct-Access ANSI SCSI revision: 02
Dec 26 15:51:25 baron kernel: Attached scsi removable disk sda at scsi1, channel 0, id 0, lun 0
Dec 26 15:51:25 baron kernel: SCSI device sda: 499713 512-byte hdwr sectors (256 MB)
Dec 26 15:51:25 baron kernel: sda: Write Protect is off
Dec 26 15:51:25 baron kernel: sda: sda1
Dec 26 15:51:29 baron /etc/hotplug/usb.agent: Setup usb-storage for USB product 3f0/4002/1
willdye
13-Dec-2003 22:20
The command "mount /dev/sda1 /mnt" worked for me.
I'm using a Vivitar ViviCam 3705, on a fresh install
of Red Hat 9 (even before doing up2date). I haven't
tried the automount system. 'Not sure yet if I want it.
--willdye, 2003/12/13
Anand Rangarajan
26-Nov-2003 14:07
Nikon Coolpix 4300 works fine with RedHat 9 (2.4.20-20.9 kernel). The device shows up as /dev/sda1 (since I don't have any other SCSI device) and can be mounted and the images copied. I have not yet tried autofs.
UnalienableBytes
24-Aug-2003 17:28
This works with a Vivitar ViviCam 3615 and Red Hat 9 after updating the kernel to Linux version 2.4.20-20.9 from Red Hat.
Please
E-mail Me with any
questions, comments or corrections.