Menu

System Architecture

Step 1 of 3 LPIC-1 101.1weight 2

Determine and configure hardware settings

“Find out what hardware is in a Linux box, which driver runs it, and how to switch devices and modules on or off.”

View .md

Before you can fix a sound card that stays silent or a USB disk that never shows up, you need to answer two questions: what hardware is in this machine, and which driver is handling it. Linux gives you a few small tools and three special directories for exactly that.

This byte covers how Linux sees hardware: the firmware settings, the tools that list devices, kernel modules (drivers), and the pieces that react when you plug something in: sysfs, udev and D-Bus.

Tip

Try this in a virtual machine or on a real Linux box. A Docker container shares the host’s kernel, so it can’t load modules and only sees part of the hardware. On Debian or Ubuntu, install the tools with sudo apt install pciutils usbutils. On RHEL or Fedora: sudo dnf install pciutils usbutils.

Turning built-in devices on or off#

Most motherboards have integrated peripherals: sound, network, Wi-Fi, Bluetooth, serial ports, sometimes a webcam. The first place to enable or disable them is the firmware setup (BIOS or UEFI). You open it by pressing a key right after power on, often Del, F2 or F10, depending on the maker.

In the setup screens you’ll typically find:

  • onboard devices (audio, LAN, SATA mode, USB ports) set to Enabled or Disabled
  • CPU features like virtualization (Intel VT-x, AMD-V)
  • the boot order and Secure Boot

A device disabled in firmware is invisible to Linux: it won’t show up in lspci at all. On a UEFI machine you can even jump into the setup screen from Linux:

bash
sudo systemctl reboot --firmware-setup

You can also keep a device present but stop Linux from using it, by not loading its driver. More on that in the modules section below.

Three special directories: /proc, /sys and /dev#

None of these hold normal files on disk. The kernel builds them in memory, live.

DirectoryWhat it isExamples
/proc/procfs: information about processes and kernel internals/proc/cpuinfo, /proc/meminfo, /proc/interrupts, /proc/modules
/sys/sysfs: the kernel’s device model, one folder per device, bus, driver and module/sys/class/net/, /sys/block/, /sys/bus/usb/devices/
/dev/device files that programs open to talk to hardware/dev/sda, /dev/nvme0n1, /dev/ttyS0, /dev/null

A few quick looks:

bash
grep "model name" /proc/cpuinfo | head -1
head -3 /proc/meminfo
ls /sys/class/net/
console
model name	: Intel(R) Core(TM) i5-8265U CPU @ 1.60GHz
MemTotal:       16231140 kB
MemFree:         9876544 kB
MemAvailable:   13209876 kB
enp0s31f6  lo  wlp2s0

/proc is the older one and mixes process data with hardware data. /sys came later (Linux 2.6) and is the clean, structured place for devices. Many tools, like lsblk and udev, read /sys under the hood.

Listing hardware#

PCI devices: lspci#

PCI and PCI Express are the internal buses that connect graphics cards, network cards, storage controllers and USB controllers to the CPU. lspci lists everything on them:

bash
lspci
console
00:00.0 Host bridge: Intel Corporation Coffee Lake HOST and DRAM Controller (rev 0c)
00:02.0 VGA compatible controller: Intel Corporation WhiskeyLake-U GT2 [UHD Graphics 620] (rev 02)
00:14.0 USB controller: Intel Corporation Cannon Point-LP USB 3.1 xHCI Controller (rev 30)
00:17.0 SATA controller: Intel Corporation Cannon Point-LP SATA Controller [AHCI Mode] (rev 30)
00:1f.3 Audio device: Intel Corporation Cannon Point-LP High Definition Audio Controller (rev 30)
00:1f.6 Ethernet controller: Intel Corporation Ethernet Connection (6) I219-V (rev 30)
02:00.0 Network controller: Intel Corporation Wireless-AC 9560 (rev 10)

The first column is the address: bus:device.function. The useful options:

