Devices#
Linux exposes hardware through device nodes in /dev, kernel state in
/sys, and runtime info in /proc. Hot-plug events are routed by
udev (systemd-udevd), which creates the nodes, applies
permissions, and triggers actions. Drivers ship as kernel modules loaded
on demand. The catalog of device nodes themselves lives in
Filesystem (the /dev section).
Subsystems#
Every kernel device belongs to one or more subsystems, exposed under
/sys/class (by function) and /sys/bus (by attachment). The
subsystem decides which character or block node appears under
/dev, which ioctls work, and which userspace daemon owns the
device.
Subsystem |
sysfs path |
Typical nodes / tools |
|---|---|---|
block |
|
|
net |
|
|
tty |
|
|
input |
|
|
drm |
|
|
sound |
|
|
usb |
|
|
pci |
|
|
hidraw |
|
|
iio |
|
Industrial / sensor devices |
power_supply |
|
|
$ ls /sys/class
$ ls /sys/class/block
$ ls /sys/bus/usb/devices
$ readlink -f /sys/class/net/eth0
$ cat /sys/class/net/eth0/address
Inspection#
The first move when something is wrong with hardware is to enumerate what the kernel actually sees. The same set of tools serves whether the operator is auditing a fresh image, chasing a missing device, or characterizing an unfamiliar host.
Tool |
Reports |
|---|---|
|
Block devices, partitions, mount points |
|
Filesystem type, label, UUID |
|
Filesystem labels and UUIDs |
|
PCI devices ( |
|
USB devices ( |
|
CPU topology, flags, vulnerabilities |
|
Online / offline memory blocks |
|
Composite hardware report |
|
SMBIOS / DMI (BIOS, board, RAM SPD) |
|
openSUSE-derived comprehensive prober |
|
Friendly summary |
|
ATA disk identification |
|
NVMe namespaces |
|
SMART health for a disk |
$ lsblk -f
$ lspci -nnk | grep -A2 -i vga
$ lsusb -tv
$ lscpu | grep -E 'Model name|MHz|Vulnerab'
$ sudo dmidecode -t memory | grep -E 'Size|Speed|Type:|Locator'
$ sudo smartctl -a /dev/sda | head -40
Udev#
udev watches the kernel uevent netlink socket and reacts to
hot-plug events. It creates and removes device nodes under /dev,
sets ownership and permissions, loads firmware, and runs
operator-defined actions through rule files in
/etc/udev/rules.d/.
Field |
Purpose |
|---|---|
|
|
|
|
|
Kernel-assigned name ( |
|
sysfs attribute (e.g. |
|
Environment variable on the event |
|
Set node name |
|
Add a stable symlink in |
|
Permission ( |
|
|
|
Run a program on the event |
A stable symlink for a USB serial adapter.
$ udevadm info -a -n /dev/ttyUSB0 | head -40
$ sudo install -m 0644 /dev/stdin /etc/udev/rules.d/10-ftdi.rules <<'EOF'
$ SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", \
SYMLINK+="ftdi", MODE="0660", GROUP="dialout"
$ EOF
$ sudo udevadm control --reload
$ sudo udevadm trigger --subsystem-match=tty
Inspect events live.
$ udevadm monitor --udev --property
$ udevadm test /sys/class/net/eth0
Kernel Modules#
Drivers and many kernel features ship as loadable modules rather than
being compiled into the kernel image. They are loaded on demand by
udev when matching hardware appears, pulled in by another
module’s dependency, or loaded explicitly with modprobe.
Tool |
What it does |
|---|---|
|
List currently loaded modules |
|
Show metadata, parameters, dependencies |
|
Load (with deps); honors |
|
Load a single |
|
Remove a module |
|
Rebuild |
|
Kernel messages (driver init and errors) |
$ lsmod | head
$ modinfo nvme | head -20
$ sudo modprobe -v vfio-pci
$ sudo modprobe -r vfio-pci
$ dmesg --human --follow
$ echo nvme | sudo tee /etc/modules-load.d/nvme.conf
$ echo 'options snd_hda_intel power_save=1' | \
sudo tee /etc/modprobe.d/snd-power.conf
$ echo 'blacklist nouveau' | sudo tee /etc/modprobe.d/blacklist-nouveau.conf
$ sudo update-initramfs -u
Block Layer#
Above the raw block device sits an optional stack. Partitions, then device-mapper (LUKS, LVM, multipath), then MD RAID, then a filesystem. Each layer is independent, so a single physical disk can carry encryption, logical volumes, and a filesystem all at once.
Tool |
Layer |
|---|---|
|
GPT / MBR partitioning (scriptable) |
|
MBR partitioning (interactive) |
|
GPT partitioning (interactive) |
|
LUKS / dm-crypt volumes |
|
LVM physical volumes, volume groups, logical vols |
|
Software RAID |
|
Multipath I/O over redundant SAN paths |
|
Create filesystems |
|
Check / repair filesystems |
|
Mount / unmount |
|
Loop devices (file-backed block devices) |
Partition + LUKS + ext4 on a fresh disk.
$ sudo parted -s /dev/sdb mklabel gpt mkpart primary 1MiB 100%
$ sudo cryptsetup luksFormat /dev/sdb1
$ sudo cryptsetup open /dev/sdb1 vault
$ sudo mkfs.ext4 -L vault /dev/mapper/vault
$ sudo mkdir /mnt/vault
$ sudo mount /dev/mapper/vault /mnt/vault
$ lsblk -o NAME,TYPE,FSTYPE,MOUNTPOINT,SIZE
Storage Health#
Spinning rust and SSDs both report health via SMART, the on-disk
telemetry every modern drive exposes. Run scheduled self-tests with
smartctl, and alert on reallocated sectors, pending sectors, and
media-wear indicators (the leading signs of imminent failure).
$ sudo smartctl -i /dev/sda
$ sudo smartctl -H /dev/sda
$ sudo smartctl -a /dev/sda
$ sudo smartctl -t short /dev/sda
$ sudo smartctl -t long /dev/sda
$ sudo nvme smart-log /dev/nvme0
$ sudo hdparm -tT /dev/sda
$ sudo systemctl enable --now smartd
Power Management#
Modern kernels run CPUs and devices through governors and idle
states, exposed under /sys/devices/system/cpu and
/sys/class/power_supply. Pick policy for the workload.
performance for throughput, powersave for laptops,
schedutil as the modern default.
Tool |
Scope |
|---|---|
|
CPU frequency / governor (current default) |
|
Inspect cpufreq state (legacy) |
|
Watt-by-watt breakdown + tunables |
|
Laptop battery / AC profile manager |
|
Battery / AC state queries |
|
ACPI thermal / battery summary |
|
Soft / hard radio kill switches (wifi, BT) |
$ sudo cpupower frequency-info
$ sudo cpupower frequency-set -g performance
$ sudo powertop --auto-tune
$ tlp-stat -s
$ upower -i $(upower -e | grep BAT)
$ rfkill list
Input, Graphics, Audio#
The desktop-side stacks. evdev for input, KMS / DRM and Wayland
or X11 for graphics, ALSA and PipeWire / PulseAudio for sound. Mostly
out-of-scope on servers, but useful when triaging an operator’s own
workstation or building a kiosk.
Stack |
Tools / probes |
|---|---|
Input (libinput) |
|
X11 |
|
Wayland |
|
DRM / GPU |
|
ALSA |
|
PipeWire |
|
PulseAudio |
|
Bluetooth |
|
$ xrandr --listmonitors
$ sudo libinput list-devices | head -30
$ wpctl status
$ bluetoothctl devices
Files & paths#
Configuration that drives module loading, udev, and per-subsystem defaults. These are where the operator makes device behavior persistent across reboots, blacklists a driver, pins an interface name, or grants a USB device to a non-root group.
Kernel modules#
/etc/modules. Modules to load at boot (Debian / Ubuntu)./etc/modules-load.d/*.conf. systemd-style, one module per line./etc/modprobe.d/*.conf. Module options, aliases, blacklists (options snd_hda_intel power_save=1,blacklist nouveau)./lib/modules/$(uname -r)/. Compiled module tree./lib/modules/$(uname -r)/modules.dep. Dependency map (rebuilt bydepmod)./etc/dracut.conf//etc/initramfs-tools/. Modules baked into the initramfs.
udev#
/etc/udev/rules.d/*.rules. Operator rules (highest precedence)./lib/udev/rules.d/*.rules. Distro / package-shipped rules./run/udev/rules.d/*.rules. Runtime rules./etc/udev/udev.conf. Daemon defaults./etc/udev/hwdb.d/*.hwdb. Hardware database fragments (vendor / product strings, key remaps).
Block layer#
/etc/fstab. Persistent mount table./etc/crypttab. LUKS volumes opened at boot./etc/mdadm/mdadm.conf. Software RAID arrays./etc/lvm/lvm.conf. LVM defaults./etc/multipath.conf. Multipath I/O configuration.
Power and CPU#
/etc/default/cpufrequtils. Governor selection (Debian)./etc/tlp.conf. TLP power-management profiles (laptops)./sys/devices/system/cpu/cpu*/cpufreq/. Live frequency knobs./sys/class/power_supply/. Battery, AC adapter state.
Graphics, input, audio#
/etc/X11/xorg.conf.d/*.conf. X server device sections./etc/libinput/and/usr/share/libinput/. Input device quirks./etc/asound.conf/~/.asoundrc. ALSA config./etc/pipewire/and~/.config/pipewire/. PipeWire config./etc/wireplumber/. WirePlumber session config.
Common Tasks#
Inspect#
What hardware is on this box.
$ lscpu
$ lsblk -f
$ lspci -nnk
$ lsusb -tv
Which removable or external storage is attached.
$ lsblk -o NAME,RM,SIZE,RO,TYPE,MOUNTPOINT,MODEL
$ udevadm info --query=property --name=/dev/sdb
$ ls -la /dev/disk/by-id/ /dev/disk/by-label/
Everything the kernel knows about a single device.
$ udevadm info /dev/<dev>
$ ls -l /sys/block/<dev>/device/
$ sudo smartctl -a /dev/<dev>
What partitions exist on this disk, and how to make a fresh filesystem.
$ lsblk -f /dev/sdb
$ sudo parted /dev/sdb print
$ sudo fdisk -l /dev/sdb
$ sudo mkfs.ext4 -L data /dev/sdb1
Investigate#
Show hot-plug events as they happen.
$ udevadm monitor --environment --udev
$ dmesg -wH
$ journalctl -kf
Is this a VM, a container, or bare metal.
$ systemd-detect-virt
$ sudo dmidecode -s system-manufacturer
$ cat /proc/1/cgroup
$ ls -la /.dockerenv 2>/dev/null
Which USB devices have been plugged in over the last week.
$ journalctl --since '7 days ago' | grep -i usb
$ grep -r '' /var/log/syslog* 2>/dev/null | grep -i 'New USB device'
$ lsusb -v 2>/dev/null | grep -E 'idVendor|idProduct|iSerial'
Is this disk dying.
$ sudo smartctl -H /dev/sda
$ sudo smartctl -a /dev/sda | less
$ sudo smartctl -t short /dev/sda
$ sudo nvme smart-log /dev/nvme0
Where the disk I/O is going.
$ iostat -xz 1 5
$ sudo iotop -boqq -n 3
$ vmstat 1 5
$ cat /proc/diskstats
Modify#
Load, unload, or blacklist a kernel module.
$ lsmod | grep <name>
$ sudo modprobe <module>
$ sudo modprobe -r <module>
$ modinfo <module>
$ echo 'blacklist <module>' | sudo tee /etc/modprobe.d/blacklist-<module>.conf
Warning
Blacklisting a driver that is in the initramfs (storage, crypto,
network for NFS root) without rebuilding the initramfs leaves the
next boot unable to mount root. Run update-initramfs -u /
dracut -f after editing modprobe.d.
Reset or rescan a flaky device without rebooting.
$ sudo udevadm trigger
$ sudo udevadm control --reload-rules
$ echo 1 | sudo tee /sys/block/sdb/device/rescan
$ for h in /sys/class/scsi_host/host*; do echo '- - -' | sudo tee $h/scan; done
References#
man 5 sysfs,man 5 proc(kernel-exposed device state).man 7 udev,man 8 udevadm(hot-plug and rule engine).man 8 lsblk,man 8 lspci,man 8 lsusb,man 1 lscpu,man 1 lshw,man 8 dmidecode,man 8 hwinfo(inspection).man 8 modprobe,man 5 modules-load.d,man 5 modprobe.d,man 8 depmod,man 5 modules.dep(kernel modules).man 8 parted,man 8 fdisk,man 8 gdisk,man 8 cryptsetup,man 8 mdadm,man 8 lvm,man 8 multipath,man 5 fstab,man 5 crypttab(block layer).man 8 smartctl,man 8 smartd,man 5 smartd.conf,man 8 nvme,man 8 nvme-smart-log,man 8 hdparm(storage health).man 1 cpupower,man 8 powertop,man 8 tlp,man 1 upower,man 8 rfkill(power management).man 1 xrandr,man 1 xinput,man 1 wpctl,man 1 pactl,man 1 bluetoothctl(input / graphics / audio).Filesystem for
/dev,/proc,/syslayout and on-disk filesystems.Hardening for
noexec/nosuid/nodevmount options and module-loading lockdown.Services for systemd-udevd, smartd, and other device-touching units.
Networking for network-device topics built on these primitives.