Hardware and drivers: udev, modules and devices
You learn how devices are detected, how drivers load as kernel modules and how to give devices stable names and permissions with udev rules.
Level 201 · 17 lessons · 15 practice labs
Lessons
Knowing the devices
- Device discovery: lspci, lsusb and lshw
- The device tree through /sys
- Device files: major and minor numbers
- Short task: produce the server's hardware inventory
Drivers
- Modules: lsmod, modinfo and dependencies
- modprobe, options and persistent settings
- Blacklisting modules and blocking loads
- Firmware files and the missing-driver error
- DKMS and out-of-tree drivers
- Short task: disable USB storage on a server
udev
- udev events and udevadm monitor
- udev rules: persistent names and symlinks
- Device permissions and groups with udev
- Starting a job when a device is plugged in
- Short task: give a serial adapter a fixed name and the right group
Wrap-up
- Hardware errors: dmesg, MCE and EDAC
- Capstone: get newly fitted cards and disks recognised and configured with stable names
Practice labs
- Produce a server's hardware summary: Find CPU model, core count, memory size and number of disks with commands and fill in the inventory card.
- Map PCI devices to the drivers they use: List which kernel driver each network and storage controller uses and mark the device with none.
- Follow a device's full path through sysfs: Follow a disk's sysfs path from controller to block device and extract its vendor, model and the bus it sits on.
- Read a loaded module's details and parameters: List the version, dependencies and tunable parameters of a loaded module.
- Set a module parameter persistently: Reload a virtual device module with a new parameter and make the setting apply at boot as well.
- Find why a module will not load: From kernel messages find and fix why a module fails on a kernel version mismatch and a missing dependency.
- Watch the events when a device is plugged in: Add a virtual device, watch the udev events and submit the serial number from the device's attributes.
- Give a device a stable name: Write and test a rule that gives a disk whose name changes at every boot a fixed symlink based on its serial number.
- Set permissions and trigger a service on plug-in: Write a rule that opens the device node to a group and starts a collector service when a meter is plugged in, stopping it on removal.
- Determine which disk sits in which slot: Use persistent device paths to match disk names with their serial numbers and ports.
- Work out where network interface names come from: Find which naming policy produced an interface name and fix the card to a meaningful name by MAC address.
- Inspect NIC driver settings and cut packet loss: Find the cause of dropped packets from interface statistics, change ring buffer and offload settings and measure the effect.
- Check hardware error records: Search kernel messages and hardware event records for memory and disk errors and write down the failing component.
- Find and install missing firmware: From the kernel message find the firmware file wanted by a device whose driver loads yet does not work and put it in place.
- Bring a new device into service end to end: For a device added to Demirsu Enerji's metering server load the driver, persist its parameter, write stable-name and permission rules and document it.
About this course
You learn how devices are detected, how drivers load as kernel modules and how to give devices stable names and permissions with udev rules.
What you will learn
- Knowing the devices
- Drivers
- udev
- Wrap-up
Prerequisites
Finishing the level 101 courses of the same path, or knowing those topics, is enough.
Lab environment
Lessons run in your own Kali Linux terminal that opens in the browser. Nothing to install; the lab starts clean in every lesson.
Frequently asked questions
- Is this course right for my level?
- The course is at level 201; it assumes you know the topics of the lower-level courses.
- Is there anything to install?
- No. Every lesson runs in your own lab environment that opens in the browser.
- How do lessons work?
- Each lesson has 8 to 10 steps and a short quiz. Early steps show the command to type, later steps give less help; if two attempts fail, the solution opens.
- Can I try it for free?
- Yes. The first three lessons of every course are free.