OptionShows
-kthe kernel driver in use and the modules that could drive it
-v, -vvmore detail: IRQ, memory ranges, I/O ports, capabilities
-nnthe numeric vendor and device IDs, like [8086:15bc]
-s 00:1f.6only the device at that address
-ta tree of buses and bridges
bash
lspci -k -s 00:1f.6
console
00:1f.6 Ethernet controller: Intel Corporation Ethernet Connection (6) I219-V (rev 30)
	Subsystem: Lenovo Ethernet Connection (6) I219-V
	Kernel driver in use: e1000e
	Kernel modules: e1000e

That one line, “Kernel driver in use”, is often the whole answer when a device doesn’t work: no line means no driver has claimed it.

USB devices: lsusb#

bash
lsusb
console
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 003: ID 046d:c52b Logitech, Inc. Unifying Receiver
Bus 001 Device 002: ID 0781:5581 SanDisk Corp. Ultra
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

ID 0781:5581 is the vendor ID and product ID. A root hub is the USB controller itself, as seen from the bus. Useful options:

  • lsusb -t shows a tree with the driver bound to each device and the speed
  • lsusb -v dumps every descriptor (run it with sudo for the full output)
  • lsusb -s 001:002 picks one device by bus and device number
  • lsusb -d 0781:5581 picks one by vendor and product ID
bash
lsusb -t
console
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/6p, 10000M
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/12p, 480M
    |__ Port 2: Dev 2, If 0, Class=Mass Storage, Driver=usb-storage, 480M
    |__ Port 3: Dev 3, If 0, Class=Human Interface Device, Driver=usbhid, 12M

Other handy tools#

lscpu (CPU details), lsblk (block devices), lshw (everything, as a tree, run as root) and dmidecode (firmware tables: board model, RAM slots, serial numbers) are not on the exam list, but you’ll use them all the time.

Hardware resources: IRQs, I/O ports and memory#

Devices need resources to talk to the CPU. The exam expects you to know where to look:

ResourceWhat it isWhere to see it
IRQan interrupt line: “hey CPU, I have data”/proc/interrupts
I/O portssmall address ranges for old-style device registers/proc/ioports
Memory rangesdevice memory mapped into the address space/proc/iomem
DMA channelsdirect memory access without the CPU (legacy ISA)/proc/dma
bash
head -5 /proc/interrupts
console
           CPU0       CPU1       CPU2       CPU3
  0:         20          0          0          0  IR-IO-APIC    2-edge      timer
  1:          0          0       1834          0  IR-IO-APIC    1-edge      i8042
  8:          0          1          0          0  IR-IO-APIC    8-edge      rtc0
  9:          0       4412          0          0  IR-IO-APIC    9-fasteoi   acpi

On modern PCI Express hardware these are set up automatically and rarely clash. lspci -v shows the IRQ and ranges for each card, which is enough for most troubleshooting.

Telling storage devices apart#

Linux names disks by the driver that handles them, not by what they look like:

Device nameKind of storage
/dev/sda, /dev/sdb…SATA and SAS disks, SSDs, USB sticks and USB disks (all through the SCSI disk driver)
/dev/sda1first partition on sda
/dev/nvme0n1, /dev/nvme0n1p1NVMe SSD (controller 0, namespace 1) and its first partition
/dev/mmcblk0, /dev/mmcblk0p1SD cards and eMMC chips
/dev/vdavirtio disk in a virtual machine
/dev/sr0optical drive (CD, DVD, Blu-ray)
/dev/hdaold parallel ATA (IDE) disk, legacy naming you may still meet in exam questions

lsblk can show the transport and whether a disk spins:

bash
lsblk -d -o NAME,TRAN,ROTA,SIZE,MODEL
console
NAME    TRAN   ROTA   SIZE MODEL
sda     sata      1 931.5G WDC WD10EZEX-08WN4A0
sdb     usb       1  14.9G Ultra
sr0     sata      1  1024M DVD-RW DU-8A5LH
nvme0n1 nvme      0 476.9G Samsung SSD 980 PRO 500GB

ROTA 1 means rotational (a spinning hard disk), 0 means solid state. USB sticks often report 1 even though they don’t spin, so treat that column as a hint.

