Download your favorite Linux distribution at LQ ISO.
Go Back > Linux Answers > Hardware
User Name


By busbarn at 2004-02-12 23:45
USB Card Reader HowTo

The purpose of this howto is to provide step by step instructions for the newbie trying to get his/her usb card reader or zip drive working. I will be describing command line steps. None of these operations are gui oriented. In all of the following steps, "$" will represent the user prompt while "#" will represent the root prompt. If there is no $ or #, then that is what the output should be. This howto will be divided into three parts:
  • Kernel Configuration
  • Recon
  • Execution

These instructions should work with the 2.4.x and 2.6.1 kernels. The output that is posted in this howto is used with kernel 2.6.1. So open up your favorite terminal program and let's get started.

Kernel Configuration
There are two important things that need to be enabled in the kernel: usb and scsi support. USB is needed because, well, that's the way your plugging the drive into your computer. SCSI is needed because the kernel will see your usb drive as an scsi device.
The first step is to compile your kernel with proper support. NOTE: I am not enabling anything as modules. For the sake of simplicity, everything is enabled with a yes.
password:(enter root password here)
#cd /usr/src/linux
#make menuconfig
NOTE: You can use config, menuconfig, or xconfig.

Enable the following (bold titles are menu headers in menuconfig):
Device Drivers -------->
SCSI Device Support --------->[*] legacy /proc/scsi/ support
<*> SCSI disk support
<*> SCSI generic support
USB Support -------------->
<*> Support for USB[*] USB device filesystem
< > EHCI HCD (USB 2.0) support
< > OHCI HCD support
<*> UHCI HCD (most Intel and VIA) support
<*> USB Mass Storage support

If you have USB2, enable EHCI. Try UHCI before OHCI. If later on in this how to the usb doesn't work, go back and switch it.

Exit, saving your changes.
If you are using kernel 2.4.x, type the following:
#  make dep && make clean bzImage modules modules_install
If you are using 2.6, type the following:
#  make && make modules_install
Copy your new kernel image to your boot directory and change your grub or lilo setup accordingly.
#cp /usr/src/linux/arch/i386/boot/bzImage /boot/USB_drive_kernel
Reboot and proceed with step 2.

Now it's time to see if you configured your kernel properly. Make sure that your card reader is plugged in, preferably with a card in it. Once you are up and running, su into root again using your favorite console program. If you forgor how to do this, look back to step 1. ;)
First, lets see if the kernel sees your reader:
#  cat proc/scsi/scsi
Host: scsi0 Channel: 00 Id: 00 Lun: 00
  Vendor: CyberDrv Model: CW058D CD-R/RW   Rev: 100D
  Type:   CD-ROM                           ANSI SCSI revision: 02
Host: scsi1 Channel: 00 Id: 00 Lun: 00
  Vendor: PIONEER  Model: DVD-ROM DVD-116  Rev: 1.21
  Type:   CD-ROM                           ANSI SCSI revision: 02
Host: scsi2 Channel: 00 Id: 00 Lun: 00
  Vendor: General  Model: USB Disk Drive   Rev: 1.00
  Type:   Direct-Access                    ANSI SCSI revision: 02
If you have something that looks like this, then you are in business. If not, go back to step one and make sure that everything is configured properly. Looking at the purple text, you can see that the kernel sees the drive at scsi2. Good. Now let's see which device the kernel has attached the drive to:
#  dmesg
hub 2-0:1.0: new USB device on port 2, assigned address 2
scsi2 : SCSI emulation for USB Mass Storage devices
  Vendor: General   Model: USB Disk Drive    Rev: 1.00
  Type:   Direct-Access                      ANSI SCSI revision: 02
SCSI device sda: 493979 512-byte hdwr sectors (253 MB)
sda: assuming Write Enabled
sda: assuming drive cache: write through
 sda: sda1
Attached scsi removable disk sda at scsi2, channel 0, id 0, lun 0
Attached scsi generic sg2 at scsi2, channel 0, id 0, lun 0,  type 0
WARNING: USB Mass Storage data integrity not assured
USB Mass Storage device found at 2
If you can find something that looks like this with the dmesg command, then you are sitting pretty. This is not the only output of dmesg, so you will have to look through it to find what you want. This tells us that the kernel has assigned your usb drive to device sda1. Yours might say sda4, sdb1, sdc1, etc. Make note of what it says, your going to need it!

