- USB storage devices
- Auto-mounting with udisks
- Manual mounting
- Getting a kernel that supports usb_storage
- Identifying device
- Mounting USB memory
- Allow writing by regular users
- As normal user with fstab
- Mount tools
- Troubleshooting
- No USB storage devices are detected
- Device not shutting down after unmounting all partitions
- Device is detected but does not register as mountable
- How to detect an USB device?
- 5 Answers 5
USB storage devices
This document describes how to use the popular USB memory sticks with Linux. However, it is also valid for other devices such as digital cameras that act as if they were just a USB storage device.
If you have an up-to-date system with the standard Arch kernel and a modern desktop environment, your device should just show up on your desktop, with no need to open a console.
Auto-mounting with udisks
This is the easiest and most frequently used method. It is used by many desktop environments, but can be used separately too.
See Udisks for detailed information, including list of mount helpers.
Manual mounting
Note: Before you decide that Arch Linux does not mount your USB device, be sure to check all available ports. Some ports might not share the same controller, preventing you from mounting the device.
Getting a kernel that supports usb_storage
If you do not use a custom-made kernel, you are ready to go, for all Arch Linux stock kernels are properly configured. If you do use a custom-made kernel, ensure it is compiled with SCSI-Support, SCSI-Disk-Support and usb_storage. If you use the latest udev, you may just plug your device in and the system will automatically load all necessary kernel modules.
Identifying device
The first thing one needs to access a storage device is its identifier assigned by kernel. See File systems#Identify existing file systems for details.
Newly plugged-in devices are usually shown in the journal.
Mounting USB memory
If mount does not recognize the file system of the device you can try to use the -t argument, see mount(8) for details. If mounting does not work, you can try to recreate the file system or even repartition the disk.
Allow writing by regular users
If you want non-root users to be able to write to the USB stick, you can issue the following command:
# mount -o gid=users,fmask=113,dmask=002 /dev/sda1 /mnt/usbstick
If it does not work, make sure that the file system is mountable and writable as root, see the previous section for details.
As normal user with fstab
See FAT#Writing to FAT32 as normal user if you want normal user to do the mount/unmount action.
Mount tools
Multiple mount tools facilitate mounting as a regular user.
Troubleshooting
No USB storage devices are detected
If you have connected your USB storage device and it is not listed by lsblk but appears in the journal without being assigned a block device, see General troubleshooting#Cannot use some peripherals after kernel upgrade.
Also ensure that your BIOS has both XHCI Handoff and EHCI Handoff enabled, but this is usually not an issue with most modern devices.
Device not shutting down after unmounting all partitions
This article or section needs expansion.
Reason: Please advise how to automatically shut down devices after unmounting (Discuss in Talk:USB storage devices)
Failure to power off a device might result in:
- a hard disk drive not parking its head, making a faint scratching sound while spinning out and degrading the device [2], or
- a solid-state drive (especially older) not flushing its cache buffers or updating its mapping tables, and losing data [3].
When you unmount the partitions, the device is still powered on. You should ask the system to turn it off first in order to safely remove it: [4]
# echo 1 > /sys/block/disk_name/device/delete
If you use udisks, you can use these commands: [5]
$ udisksctl unmount -b /dev/sdXY $ udisksctl power-off -b /dev/sdX
Device is detected but does not register as mountable
udev is shipped with a default set of rules, found in /usr/lib/udev/rules.d/ , including one for ignoring some specific devices for various reasons. Some hardware devices, such as digital cameras, portable recorders, etc., may format usb storage in a way that results in the ignore rules to be triggered. You can check if one of these rules was applied with the following command and then find the corresponding conditions in the defaults:
$ udevadm info --attribute-walk --name=device_name | grep UDISKS_IGNORE
If this is the case and your device has this property set to «1», you can override it with a custom rule, following the udev page.
How to detect an USB device?
I got a scenario, where a software works only when you insert the USB device provided by the software vendor in windows operating system. Im trying to find the content stored in the USB device. In windows operating system, the USB device icon is not shown in My_Computer. I thought, I can see the content or atleast detect the USB device in Ubuntu. Also in ubuntu, the drive is not detected. I tried «sudo fdisk -l» to know the file system, but its not useful. The drive is not detected at all. I wanted to know, how the software works only when the USB drive is inserted and it wont when it is not inserted. Do they have any files stored in the USB device? In any case, how can we detect such kind of device in Ubuntu?
5 Answers 5
To detect your USB device, in a terminal, you can try:
$ lsusb Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub Bus 001 Device 002: ID 046d:0809 Logitech, Inc. Webcam Pro 9000 Bus 003 Device 002: ID 046d:c016 Logitech, Inc. Optical Wheel Mouse
sudo apt-get install input-utils lsinput
$ lsinput /dev/input/event0 . /dev/input/event1 . /dev/input/event2 . /dev/input/event3 bustype : BUS_USB vendor : 0x46d product : 0xc016 version : 272 name : "Logitech Optical USB Mouse" phys : "usb-0000:00:1d.1-2/input0" uniq : "" bits ev : EV_SYN EV_KEY EV_REL EV_MSC
$ udevadm monitor --udev monitor will print the received events for: UDEV - the event which udev sends out after rule processing UDEV [1915.787445] add /devices/pci0000:00/0000:00:1d.3/usb5/5-2 (usb) UDEV [1915.796226] add /devices/pci0000:00/0000:00:1d.3/usb5/5-2/5-2:1.0 (usb)
But it might not work. In my case I m trying to make my Leapfrog Tag run on Ubuntu without success.
Thanks for your input. «lsusb» and «udevadm» command list my device though «lsinput» command doesnt provide me any additional information.
If the device in question is a software protection dongle, it may not be a mass storage device.
A likely alternate device for it to implement would be an ethernet controller ; the software can communicate with the device via the network adapter, which won’t appear as a drive. Or the device could implement a serial port, or another device for which the drivers are included with the operating system.
In any case, this is not an appropriate forum to ask about circumventing the copy protection on Windows software, even if you are trying to do it using Ubuntu.
If it’s a device who’s sole purpose is to prevent the software running without it being present, it’s a software protection dongle.
Thanks a lot for your comment. It was valuable input for me. I have identified that it is a software protection dongle with your help. I wanted to know much about the technology being used in it and other technical stuff. Do you know any forum like «askubuntu» sort?. I also googled to find about the same. But im not convinced.
What also works nice when your PC hardware has difficulties with usb events is running a cronjob.
This forces a complete scan of the connected USB devices.
Each minute the situation is updated.
Does anyone know if this actually scans the USB ports or does it simply scan the /dev/usb/ directory for already known devices. The way the manpage describes it, appears to only scan the device directory and doesn’t refresh the ports.
If you want to detect how a USB device is being loaded- with excellent granularity- here are (2) ways:
udevadm monitor : This will show you the USB device being loaded as the USB Bus sees it.
udevadm is part of the default package udev on 18.04 LTS; no need to install it.
Execute udevadm monitor BEFORE you insert the USB device however.
Specimen output loading a USB flash drive shown below. Skip to the last line and you can even see what device it loaded as (sda1):
udevadm monitor monitor will print the received events for: UDEV - the event which udev sends out after rule processing KERNEL - the kernel uevent KERNEL[969.010067] add /devices/pci0000:00/0000:00:14.0/usb1/1-1 (usb) KERNEL[969.010367] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0 (usb) KERNEL[969.018769] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/host0 (scsi) KERNEL[969.018849] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/host0/scsi_host/host0 (scsi_host) KERNEL[969.018934] bind /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0 (usb) KERNEL[969.019049] bind /devices/pci0000:00/0000:00:14.0/usb1/1-1 (usb) UDEV [969.024995] add /devices/pci0000:00/0000:00:14.0/usb1/1-1 (usb) UDEV [969.031390] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0 (usb) UDEV [969.036362] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/host0 (scsi) UDEV [969.041258] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/host0/scsi_host/host0 (scsi_host) UDEV [969.046202] bind /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0 (usb) UDEV [969.051734] bind /devices/pci0000:00/0000:00:14.0/usb1/1-1 (usb) KERNEL[970.051706] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/host0/target0:0:0 (scsi) KERNEL[970.052068] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/host0/target0:0:0/0:0:0:0 (scsi) KERNEL[970.052215] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/host0/target0:0:0/0:0:0:0/scsi_disk/0:0:0:0 (scsi_disk) KERNEL[970.052435] bind /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/host0/target0:0:0/0:0:0:0 (scsi) KERNEL[970.052585] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/host0/target0:0:0/0:0:0:0/scsi_device/0:0:0:0 (scsi_device) KERNEL[970.052774] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/host0/target0:0:0/0:0:0:0/scsi_generic/sg0 (scsi_generic) KERNEL[970.052963] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/host0/target0:0:0/0:0:0:0/bsg/0:0:0:0 (bsg) UDEV [970.060833] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/host0/target0:0:0 (scsi) KERNEL[970.061634] add /devices/virtual/bdi/8:0 (bdi) UDEV [970.069006] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/host0/target0:0:0/0:0:0:0 (scsi) UDEV [970.071467] add /devices/virtual/bdi/8:0 (bdi) UDEV [970.075852] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/host0/target0:0:0/0:0:0:0/scsi_disk/0:0:0:0 (scsi_disk) KERNEL[970.079839] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/host0/target0:0:0/0:0:0:0/block/sda (block) KERNEL[970.079989] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/host0/target0:0:0/0:0:0:0/block/sda/sda1 (block) UDEV [970.083556] bind /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/host0/target0:0:0/0:0:0:0 (scsi) UDEV [970.091288] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/host0/target0:0:0/0:0:0:0/scsi_device/0:0:0:0 (scsi_device) UDEV [970.091755] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/host0/target0:0:0/0:0:0:0/scsi_generic/sg0 (scsi_generic) UDEV [970.106807] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/host0/target0:0:0/0:0:0:0/bsg/0:0:0:0 (bsg) UDEV [970.339976] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/host0/target0:0:0/0:0:0:0/block/sda (block) UDEV [970.519549] add /devices/pci0000:00/0000:00:14.0/usb1/1-1/1-1:1.0/host0/target0:0:0/0:0:0:0/block/sda/sda1 (block)
dmesg (which prints the Kernel ring buffer) will also give you granular visibility into the loading of your USB device.
However, dmesg in contrast to udevadm monitor shows you how loading of your external USB device from the Kernel’s perspective
Specimen output from dmesg -this time from a USB external CD drive- shown below. The «1-2» refers to its’ location on the USB bus: First bus, second port. Had I connected the CD drive to the other port, it would have reported «1-1«:
[ 55.296482] usb 1-2: new high-speed USB device number 4 using xhci_hcd [ 55.453715] usb 1-2: New USB device found, idVendor=1c6b, idProduct=a222 [ 55.453730] usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3 [ 55.453740] usb 1-2: Product: Mass Storage Device [ 55.453749] usb 1-2: Manufacturer: USB2.0 External [ 55.453758] usb 1-2: SerialNumber: 2010100500000000174 [ 55.525860] usb-storage 1-2:1.0: USB Mass Storage device detected [ 55.527273] scsi host0: usb-storage 1-2:1.0 [ 55.530031] usbcore: registered new interface driver usb-storage [ 55.545215] usbcore: registered new interface driver uas [ 56.553073] scsi 0:0:0:0: CD-ROM slimtype eTDU108 1 SL46 PQ: 0 ANSI: 0