home -> linux -> usb

Mounting USB Devices on Linux


NOTE! This is for Fedora Core 4 and may not work on other distributions.

First we need to find out how the system will treat your specific USB device. I am using a simple USB thumb drive for this example. Plug the device into the machine and immediately open a console and type the command: dmesg. This will show some messages coming from the operating system. Look for the following lines:

sample output of dmesg command
usb 1-1: new full speed USB device using uhci_hcd and address 3
scsi2 : SCSI emulation for USB Mass Storage devices
usb-storage: device found at 3
usb-storage: waiting for device to settle before scanning
  Vendor: SanDisk   Model: Cruzer Mini       Rev: 0.2
  Type:   Direct-Access                      ANSI SCSI revision: 02
SCSI device sdb: 2001888 512-byte hdwr sectors (1025 MB)
sdb: Write Protect is off
sdb: Mode Sense: 03 00 00 00
sdb: assuming drive cache: write through
SCSI device sdb: 2001888 512-byte hdwr sectors (1025 MB)
sdb: Write Protect is off
sdb: Mode Sense: 03 00 00 00
sdb: assuming drive cache: write through
 sdb: sdb1
Attached scsi removable disk sdb at scsi2, channel 0, id 0, lun 0
usb-storage: device scan complete

By examining this closely we can see that the system has chosen to use the name sdb1 for my thumb drive. I've seen other systems use sda or sdc but it doesn't really matter as long as we know how the system identifies our USB device. Shortly after plugging in the USB device, the system should have created a node in the /dev directory. To verify this type the following command ls /dev | grep sdb1 where sdb1 is the name the the system is using for your USB device. Before we can read from or write to the device it must be mounted to the local filesystem. By default all 'media' devices (usb drive, cd-rom, floppy, etc.) are mounted under the /media directory. Start by examining the contents of the file: /etc/fstab which can be done using the vi editor from the console.

sample /etc/fstab contents
# This file is edited by fstab-sync - see 'man fstab-sync' for details
/dev/VolGroup00/LogVol00 /                       ext3    defaults        1 1
LABEL=/boot             /boot                   ext3    defaults        1 2
/dev/devpts             /dev/pts                devpts  gid=5,mode=620  0 0
/dev/shm                /dev/shm                tmpfs   defaults        0 0
/dev/proc               /proc                   proc    defaults        0 0
/dev/sys                /sys                    sysfs   defaults        0 0
/dev/VolGroup00/LogVol01 swap                    swap    defaults        0 0
/dev/fd0                /media/floppy           auto    pamconsole,exec,noauto,managed 0 0
/dev/hdc                /media/cdrom            auto    pamconsole,exec,noauto,managed 0 0

Find the line that starts with /dev/fd0 and insert a new line.

/dev/sdb1               /media/usb              vfat    user,noauto,umask=0 0 0
//TODO finish this!