1

When I plug in USB disk, I get a message like this:

kernel: usb 2-10.2: new SuperSpeed USB device number 5 using xhci_hcd
kernel: usb-storage 2-10.2:1.0: USB Mass Storage device detected
kernel: scsi 10:0:0:0: Direct-Access     SanDisk  Ultra            1.00 PQ: 0 ANSI: 6
kernel: sd 10:0:0:0: [sdf] 30031872 512-byte logical blocks: (15.4 GB/14.3 GiB)
kernel:  sdf: sdf1
kernel: sd 10:0:0:0: [sdf] Attached SCSI removable disk

when I disconnect the USB disk, I get message which is much less helpful:

kernel: usb 2-10.2: USB disconnect, device number 5

why does kernel not tell me which disk was disconnected? Suppose I have several USB disks plugged in. I would like to know that I have disconnected disk sde.

Can anything be dome about this?

I am using rsyslog as login daemon, on Debian 10.

Martin Vegter
  • 358
  • 75
  • 236
  • 411
  • 2
    why does kernel not tell me which disk was disconnected? - hmm but it does, what message did you expect to see? – Arkadiusz Drabczyk Sep 05 '22 at 17:22
  • @Arkadiusz Drabczyk - I would like to see message, that includes the name of the disk (sdf in this example). So something like: kernel: usb 2-10.2: USB disconnect, device /dev/sdf. – Martin Vegter Sep 18 '22 at 05:16
  • Just for the record, the messages about sda, sdf etc are coming from the block subsystem not from the usb subsystem. As far as the latter is concerned, anything that's plugged in/out is a usb device and is reported as such, with the bus-port:device.interface number. The messages from the former look like block device /sys/devices[...]/block/sda/sda1 has been removed. I know this is a late comment but I found your question while searching for related posts before writing my answer here – don_crissti Nov 29 '23 at 13:54

1 Answers1

2

This does not satisfy as an answer, yet I came across your question and here is my observation. Below outputs are taken from journalctl -fa

Following this askubuntu topic I found out the lines outputting [sdb] are actually due to eject command or some equivelant of it.

Output of eject /dev/sdb:

Sep 05 14:30:54 knight kernel: sdb: detected capacity change from 60493824 to 0

Output of eject -t /dev/sdb:

Sep 05 14:30:59 knight kernel: sd 2:0:0:0: [sdb] 60493824 512-byte logical blocks: (31.0 GB/28.8 GiB)
Sep 05 14:30:59 knight kernel: sdb: detected capacity change from 0 to 60493824
Sep 05 14:30:59 knight kernel:  sdb: sdb1 sdb2
Sep 05 14:30:59 knight kernel:  sdb: sdb1 sdb2

What was done above is safely removing (same output if performed from Thunar file manager as well), and replugging it in software (rather than physically).

You are pulling the rug under sd's feet, it is not acknowledged and does not log it. But it logs if is properly acknowledged. However, I don't know why sd does not log it afterwards either.

It seems plausible that it could state a missing disk, since somehow these lines were output:

Sep 05 14:31:24 knight kernel: usb 4-1: USB disconnect, device number 10
Sep 05 14:31:35 knight kernel: xhci_hcd 0000:00:10.0: Abort failed to stop command ring: -110
Sep 05 14:31:35 knight kernel: xhci_hcd 0000:00:10.0: Host halt failed, -110
Sep 05 14:31:35 knight kernel: xhci_hcd 0000:00:10.0: xHCI host controller not responding, assume dead
Sep 05 14:31:35 knight kernel: xhci_hcd 0000:00:10.0: HC died; cleaning up
Sep 05 14:31:35 knight kernel: xhci_hcd 0000:00:10.0: Timeout while waiting for setup device command
Sep 05 14:31:35 knight kernel: usb 4-1: device not accepting address 11, error -108
Sep 05 14:31:35 knight kernel: usb usb4-port1: couldn't allocate usb_device

But again, I am not knowledgeable enough on SCSI nor the kernel to answer the question at hand.

cbugk
  • 436