Home / Alt manpages / proc_sys_dev(5)

  • proc_sys_dev(5)
  • File format
  • linux

Inspect and Safely Tune Linux Device Settings under /proc/sys/dev

A driver setting needs checking, so start at /proc/sys/dev/ and list what your own kernel actually exposes. Allow about ten minutes. You need a shell for inspection, and an account with sudo only for the optional write step.

Before you start

/proc/sys/dev/ is the proc filesystem's directory for device-specific kernel information. The local proc_sys_dev(5) manpage gives dev/cdrom/info as an example and warns the directory can be empty on some systems. It is not a universal inventory of every device, and it is not a directory of ordinary config files on disk.

This documentation is from Linux man-pages 6.7, package version 6.7-2. The kernel, drivers, hardware and boot configuration decide which entries actually appear, so treat the live filesystem as the authority for this host.

1. List the settings your host exposes

Start with a read-only listing. This prints files only, so individual values are easier to spot than in a long recursive directory listing:

find /proc/sys/dev -type f -print | sort

On one current host this includes entries under cdrom, hpet, mac_hid, raid, scsi and tty. Your result may be shorter, longer or empty. An empty result is a supported outcome, not proof the kernel has no devices.

2. Read one value and its context

Pick a path from your own listing. For example, dev.cdrom.autoclose is exposed here: read the proc file directly, then use sysctl if it is installed. The dots in the second command are the same path separators shown as slashes in the first:

cat /proc/sys/dev/cdrom/autoclose
sysctl dev.cdrom.autoclose

Expected output on this host is:

1
dev.cdrom.autoclose = 1

These are live kernel values. They are not necessarily persistent, and they are not guaranteed to exist after a driver is removed or on a different kernel. If a path is absent, do not create a replacement file; re-run the inventory and check the relevant driver documentation instead.

3. Inspect a group without changing it

sysctl can show the whole device namespace as key-value pairs. Suppress errors, since some entries can disappear while drivers change, then keep the output for comparison before any tuning:

sysctl -a 2>/dev/null | grep '^dev\.'

Still read-only. Do not treat names found in an online example as portable: this host has dev.raid.speed_limit_min and dev.tty.ldisc_autoload, but a server without those kernel facilities may not.

Checkpoint

Before writing anything, note the setting's kernel or driver documentation, its current value, and how you would restore it. A write may also need elevated privileges.

4. Make one reversible runtime change

The following changes the CD-ROM driver's automatic tray-close setting on a host where that exact file exists. It is deliberately a small example, not a recommendation for a production machine, and it may affect the next tray operation, so run it only when that is acceptable:

setting=/proc/sys/dev/cdrom/autoclose
old=$(cat "$setting")
printf 'old value: %s\n' "$old"
printf '0\n' | sudo tee "$setting"
cat "$setting"

Expected output includes the value you saved, then 0, then 0 again. If the file is missing, stop rather than substitute another path. If the write fails, the value was not confirmed; read it again before deciding what happened.

Restore the saved value as soon as you finish testing. Replace OLD_VALUE_FROM_ABOVE with the value your own command printed:

printf '%s\n' 'OLD_VALUE_FROM_ABOVE' | sudo tee /proc/sys/dev/cdrom/autoclose
cat /proc/sys/dev/cdrom/autoclose

Recovery

The final command must print the original value. If you lost it, stop making changes and consult the driver documentation rather than guessing. A runtime write normally lasts only until the setting is reinitialised or the system reboots; persistence, if needed, belongs in the distribution's sysctl configuration and should be tested separately.

Common traps

  • Confusing absence with failure. /proc/sys/dev/ may be empty, and device-specific files vary by kernel and hardware.
  • Assuming every file is writable. Some entries are information only, and a successful read does not grant permission to write.
  • Mixing names and paths. /proc/sys/dev/raid/speed_limit_min maps to dev.raid.speed_limit_min for sysctl, but only when that file exists.
  • Expecting persistence. A value read from procfs describes the running system; record deliberate persistent settings through your distribution's normal configuration process, with a recovery plan.
  • Using a recursive write. Never pipe a bulk listing into a write command. Each setting has its own meaning and its own safety boundary.

Done means

  • Listed the actual files under /proc/sys/dev on the target host.
  • Verified one value with a direct read and, where available, sysctl.
  • Checked existence before considering a write.
  • Recorded the old value, made only a deliberate runtime change, and restored it when testing ended.
  • Know the limit: device-specific proc settings are host- and kernel-dependent, not portable files to copy between systems.