In DMESG I see:
[sdb] Attached SCSI removable disk
- How does Linux decide what is removable and not removable?
- Is there a way I can look up if a device is "removable" or not other than the log, for example somehwere in /sys or /proc?
You can query this attribute from a udev rule, with
Note that removable (the device keeps existing but may have no media) isn't the same thing as hotpluggable (the device can come and go). For example, CD drives are removable but often not hotpluggable. USB flash drives are both, but hard disks in external enclosures are typically hotpluggable but not removable.
If you want to find out the nitty-gritty of when a device is considered removable, you'll have to dig into the kernel source. Search for
removable — there aren't too many spurious hits. For SCSI devices, the
removable bit is read from the device in
scsi_add_lun with a SCSI INQUIRY command.
With a little effort I found the answer to my second question: