#################################################################################

Title:  USB pendrive Howto - Configure, install and wildly use it.
Author: Marco Segato <marco(dot)segato(at)gmail(dot)com>
Website: http://marcosegato.altervista.org/

#################################################################################


==========================
How to read this few lines
==========================

These few lines are provided AS IS, no warranty for your hardware ;)

If the line starts with a "#" you have to execute the command as root;
if the line starts with a "$" you can execute the command as normal user.

Examples of shell output are provided by my linux-box configured as is:
 - Slackware 9.0;
 - kernel 2.4.20 (default installation);
 - mainboard ECS K7VZA with 2 USB ports;
 - PCI USB hub with 2 USB ports;
 - pendrive Picodisk Tech 2.


===============
A) Requirements
===============

 - A new USB pendrive ready to be plugged into your linux-box;
 - linux kernel >= 2.4.x (older ones do not support USB devices);
 - a mainboard with at least 1 USB port.


========================
B) Finding your pendrive
========================

1) NB: if your distro is one of the latest, you'll probably won't to do this,
   because hotplug will do it for you! Anyway, you can use this step to control
   your configuration and better learn the usage of modules ;)
   Do NOT initially plug in your pendrive! Execute from shell:
    # lsmod
   and load this modules if they aren't listed:
    # modprobe sd_mod
    # modprobe usbcore
    # modprobe uhci
    # modprobe usb-ohci
    # modprobe usb-storage

2) Check your configuration BEFORE using the new device; USB mass storages are
   recognized by linux as scsi devices, so you'll probably find it as one of
   those, depending on your scsi configuration:
    # cat /proc/scsi/scsi
   You'll read something like this:
     Attached devices:
     Host: scsi0 Channel: 00 Id: 00 Lun: 00
       Vendor: SAMSUNG  Model: CD-ROM SC-152L   Rev: LS01
       Type:   CD-ROM                           ANSI SCSI revision: 02
     Host: scsi0 Channel: 00 Id: 01 Lun: 00
       Vendor: PHILIPS  Model: PCRW804          Rev:  2.0
       Type:   CD-ROM                           ANSI SCSI revision: 02
   and then:
    # lsusb
   with something like this:
     Duplicate HUT Usage Spec at line 2650
     Bus 003 Device 001: ID 0000:0000 Virtual Hub
     Bus 002 Device 001: ID 0000:0000 Virtual Hub
     Bus 002 Device 002: ID 0483:7554 SGS Thomson Microelectronics 56k SoftModem
     Bus 001 Device 001: ID 0000:0000 Virtual Hub
     Bus 001 Device 002: ID 0461:4d03 Primax Electronics Kensington Mouse-in-a-box

3) Now you can insert your new pendrive into USB port and try to find where the
   pendrive has been attached by the kernel; execute again:
    # cat /proc/scsi/scsi
   and find the differences between now and before: if you can find a new device
   in the list, your pendrive is alive! :) This time output could be:
     Attached devices:
     Host: scsi0 Channel: 00 Id: 00 Lun: 00
       Vendor: SAMSUNG  Model: CD-ROM SC-152L   Rev: LS01
       Type:   CD-ROM                           ANSI SCSI revision: 02
     Host: scsi0 Channel: 00 Id: 01 Lun: 00
       Vendor: PHILIPS  Model: PCRW804          Rev:  2.0
       Type:   CD-ROM                           ANSI SCSI revision: 02
     Host: scsi1 Channel: 00 Id: 00 Lun: 00                             } HERE!
       Vendor: Eutron   Model: Picodisk Tech 2  Rev: 1.00               } HERE!
       Type:   Direct-Access                    ANSI SCSI revision: 02  } HERE!
   and then:
    # lsusb
   with something like this:
     Duplicate HUT Usage Spec at line 2650
     Bus 003 Device 001: ID 0000:0000 Virtual Hub
     Bus 002 Device 001: ID 0000:0000 Virtual Hub
     Bus 002 Device 002: ID 0483:7554 SGS Thomson Microelectronics 56k SoftModem
     Bus 001 Device 001: ID 0000:0000 Virtual Hub
     Bus 001 Device 003: ID 073d:0050   } HERE!
     Bus 001 Device 002: ID 0461:4d03 Primax Electronics Kensington Mouse-in-a-box
   it's again your pendrive :)

4) At this point you're ready to find where your pendrive has been attached;
    # dmesg | more
   will give you an idea:
     hub.c: new USB device 00:0a.0-1, assigned address 3
     usb.c: USB device 3 (vend/prod 0x73d/0x50) is not claimed by any active driver.
     Initializing USB Mass Storage driver...
     usb.c: registered new driver usb-storage
     usb_control/bulk_msg: timeout
     scsi1 : SCSI emulation for USB Mass Storage devices
       Vendor: Eutron    Model: Picodisk Tech 2   Rev: 1.00
       Type:   Direct-Access                      ANSI SCSI revision: 02
     Attached scsi removable disk sda at scsi1, channel 0, id 0, lun 0
     SCSI device sda: 256000 512-byte hdwr sectors (131 MB)
     sda: Write Protect is off
      sda: sda1  } HERE!
     WARNING: USB Mass Storage data integrity not assured
     USB Mass Storage device found at 3
     USB Mass Storage support registered.
   As you can see the new device has been attached at /dev/sda1 as scsi disk.


======================
C) Using your pendrive
======================

To use your USB pendrive you have only to mount it; first make a new directory:
  # mkdir /mnt/pendrive
Supposed that the device has been attached at /dev/sda1:
  # mount -t vfat /dev/sda1 /mnt/pendrive
NB: in some documentation I found in the web, someone suggested to mount the
device with 'auto' filesystem; in my experience, mounting the pendrive by this
way caused the usage of DOS/fat16 filesystem with all its limits. So, if you
do not want to format the pendrive to use a *nix filesystem, you should better
use the 'vfat' option here.


===============================================
D) Automatically mount the pendrive at the boot
===============================================

Edit as root your /etc/fstab and add this line:
  /dev/sda1     /mnt/pendrive     vfat     noauto,user,rw     1   0
Specifing 'noauto', you deny automatic mount of the device (as should be for
external hard disk!); 'user' lets non-root users mount or umount the device;
'rw' stands for the ability of reading AND writing.
Now you can reboot and have fun with your new pendrive!


#################################################################################

Thank's to bboross(at)yahoo(dot)com, he found out the need of the module sd_mod

#################################################################################