all repos — nixfiles @ 0ec55c7bd5465d93ed406aef3bf6c1d0bdb5e003

System and user configuration, managed by nix and home-manager

bare-metal: set optimal IO scheduler per disk type
Alan Pearce alan@alanpearce.eu
Tue, 12 Jan 2021 17:02:27 +0100
commit

0ec55c7bd5465d93ed406aef3bf6c1d0bdb5e003

parent

82eac6549fe01ecd4b8aec799f1dba37eb253ecd

1 files changed, 9 insertions(+), 0 deletions(-)

jump to
M system/settings/hardware/bare-metal.nixsystem/settings/hardware/bare-metal.nix
@@ -9,6 +9,15 @@ pciutils     usbutils
   ];
 
+  services.udev.extraRules = ''
+    # set scheduler for NVMe
+    ACTION=="add|change", KERNEL=="nvme[0-9]n[0-9]", ATTR{queue/scheduler}="none"
+    # set scheduler for SSD and eMMC
+    ACTION=="add|change", KERNEL=="sd[a-z]|mmcblk[0-9]*", ATTR{queue/rotational}=="0", ATTR{queue/scheduler}="mq-deadline"
+    # set scheduler for rotating disks
+    ACTION=="add|change", KERNEL=="sd[a-z]", ATTR{queue/rotational}=="1", ATTR{queue/scheduler}="bfq"
+  '';
+
   boot.kernel.sysctl = {
     "net.ipv4.tcp_allowed_congestion_control" = "illinois reno lp";
     "net.ipv4.tcp_congestion_control" = "illinois";