You are not logged in.

#1 2026-02-23 13:39:47

Enrico1989
Member
Registered: 2018-07-05
Posts: 298

[SOLVED] How can I investigate USB not being detected?

Often it happens that I insert a USB storage device, and then expect it to find it in the output of

sudo fdisk -l

but I don't.

At that point I just reboot the machine, and the command above will show the device too. No need for me to even remove and re-plug the USB device.

So something must be happening while my system is up.

Is there something I can do now (I've just rebooted, so the USB has been detected) or next time the issue occurs to gather more info for you to help me?

At https://wiki.archlinux.org/title/USB_storage_devices, the https://wiki.archlinux.org/title/USB_st … e_detected section doesn't seem to apply to me, because in my case a reboot is enough to get the USBs detected.

Last edited by Enrico1989 (2026-02-24 10:50:53)

Offline

#2 2026-02-23 13:43:57

Scimmia
Fellow
Registered: 2012-09-01
Posts: 13,584

Re: [SOLVED] How can I investigate USB not being detected?

Next time it happens, check uname -r and pacman -Q linux (substitute with your kernel package). This usually happens because you've updated the kernel and don't have the necessary modules loaded. Since the modules for the old kernel are no longer on disk, it can't load anything new.

Offline

#3 2026-02-23 13:54:46

Enrico1989
Member
Registered: 2018-07-05
Posts: 298

Re: [SOLVED] How can I investigate USB not being detected?

Well, I suppose given I often keep the system up for days and days, and that I'm running pacman -Syu everytime I see even a single update, I suppose it's most likely that's exactly what's happening.

Scimmia wrote:

(substitute with your kernel package)

pacman -Q linux tab-completes to just

linux                  linux-api-headers      linux-firmware-whence  linux-headers

according to that and to https://wiki.archlinux.org/title/Kernel, I assume I've got the "linux" kernel package, right?

Scimmia wrote:

Next time it happens, check uname -r and pacman -Q linux

I suppose the expectation is that the former would give me an older version than the latter?

So is there nothing I can check now to verify that between the last boot and the previous one there was indeed a kernel update?

Offline

#4 2026-02-23 20:00:18

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 25,064

Re: [SOLVED] How can I investigate USB not being detected?

Check the /var/log/pacman.log if the previous update included the linux package that will be the relevant difference.

Offline

#5 2026-02-23 21:36:54

dimich
Member
From: Kharkiv, Ukraine
Registered: 2009-11-03
Posts: 493

Re: [SOLVED] How can I investigate USB not being detected?

Although it is recommended to boot new kernel as soon as it is updated, sometimes you can't reboot immediately. To avoid lack of modules in such situation you can force some modules to be always loaded after boot.
E.g. in /etc/modules-load.d/usb.conf:

usb_storage
uas

/etc/modules-load.d/filesystem.conf:

vfat
nls_utf8
nls_cp437
nls_iso8859-1

Drawback is some tiny extra RAM usage. There is also another option to load important modules in kernel hook before update, but it's more tricky.

Offline

#6 2026-02-23 23:39:45

mmy8x
Member
Registered: 2025-03-02
Posts: 91

Re: [SOLVED] How can I investigate USB not being detected?

If you can get kernel logs from the last few boots (journalctl or something) then the first few lines of each log should tell which kernel version was booted.

Next time you see something like that it would make sense to run dmesg and see the final lines - was the device detected, are any drivers loading, are there any errors.

Last edited by mmy8x (2026-02-23 23:41:40)

Offline

#7 2026-02-24 10:50:30

Enrico1989
Member
Registered: 2018-07-05
Posts: 298

Re: [SOLVED] How can I investigate USB not being detected?

V1del wrote:

Check the /var/log/pacman.log if the previous update included the linux package that will be the relevant difference.

Thanks.

For my own reference, this tells me when the last update to the linux package occurred:

grep ' linux ' /var/log/pacman.log | tail -1
/var/log/pacman.log:[2026-02-14T10:18:05+0100] [ALPM] upgraded linux (6.18.8.arch2-1 -> 6.18.9.arch1-2)

so last update to linux was on February the 14th.

This tells me  the first time yesterday I was surprised running fdisk wouldn't show the usb drive I had physically plugged in:

history | grep ' 23/02/26 .* fdisk' | head -1
25097  23/02/26 14:11:55 sudo fdisk -l

This tells me the times of the last reboots:

for ((i=0; i<5; ++i)); do journalctl -b -$i 2>/dev/null | head -n 1; done | tac | cut -d' ' -f 1-3
Jan 30 23:13:28
Feb 03 17:00:05
Feb 10 17:00:56
Feb 23 14:19:34
Feb 24 07:41:38

So yeah, when I experienced the issue, I had not rebooted since the last update to the linux package, and rebooting fixed the issue.

dimich wrote:

Although it is recommended to boot new kernel as soon as it is updated

I should keep this in mind!

Offline

#8 2026-02-24 18:39:34

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 25,064

Re: [SOLVED] How can I investigate USB not being detected?

If you want to fix this more globally: https://archlinux.org/packages/extra/an … ules-hook/ contains alpm hooks and systemd services to maintain at least a current boot's worth of kernel modules and cleaning them up once booted into a new one.

Offline

#9 2026-02-28 07:23:26

Enrico1989
Member
Registered: 2018-07-05
Posts: 298

Re: [SOLVED] How can I investigate USB not being detected?

I have a simple follow up question regarding this

Scimmia wrote:

pacman -Q linux (substitute with your kernel package)

I suppose the various "linux-*"-named packages at https://wiki.archlinux.org/title/Kernel are alternative kernels that might be in use, but what is the programmatic way to determine the name of the kernel package in use on a system?

Even uname -a doesn't seem to contain the name of the package.

(I'm asking because I show the number of available updates in a status bar, and I could change the message to tell if one if the updates is the kernel update, so I know I have to reboot afterwards.)

Offline

#10 2026-02-28 16:16:48

dimich
Member
From: Kharkiv, Ukraine
Registered: 2009-11-03
Posts: 493

Re: [SOLVED] How can I investigate USB not being detected?

Enrico1989 wrote:

what is the programmatic way to determine the name of the kernel package in use on a system?

The kernel is identified by version string including EXTRAVERSION suffix, not by package name. I have written small python program "linux-version" to extract version string from vmlinuz image. I use it in shell script to list running and installed versions:

#!/bin/bash
echo -n "Running:   "; uname -r
for file in /usr/lib/modules/*/vmlinuz; do
    echo -n "Installed: "
    linux-version "$file" | sed 's/ .*$//'
done

You can also iterate installed /usr/lib/modules/*/vmlinuz files, and if vmlinuz version matches "uname -r" value, query which package owns that vmlinuz file with "pacman -Qoq /path/to/vmlinuz".

Offline

#11 2026-03-01 02:02:55

dimich
Member
From: Kharkiv, Ukraine
Registered: 2009-11-03
Posts: 493

Re: [SOLVED] How can I investigate USB not being detected?

dimich wrote:

You can also iterate installed /usr/lib/modules/*/vmlinuz files, and if vmlinuz version matches "uname -r" value

Ah, I just realized this won't work if update already happened. So you should scan installed images right after boot before any update may happen, and store package name somewhere.
Or try to parse suffix from the version string, e.g.

#!/bin/bash

flavor()
{
    sed -n 's/.*-\([[:alpha:]_]\+\).*/\1/p'
}

running_flavor=$(uname -r | flavor)
linux_package=''

for file in /usr/lib/modules/*/vmlinuz; do
    if [[ $(linux-version "$file" | flavor) == "$running_flavor" ]]; then
        linux_package=$(pacman -Qoq "$file")
        break;
    fi
done

if [[ -n "$linux_package" ]]; then
    echo "Running kernel from package '$linux_package'"
else
    echo "Running kernel from unknown package"
fi

However, this is volatile to version naming policy.

Last edited by dimich (2026-03-01 02:07:16)

Offline

Board footer

Powered by FluxBB