Access a USB flash drive in Linux.
Linux normally mounts USB flash drives or thumb drives automatically when you plug them in. Sometimes it does not, which can frustrate new users because using the drive becomes difficult and they do not know what to do. This article explains how to use a USB flash drive or thumb drive when Linux does not mount it automatically. First enter: #tail -f /var/log/messages to check whether Linux detects the USB flash drive hardware. Then plug in the drive, and messages like the following appear: Jun 27 12:18:09 localhost kernel: usb 1-5: new high speed USB device using ehci_hcd and address 9 Jun 27 12:18:10 localhost kernel: Initializing USB Mass Storage driver… Jun 27 12:18:10 localhost kernel: scsi2 : SCSI emulation for USB Mass Storage devices Jun 27 12:18:10 localhost kernel: usbcore: registered new driver usb-storage Jun 27 12:18:10 localhost kernel: USB Mass Storage support registered. Jun 27 12:18:15 localhost kernel: Vendor: 256MB Model: USB2.0FlashDrive Rev: 2.00 Jun 27 12:18:15 localhost kernel: Type: Direct-Access ANSI SCSI revision: 02 Jun 27 12:18:15 localhost kernel: sda: Unit Not Ready, sense: Jun 27 12:18:15 localhost kernel: : Current: sense key: Unit Attention Jun 27 12:18:15 localhost kernel: Additional sense: Not ready to ready change, medium may have changed Jun 27 12:18:15 localhost kernel: sda : READ CAPACITY failed. Jun 27 12:18:15 localhost kernel: sda : status=1, message=00, host=0, driver=08 Jun 27 12:18:15 localhost kernel: sd: Current: sense key: Unit Attention Jun 27 12:18:15 localhost kernel: Additional sense: Not ready to ready change, medium may have changed Jun 27 12:18:15 localhost kernel: sda: Write Protect is off Jun 27 12:18:15 localhost kernel: sda: assuming drive cache: write through Jun 27 12:18:15 localhost kernel: SCSI device sda: 512000 512-byte hdwr sectors (262 MB) Jun 27 12:18:15 localhost kernel: sda: Write Protect is off Jun 27 12:18:15 localhost kernel: sda: assuming drive cache: write through Jun 27 12:18:15 localhost kernel: sda: sda1 Jun 27 12:18:15 localhost kernel: Attached scsi removable disk sda at scsi2, channel 0, id 0, lun 0 Jun 27 12:18:15 localhost scsi.agent[3965]: disk at /devices/pci0000:00/0000:00:1d.7/usb1/1-5/1-5:1.0/host2/target2:0:0/2:0:0:0 Jun 27 12:18:15 localhost fstab-sync[3989]: added mount point /media/usbdisk for /dev/sda1 The red text indicates that the USB flash drive has been detected as sda, with one partition named sda1. The steps shown in green below may be unnecessary. Check whether the usb_storage module has loaded with: #lsmod Module Size Used by usb_storage 74761 0 sd_mod 22977 0 scsi_mod 136457 2 usb_storage,sd_mod Check the flash drive’s ID with: #lsusb Bus 001 Device 009: ID 0ea0:2168 Ours Technology, Inc. Transcend JetFlash 2.0 / Astone USB Drive Once you have confirmed that the system detects the USB flash drive, make it available using:
mkdir /mymountpoint // สร้าง directory เพื่อรองรับการ mount
mount /dev/sda1 /mymountpoint // ทำการ mount USB flash หรือ thumbdrives ขึ้นมาใน directory ที่ชื่อ mymountpoint
If the drive still does not work after these steps, try: #modprobe usb-storage to load the usb-storage module, then repeat the steps above. If nothing works (the worst case), restart the machine. Additional note: If a USB flash drive is unused for a long time, the system automatically unplugs it. To check whether this has happened, look in /var/log/messages. The following message indicates that the USB flash drive has been unplugged: Jun 27 12:35:14 localhost kernel: usb 1-5: USB disconnect, address 9