We need to make a directory in order to mount the drive. No, it isn't a horse.
# mkdir /mnt/USBdrive
#chmod 700 /mnt/USBdrive
I chmod because then you can't access the /mnt/USBdrive directory unless it is mounted. This may be confusing but when it comes to mounting, it's newbie friendly.

Now we need to update our /etc/fstab file. You can use any text editor, as long as you are still root. I prefer nano because it is newbie friendly! Add this line to the end of the file:
# nano -w /etc/fstab

/dev/sda1      /mnt/USBdrive    auto      user,rw,noauto      0 0
If you are using a digital camera card or some other windows oriented device, change auto to vfat.

Exit. Now's the moment of truth. As root, try:
# mount /mnt/USBdrive
if all goes well, exit and you are good to go.

A couple of issues you might run in to:
If you plug in or unplug other usb devices, the device label can change (especially if there is rebooting involved). So if it works, and you reboot and it doesn't, just dmesg to see what happened.

If your fs type entry in your fstab is wrong, (the whole auto, vfat thing) then you will get an error message. While this is unlikely, it is a possibility.

You should now be able to successfully setup a usb hard drive. IF you run in to some problems, there's a pretty good forum around here to ask for help! Have Fun!

by BobNz on Mon, 2004-04-12 23:30
I don't have the usr/src/linux folder so........?

by Muzzy on Sun, 2004-05-02 09:23
BobNZ : the article talks about reinstalling the kernel. If you don't know how to do this then you should probably read up on that first. However, you probably won't even need to recompile your kernel because many/most distributions come with USB as standard, so you can probably skip this section.

by BobNz on Sun, 2004-05-02 15:33
ok thanks for that.


by Sage1 on Mon, 2004-05-17 07:06
Wow! The latest two distros of Knoppix contain USB automatic setup!
You can see them, and download them, at the Knoppix URL in my sig.

Versions are knoppixV3.4-2004-05-04 and knoppixV3.4-2004-05-10

by rexster on Wed, 2004-05-26 08:06
i got scsi hd in sda
so, the dmesg show usb card reader in sdb.

question is, my card reader is 7in1.
in windows it show up 4 new drive.
so how do i mount?

i try mount /dev/sdb1 it ask for filetype
i try set vfat as filetype still cant work
it say:
mount: wrong fs type, bad option, bad superblock on /dev/sdb1,
or too many mounted file systems

got k12ltsp 4.01 running.

by rexster on Wed, 2004-05-26 08:26
i also try this:

same error...

by Sage1 on Wed, 2004-05-26 14:02
His Suse 9.1 recognized the 8-in-1 unit out of the box... perhaps it is in that distro, but, not in yours (yet)?

do the search, like I did?!

HTH! I just go a 7-in-1, and will check it out on my Knoppix systems...

by Sage1 on Wed, 2004-05-26 14:33
kernels need to be compiled with initrd

This link discusses the user's successful job to get his to work!

by perry on Thu, 2004-06-17 15:18
Originally posted by busbarn
This thread is to discuss the article titled: USB Card Reader HowTo
nice article, kinda answers my question as my maxtor, cd-rewriter, camera and flashdisk are all based off my external linksys usb hub....

and in Linux they seem to be operating at USB 1.x rates whereas with windows it's always much faster, i suspect USB 2.0.

however do what you say, i'm going to have to download the source code for Linux... nice idea but space is a premium for me....

what to do....

but here's another question, how do you "drop" a usb device that's no longer responding. i've tried to umount but it keeps saying "device is busy"....

any ideas


- perry

by benk on Sun, 2004-07-04 21:16
I've got Fedora Core 2, and it seems that my USB Hard disk works on it. I'm a newbie, and I'm guessing that added the line to /etc/fstab is to automate the mounting process? Also, will this /dev/sda1 mounted on mnt/USBdrive work if I replace the USB hard disk with my card reader and vise versa? And one last thing, if I get it to work, how do I automate it in Gnome? Is there a way to add a icon like the floppy or cd-rom drive?


All times are GMT -5. The time now is 10:06 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration