Well, there is a "removable" flag implemented as a file underneath `/sys but....
For example, on my system, this file underneath /sys
represents disk /dev/sde
implemented by an attached USB hard disk (the USB device found on "bus 1 -> port 2 -> config 1 -> interface 0")
/sys/devices/pci0000:00/0000:00:02.1/usb1/1-2/1-2:1.0/host9/target9:0:0/9:0:0:0/block/sde
The subpath
/sys/devices/pci0000:00/0000:00:02.1/usb1/1-2
which is the USB device found on "bus 1 -> port 2" seems to represent the USB device itself.
Let's look for the "removable" files using find
and print their contents using cat
:
$ cd /sys/devices/pci0000:00/0000:00:02.1/usb1/1-2
$ find . -name removable -exec echo -n '{}: ' ";" -exec cat '{}' ";"
./1-2:1.0/host9/target9:0:0/9:0:0:0/block/sde/removable: 0
./removable: unknown
So, the "device" is not known to be removable, and the "disk" is not removable (assuming '0' means 'no'). Not very helpful.