Kernel modules: drivers you can load and unload#

Most drivers are kernel modules: .ko files under /lib/modules/$(uname -r)/. The kernel loads them on demand when it finds matching hardware. Three commands do most of the work.

lsmod: what’s loaded#

bash
lsmod | head -6
console
Module                  Size  Used by
uas                    32768  0
usb_storage            86016  1 uas
e1000e                331776  0
snd_hda_intel          61440  3
snd_hda_codec         196608  2 snd_hda_intel,snd_hda_codec_realtek

“Used by” is a count, followed by the modules that depend on this one. lsmod just formats /proc/modules.

modinfo: what a module is#

bash
modinfo e1000e | head -4
modinfo -p snd_hda_intel | head -3
console
filename:       /lib/modules/6.1.0-27-amd64/kernel/drivers/net/ethernet/intel/e1000e/e1000e.ko
license:        GPL v2
description:    Intel(R) PRO/1000 Network Driver
author:         Intel Corporation, <linux.nics@intel.com>
index:Index value for Intel HD audio interface. (array of int)
id:ID string for Intel HD audio interface. (array of charp)
enable:Enable Intel HD audio interface. (array of bool)

-p lists the parameters a module accepts.

modprobe: load and unload, with dependencies#

bash
sudo modprobe loop               # load a module (and anything it needs)
sudo modprobe loop max_loop=16   # load it with a parameter
sudo modprobe -r loop            # remove it, and unused dependencies

modprobe uses the dependency list modules.dep (built by depmod) to load what a module needs first. The older insmod and rmmod work on a single file and ignore dependencies, so prefer modprobe.

If a module is busy you get an error, and nothing changes:

console
modprobe: FATAL: Module snd_hda_intel is in use.

Making it permanent#

