Tuesday, July 31, 2007

Mounting USB storage drives in Linux

Plug in Memory Stick into available USB port and then..
# dmesg | less

(The device is picked up as a USB 1.1 and allocated an address.
Also says what HCD it is using.)

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

(SCSI emulation automatically kicks in)
scsi0 : SCSI emulation for USB Mass Storage devices
usb-storage: device found at 2

(Now the device information including model number is retrieved)
usb-storage: waiting for device to settle before scanning
Vendor: JetFlash Model: TS512MJF2A Rev: 1.00
Type: Direct-Access ANSI SCSI revision: 02
SCSI device sda: 1003600 512-byte hdwr sectors (514 MB)

(The write-protect sense is EXPERIMENTAL code in the later kernels)
sda: Write Protect is off
sda: Mode Sense: 0b 00 00 08
sda: assuming drive cache: write through
SCSI device sda: 1003600 512-byte hdwr sectors (514 MB)
/dev/scsi/host0/bus0/target0/lun0: p1
Attached scsi removable disk sda at scsi0, channel 0, id 0, lun 0
Attached scsi generic sg0 at scsi0, channel 0, id 0, lun 0, type 0
usb-storage: device scan complete
(At this point, the device is generally accessible by mounting /dev/sda1)

(When the device is disconnected, the system acknowledges the same)
usb 1-1: USB disconnect, address 2

To see the partition table type fdisk -l /dev/sda

To Mount the partition type

# mount /dev/sda1 /mnt/usb
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/hda8 9.4G 7.5G 1.9G 80% /
/dev/hda9 11G 8.1G 2.4G 78% /usr
none 189M 0 189M 0% /dev/shm
/dev/sda1 490M 34M 457M 7% /mnt/usb


No comments: