Problem With Linux Unmounting USB External Drives

Submitted by Tom Thorp on Thursday, August 3, 2023 - 22:59
Modified on Friday, August 4, 2023 - 00:49
USB External Hard Drive Mount

The Problem

The crux of the 'USB drive disconnects' is to do with compatibility with the USB 3.x protocol - specifically 'USB Attached Storage' (commonly called UAS). With older hardware, connecting via USB 2.0 didn't present a problem with the slower throughput rate, as USB mounted external drives were able to keep up. With manufacturers tending to cut some corners, their product(s) may not be fully UAS compliant. Linux operating systems are more fallible than most, which can lead to USB mounted drives disconnecting. 

The Solution

The workaround to this issue, is to disable 'USB Attached Storage' (UAS) mode on the affected device, and mark it as 'USB  Mass Storage' device. To do so, from the console type the following : 

[fedora@localhost ~]$ sudo lsusb -t
/:  Bus 04.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/2p, 5000M
    |__ Port 1: Dev 2, If 0, Class=Mass Storage, Driver=uas, 5000M
/:  Bus 03.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/2p, 480M
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/2p, 480M
    |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/6p, 480M
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/2p, 480M
    |__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/6p, 480M
        |__ Port 4: Dev 3, If 0, Class=Video, Driver=uvcvideo, 480M
        |__ Port 4: Dev 3, If 1, Class=Video, Driver=uvcvideo, 480M
        |__ Port 5: Dev 4, If 0, Class=Vendor Specific Class, Driver=dvb_usb_dib0700, 480M

Locate which Bus & Device is using the UAS driver. In my case, it is Bus 04 Device 2 . 

Next, get the device id connected to Bus 04 Device 2.

[fedora@localhost ~]$ sudo lsusb
Bus 002 Device 002: ID 8087:8001 Intel Corp. 
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 8087:8009 Intel Corp. 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 002: ID 7825:a2a4  
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 004: ID 046d:c248 Logitech, Inc. G105 Gaming Keyboard
Bus 003 Device 006: ID 056a:0011 Wacom Co., Ltd Graphire 2 4x5
Bus 003 Device 005: ID 046d:c077 Logitech, Inc. M105 Optical Mouse
Bus 003 Device 003: ID 05e3:0608 Genesys Logic, Inc. Hub
Bus 003 Device 002: ID 05e3:0608 Genesys Logic, Inc. Hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

In this case, the device id is 7825:a2a4 . Whatever your device id is, note it down as this will be important shortly. 

Next, we have to make an entry into the kernel's blacklist file. To do this, with root privileges, create a file in '/etc/modprobe.d' directory. Thus : 

[root@localhost ~]# cd /etc/modprobe.d
[root@localhost modprobe.d]# nano blacklist-uas-on-quirks.conf

Add the following line to 'blacklist-uas-on-quirks.conf' : 

options usb-storage quirks=7825:a2a4:u

If there is more than one device id that needs to be added, then add them like so : 

options usb-storage quirks=7825:a2a4:u,174c:55aa:u

where device ids are added in the following format: 

options usb-storage quirks=[id]:u

Save the file.

Finally, commit the blacklist to the linux kernel by regenerating the initramfs file, then reboot. On Fedora it is thus : 

[root@localhost ~]# dracut --force
[root@localhost ~]# reboot now

Upon reboot, check that UAS has successfully been disabled for your device by running the following command : 

[root@localhost ~]# dmesg | grep UAS
[    1.976152] usb 4-1: UAS is ignored for this device, using usb-storage instead

If your message log is similar to this, then congratulations. Your device should now connect as a USB Storage device instead of the newer USB Attached Storage standard. You can now try and connect / disconnect any USB devices that you were having drop-outs with. 

 

Any comments most welcome. 

 

About the author

Tom Thorp
Tom Thorp is an IT Consultant living in Miami on Queensland's Gold Coast. With over 30+ years working in the IT industry, Tom's experience is a broad canvas. The IT services Tom provides to his clients, includes :
 
Website development and hosting
Database Administration
Server Administration (Windows, Linux, Apple)
PABX Hosting and Administration
Helpdesk Support (end-user & technical).
  If you like any of my content, consider a donation via Crypto by clicking on one of the payment methods :
 
Categories