Settings for modprobe live in /etc/modprobe.d/*.conf:

/etc/modprobe.d/local.conftext
# never auto-load the PC speaker beep driver
blacklist pcspkr

# default options whenever this module loads
options snd_hda_intel power_save=1

blacklist stops automatic loading by hardware match, but modprobe pcspkr by hand still works. To block a module completely, add install pcspkr /bin/false. If the module is also inside the initramfs (the small early-boot filesystem), rebuild it afterwards: sudo update-initramfs -u on Debian and Ubuntu, sudo dracut -f on RHEL and Fedora.

To load a module at every boot even without matching hardware, list its name in a file in /etc/modules-load.d/ (systemd). Debian also still reads the older /etc/modules.

The parameters a loaded module is using right now are visible in sysfs:

bash
cat /sys/module/snd_hda_intel/parameters/power_save

sysfs, udev and D-Bus: what happens when you plug something in#

The exam wants the concept, so here is the chain of events when you plug in a USB stick:

  1. The kernel detects the device, loads a driver (here usb-storage), and adds it to sysfs under /sys/devices/.... It then sends out a “uevent”: a device was added.
  2. udev (the systemd-udevd service) receives that event. It creates the device node in /dev (/dev/sdb), sets its owner and permissions, adds stable names like /dev/disk/by-uuid/..., and runs any matching rules.
  3. Desktop services like udisks hear about the new disk and announce it on D-Bus. Your file manager listens there and pops up “USB stick connected”.

Devices that are there at boot are called coldplug devices. udev replays their events at startup so they get the same treatment. Devices you plug in later are hotplug devices.

Watching udev live#

bash
udevadm monitor

Plug in a USB stick and you’ll see both the kernel event and udev’s event:

console
KERNEL[2841.112093] add      /devices/pci0000:00/0000:00:14.0/usb1/1-2 (usb)
KERNEL[2841.115830] add      /devices/pci0000:00/0000:00:14.0/usb1/1-2/1-2:1.0 (usb)
UDEV  [2841.130417] add      /devices/pci0000:00/0000:00:14.0/usb1/1-2 (usb)
UDEV  [2841.142955] add      /devices/pci0000:00/0000:00:14.0/usb1/1-2/1-2:1.0 (usb)

udevadm info /dev/sdb shows every property udev knows about a device, which is what you match on in rules.

A udev rule#

Rules shipped by packages live in /usr/lib/udev/rules.d/ (on Debian and Ubuntu also reachable as /lib/udev/rules.d/). Your own rules go in /etc/udev/rules.d/ and win when the file names match. This one gives a specific stick a fixed extra name:

/etc/udev/rules.d/99-backup-stick.rulestext
SUBSYSTEM=="block", ATTRS{idVendor}=="0781", ATTRS{idProduct}=="5581", SYMLINK+="backupstick"
bash
sudo udevadm control --reload
sudo udevadm trigger
ls -l /dev/backupstick

D-Bus in one paragraph#

D-Bus is a message bus: a way for programs to talk to each other and to system services. There’s one system bus (for services like systemd, NetworkManager, udisks and logind) and one session bus per logged-in user. You’ll rarely use it by hand, but you can peek:

bash
busctl list | grep freedesktop | head -4
console
org.freedesktop.NetworkManager   812 NetworkManager root :1.6  NetworkManager.service - -
org.freedesktop.UDisks2          934 udisksd        root :1.12 udisks2.service       - -
org.freedesktop.login1           701 systemd-logind root :1.3  systemd-logind.service - -
org.freedesktop.systemd1           1 systemd        root :1.0  init.scope            - -

Managing USB devices from the command line#

Besides listing them with lsusb, you can control USB devices:

bash
udisksctl unmount -b /dev/sdb1     # unmount through udisks (no root needed on a desktop)
udisksctl power-off -b /dev/sdb    # tell the stick it's safe to pull

The kernel also lets you switch a USB device off through sysfs. Writing 0 to its authorized file disconnects the drivers. Writing 1 brings it back:

bash
echo 0 | sudo tee /sys/bus/usb/devices/1-2/authorized
echo 1 | sudo tee /sys/bus/usb/devices/1-2/authorized

1-2 is bus 1, port 2, the same numbers you see in udevadm monitor and lsusb -t. And to keep a USB driver from loading at all, blacklist its module like any other.Tools like USBGuard build on this same authorized switch to allow only USB devices you have approved, which protects against “found a USB stick in the parking lot” attacks.

Exam checklist#

  • /proc/ = processes and kernel info (cpuinfo, meminfo, interrupts, ioports, iomem, dma, modules). /sys/ = sysfs, the device model. /dev/ = device files, managed by udev.
  • lspci lists PCI devices. -k shows the driver, -v the resources, -nn the IDs, -t a tree.
  • lsusb lists USB devices. -t tree with drivers, -v details, -s bus:dev, -d vendor:product.
  • lsmod lists loaded modules (from /proc/modules). modinfo describes one.
  • modprobe name loads with dependencies, modprobe -r name removes. insmod and rmmod skip dependencies.
  • Module settings go in /etc/modprobe.d/*.conf: blacklist, options, install. Boot-time loading: /etc/modules-load.d/ (or /etc/modules on Debian).
  • Disk names: sdX for SATA, SAS and USB, nvme0n1 for NVMe, mmcblk0 for SD and eMMC, sr0 for optical, hdX for legacy IDE.
  • udev creates /dev entries and applies rules from /etc/udev/rules.d/. udevadm monitor and udevadm info to inspect.
  • D-Bus is the message bus that lets services (udisks, NetworkManager, systemd) tell programs about hardware events.
  • Integrated peripherals are enabled or disabled in the BIOS/UEFI setup. Disabled there means Linux never sees them.

Byte check

0/3

Answer these 3 questions to commit this byte to your learning path.

  1. A network card shows up in lspci, but you want to know which kernel module drives it. Which command tells you?
  2. You want to unload the module pcspkr and stop it from loading automatically at the next boot. What do you do?
  3. Which component creates the files in /dev when you plug in a USB stick and can give them extra names through rules?
Search posts and bytes

Optional account

Keep your progress everywhere

Everything on AminBytes is free to read, with or without an account. Sign in only if you want your commits, streak and merged topics saved, on every device.

or

We keep only your name, avatar and which bytes you finished, and you can delete it all anytime. Privacy