Sandisk Mini USB Disconnects when Laptop Suspends on Battery
https://askubuntu.com/questions/1559554/sandisk-mini-usb-disconnects-when-laptop-suspends-on-battery
I have a 128Gb Sandisk mini USB device that I am using for extra storage on an old Lenovo V145-15AST (model 81MT) running Xubuntu 24.04.2.
I have it mounted using fstab and everything works as intended.
# mount Sandisk 128Gb USB
/dev/disk/by-uuid/3936-3889 /media/Sandisk auto x-gvfs-name=USB-Sandisk,x-gvfs-show,uid=1000,gid=1000 0 1
Initially, the presence of the USB drive would cause the system to hang when waking from suspend, but only when running on battery power. The following command
echo "XHC0" | sudo tee /proc/acpi/wakeup
fixed the problem, so that is now automated on startup.
Then I noticed that the USB device would just "disappear" if I left it suspended on battery for longer than an hour. I assume that is to do with power states and entering a deeper suspend/freeze. So I tried disabling auto-suspend by editing GRUB.
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash usbcore.autosuspend=-1"
And checking
cat /sys/module/usbcore/parameters/autosuspend
gives -1 on a reboot.
lsusb gives the following:
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 002: ID 0438:7900 Advanced Micro Devices, Inc. Root Hub
Bus 002 Device 003: ID 0bda:c024 Realtek Semiconductor Corp. Bluetooth Radio
Bus 002 Device 004: ID 13d3:5a02 IMC Networks EasyCamera
Bus 003 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 004: ID 0781:5583 SanDisk Corp. Ultra Fit
So I added the below rule to /etc/udev/rules.d/92-usb-input-no-powersave.rules
ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="0781", ATTR{idProduct}=="5583", TEST=="power/control", ATTR{power/control}="on"
I also tried with SUBSYSTEMS=="usb", but the USB device is still powered off after an hour. (again, this only happens on battery power).
udevadm info -a /dev/sda
outputs the below:
looking at device '/devices/pci0000:00/0000:00:10.0/usb3/3-3/3-3:1.0/host0/target0:0:0/0:0:0:0/block/sda':
KERNEL=="sda"
SUBSYSTEM=="block"
DRIVER==""
ATTR{alignment_offset}=="0"
ATTR{capability}=="0"
ATTR{discard_alignment}=="0"
ATTR{diskseq}=="53"
ATTR{events}=="media_change"
ATTR{events_async}==""
ATTR{events_poll_msecs}=="-1"
ATTR{ext_range}=="256"
ATTR{hidden}=="0"
ATTR{inflight}==" 0 0"
ATTR{integrity/device_is_integrity_capable}=="0"
ATTR{integrity/format}=="none"
ATTR{integrity/protection_interval_bytes}=="0"
ATTR{integrity/read_verify}=="0"
ATTR{integrity/tag_size}=="0"
ATTR{integrity/write_generate}=="0"
ATTR{mq/0/cpu_list}=="0, 1, 2, 3"
ATTR{mq/0/nr_reserved_tags}=="0"
ATTR{mq/0/nr_tags}=="2"
ATTR{partscan}=="1"
ATTR{power/async}=="disabled"
ATTR{power/control}=="auto"
ATTR{power/runtime_active_kids}=="0"
ATTR{power/runtime_active_time}=="0"
ATTR{power/runtime_enabled}=="disabled"
ATTR{power/runtime_status}=="unsupported"
ATTR{power/runtime_suspended_time}=="0"
ATTR{power/runtime_usage}=="0"
ATTR{queue/add_random}=="1"
ATTR{queue/atomic_write_boundary_bytes}=="0"
ATTR{queue/atomic_write_max_bytes}=="0"
ATTR{queue/atomic_write_unit_max_bytes}=="0"
ATTR{queue/atomic_write_unit_min_bytes}=="0"
ATTR{queue/chunk_sectors}=="0"
ATTR{queue/dax}=="0"
ATTR{queue/discard_granularity}=="512"
ATTR{queue/discard_max_bytes}=="0"
ATTR{queue/discard_max_hw_bytes}=="0"
ATTR{queue/discard_zeroes_data}=="0"
ATTR{queue/dma_alignment}=="511"
ATTR{queue/fua}=="0"
ATTR{queue/hw_sector_size}=="512"
ATTR{queue/io_poll}=="0"
ATTR{queue/io_poll_delay}=="-1"
ATTR{queue/io_timeout}=="30000"
ATTR{queue/iosched/async_depth}=="4"
ATTR{queue/iosched/fifo_batch}=="16"
ATTR{queue/iosched/front_merges}=="1"
ATTR{queue/iosched/prio_aging_expire}=="10000"
ATTR{queue/iosched/read_expire}=="500"
ATTR{queue/iosched/write_expire}=="5000"
ATTR{queue/iosched/writes_starved}=="2"
ATTR{queue/iostats}=="1"
ATTR{queue/iostats_passthrough}=="0"
ATTR{queue/logical_block_size}=="512"
ATTR{queue/max_discard_segments}=="1"
ATTR{queue/max_hw_sectors_kb}=="512"
ATTR{queue/max_integrity_segments}=="0"
ATTR{queue/max_sectors_kb}=="512"
ATTR{queue/max_segment_size}=="65536"
ATTR{queue/max_segments}=="2048"
ATTR{queue/minimum_io_size}=="4096"
ATTR{queue/nomerges}=="0"
ATTR{queue/nr_requests}=="4"
ATTR{queue/nr_zones}=="0"
ATTR{queue/optimal_io_size}=="0"
ATTR{queue/physical_block_size}=="512"
ATTR{queue/read_ahead_kb}=="128"
ATTR{queue/rotational}=="1"
ATTR{queue/rq_affinity}=="1"
ATTR{queue/scheduler}=="none [mq-deadline] "
ATTR{queue/stable_writes}=="0"
ATTR{queue/virt_boundary_mask}=="0"
ATTR{queue/wbt_lat_usec}=="75000"
ATTR{queue/write_cache}=="write back"
ATTR{queue/write_same_max_bytes}=="0"
ATTR{queue/write_zeroes_max_bytes}=="33553920"
ATTR{queue/zone_append_max_bytes}=="0"
ATTR{queue/zone_write_granularity}=="0"
ATTR{queue/zoned}=="none"
ATTR{range}=="16"
ATTR{removable}=="1"
ATTR{ro}=="0"
ATTR{size}=="240328704"
ATTR{stat}==" 265 28681 35982 5139 1 0 1 3 0 2477 5143 0 0 >
ATTR{trace/act_mask}=="disabled"
ATTR{trace/enable}=="0"
ATTR{trace/end_lba}=="disabled"
ATTR{trace/pid}=="disabled"
ATTR{trace/start_lba}=="disabled"
looking at parent device '/devices/pci0000:00/0000:00:10.0/usb3/3-3/3-3:1.0/host0/target0:0:0/0:0:0:0':
KERNELS=="0:0:0:0"
SUBSYSTEMS=="scsi"
DRIVERS=="sd"
ATTRS{blacklist}=="SKIP_IO_HINTS"
ATTRS{cdl_enable}=="0"
ATTRS{cdl_supported}=="0"
ATTRS{delete}=="(not readable)"
ATTRS{device_blocked}=="0"
ATTRS{device_busy}=="0"
ATTRS{dh_state}=="detached"
ATTRS{eh_timeout}=="10"
ATTRS{evt_capacity_change_reported}=="0"
ATTRS{evt_inquiry_change_reported}=="0"
ATTRS{evt_lun_change_reported}=="0"
ATTRS{evt_media_change}=="0"
ATTRS{evt_mode_parameter_change_reported}=="0"
ATTRS{evt_soft_threshold_reached}=="0"
ATTRS{inquiry}==""
ATTRS{iocounterbits}=="32"
ATTRS{iodone_cnt}=="0x3d1f"
ATTRS{ioerr_cnt}=="0x4"
ATTRS{iorequest_cnt}=="0x3d1f"
ATTRS{iotmo_cnt}=="0x0"
ATTRS{model}==" SanDisk 3.2Gen1"
ATTRS{power/async}=="enabled"
ATTRS{power/autosuspend_delay_ms}=="-1"
ATTRS{power/control}=="on"
ATTRS{power/runtime_active_kids}=="0"
ATTRS{power/runtime_active_time}=="31342045"
ATTRS{power/runtime_enabled}=="forbidden"
ATTRS{power/runtime_status}=="active"
ATTRS{power/runtime_suspended_time}=="0"
ATTRS{power/runtime_usage}=="2"
ATTRS{queue_depth}=="2"
ATTRS{queue_type}=="simple"
ATTRS{rescan}=="(not readable)"
ATTRS{rev}=="1.00"
ATTRS{scsi_level}=="8"
ATTRS{state}=="running"
ATTRS{timeout}=="30"
ATTRS{type}=="0"
ATTRS{vendor}==" USB "
ATTRS{vpd_pg0}==""
ATTRS{vpd_pg80}==""
ATTRS{vpd_pg83}==""
ATTRS{vpd_pgb0}==""
ATTRS{wwid}=="t10. USB\0\0\0\0 SanDisk 3.2Gen10002321502222516"
looking at parent device '/devices/pci0000:00/0000:00:10.0/usb3/3-3/3-3:1.0/host0/target0:0:0':
KERNELS=="target0:0:0"
SUBSYSTEMS=="scsi"
DRIVERS==""
ATTRS{power/async}=="enabled"
ATTRS{power/control}=="auto"
ATTRS{power/runtime_active_kids}=="1"
ATTRS{power/runtime_active_time}=="31342046"
ATTRS{power/runtime_enabled}=="enabled"
ATTRS{power/runtime_status}=="active"
ATTRS{power/runtime_suspended_time}=="0"
ATTRS{power/runtime_usage}=="0"
looking at parent device '/devices/pci0000:00/0000:00:10.0/usb3/3-3/3-3:1.0/host0':
KERNELS=="host0"
SUBSYSTEMS=="scsi"
DRIVERS==""
ATTRS{power/async}=="enabled"
ATTRS{power/control}=="auto"
ATTRS{power/runtime_active_kids}=="1"
ATTRS{power/runtime_active_time}=="31342153"
ATTRS{power/runtime_enabled}=="enabled"
ATTRS{power/runtime_status}=="active"
ATTRS{power/runtime_suspended_time}=="0"
ATTRS{power/runtime_usage}=="0"
looking at parent device '/devices/pci0000:00/0000:00:10.0/usb3/3-3/3-3:1.0':
KERNELS=="3-3:1.0"
SUBSYSTEMS=="usb"
DRIVERS=="uas"
ATTRS{authorized}=="1"
ATTRS{bAlternateSetting}==" 1"
ATTRS{bInterfaceClass}=="08"
ATTRS{bInterfaceNumber}=="00"
ATTRS{bInterfaceProtocol}=="62"
ATTRS{bInterfaceSubClass}=="06"
ATTRS{bNumEndpoints}=="04"
ATTRS{physical_location/dock}=="no"
ATTRS{physical_location/horizontal_position}=="left"
ATTRS{physical_location/lid}=="no"
ATTRS{physical_location/panel}=="unknown"
ATTRS{physical_location/vertical_position}=="upper"
ATTRS{power/async}=="enabled"
ATTRS{power/runtime_active_kids}=="1"
ATTRS{power/runtime_enabled}=="disabled"
ATTRS{power/runtime_status}=="unsupported"
ATTRS{power/runtime_usage}=="0"
ATTRS{supports_autosuspend}=="0"
looking at parent device '/devices/pci0000:00/0000:00:10.0/usb3/3-3':
KERNELS=="3-3"
SUBSYSTEMS=="usb"
DRIVERS=="usb"
ATTRS{authorized}=="1"
ATTRS{avoid_reset_quirk}=="0"
ATTRS{bConfigurationValue}=="1"
ATTRS{bDeviceClass}=="00"
ATTRS{bDeviceProtocol}=="00"
ATTRS{bDeviceSubClass}=="00"
ATTRS{bMaxPacketSize0}=="9"
ATTRS{bMaxPower}=="896mA"
ATTRS{bNumConfigurations}=="1"
ATTRS{bNumInterfaces}==" 1"
ATTRS{bcdDevice}=="0100"
ATTRS{bmAttributes}=="80"
ATTRS{busnum}=="3"
ATTRS{configuration}==""
ATTRS{devnum}=="4"
ATTRS{devpath}=="3"
ATTRS{idProduct}=="5583"
ATTRS{idVendor}=="0781"
ATTRS{ltm_capable}=="no"
ATTRS{manufacturer}==" USB"
ATTRS{maxchild}=="0"
ATTRS{physical_location/dock}=="no"
ATTRS{physical_location/horizontal_position}=="left"
ATTRS{physical_location/lid}=="no"
ATTRS{physical_location/panel}=="unknown"
ATTRS{physical_location/vertical_position}=="upper"
ATTRS{power/active_duration}=="31341730"
ATTRS{power/async}=="enabled"
ATTRS{power/autosuspend}=="-1"
ATTRS{power/autosuspend_delay_ms}=="-1000"
ATTRS{power/connected_duration}=="31342655"
ATTRS{power/control}=="on"
ATTRS{power/level}=="on"
ATTRS{power/persist}=="1"
ATTRS{power/runtime_active_kids}=="1"
ATTRS{power/runtime_active_time}=="31342168"
ATTRS{power/runtime_enabled}=="forbidden"
ATTRS{power/runtime_status}=="active"
ATTRS{power/runtime_suspended_time}=="0"
ATTRS{power/runtime_usage}=="2"
ATTRS{product}==" SanDisk 3.2Gen1"
ATTRS{quirks}=="0x400"
ATTRS{removable}=="removable"
ATTRS{remove}=="(not readable)"
ATTRS{rx_lanes}=="1"
ATTRS{serial}=="00023215022225165640"
ATTRS{speed}=="5000"
ATTRS{tx_lanes}=="1"
ATTRS{urbnum}=="31631"
ATTRS{version}==" 3.20"
looking at parent device '/devices/pci0000:00/0000:00:10.0/usb3':
KERNELS=="usb3"
SUBSYSTEMS=="usb"
DRIVERS=="usb"
ATTRS{authorized}=="1"
ATTRS{authorized_default}=="1"
ATTRS{avoid_reset_quirk}=="0"
ATTRS{bConfigurationValue}=="1"
ATTRS{bDeviceClass}=="09"
ATTRS{bDeviceProtocol}=="03"
ATTRS{bDeviceSubClass}=="00"
ATTRS{bMaxPacketSize0}=="9"
ATTRS{bMaxPower}=="0mA"
ATTRS{bNumConfigurations}=="1"
ATTRS{bNumInterfaces}==" 1"
ATTRS{bcdDevice}=="0614"
ATTRS{bmAttributes}=="e0"
ATTRS{busnum}=="3"
ATTRS{configuration}==""
ATTRS{devnum}=="1"
ATTRS{devpath}=="0"
ATTRS{idProduct}=="0003"
ATTRS{idVendor}=="1d6b"
ATTRS{interface_authorized_default}=="1"
ATTRS{ltm_capable}=="yes"
ATTRS{manufacturer}=="Linux 6.14.0-35-generic xhci-hcd"
ATTRS{maxchild}=="4"
ATTRS{power/active_duration}=="31998874"
ATTRS{power/async}=="enabled"
ATTRS{power/autosuspend}=="-1"
ATTRS{power/autosuspend_delay_ms}=="-1000"
ATTRS{power/connected_duration}=="31999661"
ATTRS{power/control}=="on"
ATTRS{power/level}=="on"
ATTRS{power/runtime_active_kids}=="1"
ATTRS{power/runtime_active_time}=="31999200"
ATTRS{power/runtime_enabled}=="forbidden"
ATTRS{power/runtime_status}=="active"
ATTRS{power/runtime_suspended_time}=="0"
ATTRS{power/runtime_usage}=="2"
ATTRS{power/wakeup}=="disabled"
ATTRS{power/wakeup_abort_count}==""
ATTRS{power/wakeup_active}==""
ATTRS{power/wakeup_active_count}==""
ATTRS{power/wakeup_count}==""
ATTRS{power/wakeup_expire_count}==""
ATTRS{power/wakeup_last_time_ms}==""
ATTRS{power/wakeup_max_time_ms}==""
ATTRS{power/wakeup_total_time_ms}==""
ATTRS{product}=="xHCI Host Controller"
ATTRS{quirks}=="0x0"
ATTRS{removable}=="unknown"
ATTRS{remove}=="(not readable)"
ATTRS{rx_lanes}=="1"
ATTRS{serial}=="0000:00:10.0"
ATTRS{speed}=="5000"
ATTRS{tx_lanes}=="1"
ATTRS{urbnum}=="242"
ATTRS{version}==" 3.00"
looking at parent device '/devices/pci0000:00/0000:00:10.0':
KERNELS=="0000:00:10.0"
SUBSYSTEMS=="pci"
DRIVERS=="xhci_hcd"
ATTRS{ari_enabled}=="0"
ATTRS{broken_parity_status}=="0"
ATTRS{class}=="0x0c0330"
ATTRS{consistent_dma_mask_bits}=="64"
ATTRS{current_link_speed}=="Unknown"
ATTRS{current_link_width}=="0"
ATTRS{d3cold_allowed}=="1"
ATTRS{dbc}=="disabled"
ATTRS{dbc_bInterfaceProtocol}=="01"
ATTRS{dbc_bcdDevice}=="0010"
ATTRS{dbc_idProduct}=="0010"
ATTRS{dbc_idVendor}=="1d6b"
ATTRS{dbc_poll_interval_ms}=="64"
ATTRS{device}=="0x7914"
ATTRS{dma_mask_bits}=="64"
ATTRS{driver_override}=="(null)"
ATTRS{enable}=="1"
ATTRS{irq}=="18"
ATTRS{local_cpulist}=="0-1"
ATTRS{local_cpus}=="3"
ATTRS{max_link_speed}=="Unknown"
ATTRS{max_link_width}=="255"
ATTRS{msi_bus}=="1"
ATTRS{msi_irqs/27}=="msix"
ATTRS{msi_irqs/28}=="msix"
ATTRS{msi_irqs/29}=="msix"
ATTRS{numa_node}=="-1"
ATTRS{power/async}=="enabled"
ATTRS{power/control}=="on"
ATTRS{power/runtime_active_kids}=="2"
ATTRS{power/runtime_active_time}=="31999531"
ATTRS{power/runtime_enabled}=="forbidden"
ATTRS{power/runtime_status}=="active"
ATTRS{power/runtime_suspended_time}=="0"
ATTRS{power/runtime_usage}=="3"
ATTRS{power/wakeup}=="disabled"
ATTRS{power/wakeup_abort_count}==""
ATTRS{power/wakeup_active}==""
ATTRS{power/wakeup_active_count}==""
ATTRS{power/wakeup_count}==""
ATTRS{power/wakeup_expire_count}==""
ATTRS{power/wakeup_last_time_ms}==""
ATTRS{power/wakeup_max_time_ms}==""
ATTRS{power/wakeup_total_time_ms}==""
ATTRS{power_state}=="D0"
ATTRS{remove}=="(not readable)"
ATTRS{rescan}=="(not readable)"
ATTRS{resource0}=="(not readable)"
ATTRS{revision}=="0x20"
ATTRS{subsystem_device}=="0x380b"
ATTRS{subsystem_vendor}=="0x17aa"
ATTRS{vendor}=="0x1022"
looking at parent device '/devices/pci0000:00':
KERNELS=="pci0000:00"
SUBSYSTEMS==""
DRIVERS==""
ATTRS{power/async}=="enabled"
ATTRS{power/control}=="auto"
ATTRS{power/runtime_active_kids}=="21"
ATTRS{power/runtime_active_time}=="0"
ATTRS{power/runtime_enabled}=="disabled"
ATTRS{power/runtime_status}=="unsupported"
ATTRS{power/runtime_suspended_time}=="0"
ATTRS{power/runtime_usage}=="0"
ATTRS{waiting_for_supplier}=="0"
I notice from some manual experimenting with unmounting/remounting and unbinding/rebinding that the sda block is simply gone, and after a replug the drive is reconfigured under sdc (sdb is the main internal drive). Issuing the below on a normal working system:
echo 0000:00:10.0 > /sys/bus/pci/drivers/xhci_hcd/unbind
then suspending the system for a while before waking then issuing
echo 0000:00:10.0 > /sys/bus/pci/drivers/xhci_hcd/bind
works fine IF the system wake happens before an hour elapses (I think it was an hour but I could be wrong on the exact time it takes to enter a deeper suspend state). At any rate, if I leave it suspended for too long on battery the block device disappears.
This isn't a huge deal since I don't often suspend on battery for any great length of time, and a replug of the USB device is all that is necessary. However, it does happen occasionally and I would prefer to minimise physical replugging if there is another way.
Any ideas? I suspect it might not be possible with that USB device and the 'proper' solution is a bigger SSD. Still, I am open to suggestions.
TIA
EDIT I have added the fstab entry above and will attach dmesg logs of a clean suspend/resume on power versus a failed suspend/resume on battery. I am also going to change the drive from fat to ext4 and retest, although I can't see that making any difference.
--
Mark