Using USB Sticks On Linux

As the name of the page is telling you I'm going to explain how to use your USB-stick aka mp3 player with Linux. Let's start ...

What do you need ? Well some "play" with kernel ( or maybe not ) and tons of nerves :) Procedure is similar as to all new hardware, meaning finding out what makes it tick. We need to find out everything there is to know about USB-stick or mp3 player and how it interacts with kernel, and what file system is used on your mp3 player/stick.

First step is to actually find out how USB is seen on our PC, and what driver ( module ) is used for that. That we can find out with commands dmesg and lspci and with a little piping we get :

castra@utopia castra $ dmesg | grep USB
USB Universal Host Controller Interface driver v2.2
uhci_hcd 0000:00:07.2: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller
uhci_hcd 0000:00:07.2: new USB bus registered, assigned bus number 1
hub 1-0:1.0: USB hub found
uhci_hcd 0000:00:07.3: VIA Technologies, Inc. VT82xxxxx UHCI USB 1.1 Controller (#2)

or

castra@utopia castra $ lspci -v | grep USB
00:07.2 USB Controller: VIA Technologies, Inc. USB (rev 1a) (prog-if 00 [UHCI])
Subsystem: VIA Technologies, Inc. USB Controller
00:07.3 USB Controller: VIA Technologies, Inc. USB (rev 1a) (prog-if 00 [UHCI])
Subsystem: VIA Technologies, Inc. USB Controller

From this we see that driver ( module ) we are after is UHCI. To make things easier for us we are going to add/use driver for mass storage and SCSI driver.

This is the kernel part that is needed in order to make mp3/stick work.

Type this:

cd /usr/src/linux
make menuconfig

And choose following:

Device Drivers --->SCSI device support --->

 SCSI disk support

USB support --->

 UHCI HCD (most Intel and VIA) support
USB Mass Storage support

File systems --->DOS/FAT/NT Filesystems --->

 MSDOS fs support
VFAT (Windows-95) fs support

After choosing all this stuff save it and type:

make modules ; make modules_install

If no errors are seen and there should be no errors anyway :) load modules !

modprobe usb-storage
modprobe vfat
modprobe msdos
modprobe usb-uhci
modprobe sd_mod

Connect your USB-stick/mp3 and type dmsg ! You should see something like this:

usb 1-2: new full speed USB device using address 3

scsi0 : SCSI emulation for USB Mass Storage devices

Vendor: Model: Rev:

Type: Direct-Access ANSI SCSI revision: 02

USB Mass Storage device found at 3
SCSI device sda: 252509 512-byte hdwr sectors (129 MB)
sda: assuming Write Enabled
sda: assuming drive cache: write through

/dev/scsi/host0/bus0/target0/lun0: p1

Attached scsi removable disk sda at scsi0, channel 0, id 0, lun 0

This means that hardware is recognised by PC and we are almost done.<br> Device is found under /dev/sda1 or sda2

We now we have to make a place where to mount it with:

mkdir /mnt/usb

and mount it as root

mount -t msdos /dev/sda1 /mnt/usb # ( or msdos, vfat or any fs you are using)

To confirm that everything is loaded and in place we do this :

df -h 

and you should see something like this:

castra@utopia castra # df -h
Filesystem Size Used Avail Use% Mounted on
/dev/hda3 6.0G 4.9G 1.1G 82% /
/dev/hda4 68G 66G 2.8G 97% /home
none 252M 0 252M 0% /dev/shm
/dev/sda1 123M 37M 87M 30% /mnt/usb

Line we are interested in is the last one above !

With that our little howto is done.

By Adis Beglerovic

website software by Techno Joy // New Zealand Web Developers