Configure sysfs during system boot to apply custom configuration using a simple and convenient way.
Installation
Update package index.
$ sudo apt update
Ign:1 http://ftp.task.gda.pl/debian stretch InRelease Hit:2 http://ftp.task.gda.pl/debian stretch-updates InRelease Hit:3 http://ftp.task.gda.pl/debian stretch Release Hit:4 http://security.debian.org/debian-security stretch/updates InRelease Reading package lists... Done Building dependency tree Reading state information... Done All packages are up to date.
Install sysfs query tool and boot-time setup.
$ sudo apt install -y sysfsutils
Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: libsysfs2 The following NEW packages will be installed: libsysfs2 sysfsutils 0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded. Need to get 53.3 kB of archives. After this operation, 151 kB of additional disk space will be used. Get:1 http://ftp.task.gda.pl/debian stretch/main amd64 libsysfs2 amd64 2.1.0+repack-4+b2 [27.8 kB] Get:2 http://ftp.task.gda.pl/debian stretch/main amd64 sysfsutils amd64 2.1.0+repack-4+b2 [25.4 kB] Fetched 53.3 kB in 0s (171 kB/s) Selecting previously unselected package libsysfs2:amd64. (Reading database ... 31592 files and directories currently installed.) Preparing to unpack .../libsysfs2_2.1.0+repack-4+b2_amd64.deb ... Unpacking libsysfs2:amd64 (2.1.0+repack-4+b2) ... Selecting previously unselected package sysfsutils. Preparing to unpack .../sysfsutils_2.1.0+repack-4+b2_amd64.deb ... Unpacking sysfsutils (2.1.0+repack-4+b2) ... Setting up libsysfs2:amd64 (2.1.0+repack-4+b2) ... Setting up sysfsutils (2.1.0+repack-4+b2) ... update-rc.d: warning: start and stop actions are no longer supported; falling back to defaults Processing triggers for libc-bin (2.24-11+deb9u3) ... Processing triggers for systemd (232-25+deb9u6) ... Processing triggers for man-db (2.7.6.1-2) ...
Inspect service status.
$ systemctl status sysfsutils
● sysfsutils.service - LSB: Set sysfs variables from /etc/sysfs.conf Loaded: loaded (/etc/init.d/sysfsutils; generated; vendor preset: enabled) Active: active (exited) since Wed 2018-12-05 22:27:55 CET; 5min ago Docs: man:systemd-sysv-generator(8)
Ensure that service is enabled at boot time.
$ systemctl is-enabled sysfsutils
sysfsutils.service is not a native service, redirecting to systemd-sysv-install. Executing: /lib/systemd/systemd-sysv-install is-enabled sysfsutils enabled
Configuration
Inspect sysfs value you want to change at boot time.
$ cat /sys/block/sda/queue/scheduler noop deadline [cfq]
Create configuration file with desired value inside /etc/sysfs.d/
directory.
$ echo "block/sda/queue/scheduler = noop" | sudo tee /etc/sysfs.d/sda_scheduler.conf block/sda/queue/scheduler = noop
Restart sysfsutils
service, you do not need to perform system reboot.
$ sudo systemctl restart sysfsutils
See it for yourself.
$ cat /sys/block/sda/queue/scheduler [noop] deadline cfq