I want to add a udev rule to set sysctl -w vm.swappiness = 100 on machines where the boot partition is on a flash storage device.

My current system uses an NVMe card, which I can detect as SUBSYSTEM="nvme", but I think (I don't have one available to check at the moment) that value for SATA SSDs is "scsi", which is not SSD-specific. Actually, as I write this I dimly recall some manufacturer recently announced spinning disk NVMes for some niche usage, so that's not perfect either (though it'd be fine for my purposes).

How can I somewhat reliably detect the.. 'technology' of a storage device in a udev rule?

  • 1
    what's the "technology" you mean? Because SSDs are "flash storage devices"; and any "flash storage device" with an integrated flash abstraction layer is an SSD. So, where you want to make a difference, there is none. Nov 23, 2021 at 13:14
  • @MarcusMüller Yes, exactly? But SCSI could be a spinning disk right? So unless you're saying SSDs (or HDDs) don't use SUBSYSTEM="scsi" as I said/assumed, I can't use 'scsi or nvme' to determine if it's flash. I'm not sure what isn't clear, but the goal is exactly to determine if it's a "flash storage device" which, yes, includes SSDs.
    – OJFord
    Nov 23, 2021 at 15:43
  • @MarcusMüller The only "difference I want to make" is that I'm stating that SSDs not on an NVMe card ("SATA SSDs") do not identify as "nvme", which is.. I would think obvious and uncontroversial.
    – OJFord
    Nov 23, 2021 at 15:51

1 Answer 1


You can check /sys/block/*/queue/rotational for finding out whether the kernel thinks it is a storage device with a rotating medium. This is independent of the subsystem.

And it is even available in udev:

udevadm info -a /dev/nvme0n1 | grep -F 'ATTR{queue/rotational}'
  • Nice, thanks, I'm tempted to accept this answer because I don't actually need it to be in a udev rule (in which I'm not sure how I would check the contents of this file?)... so, apologies to future searchers who do I suppose!
    – OJFord
    Nov 23, 2021 at 15:46
  • @OJFord It does work with udev, too; see my edit. Nov 23, 2021 at 15:54
  • Perfect, thanks!
    – OJFord
    Nov 23, 2021 at 15:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .