CertGrid CertGrid
Hands-on Lab·LPIC-1

Kernel modules, devices and udev

Objective 101.1 names modprobe, lsmod, /dev, /sys and udev as things you should be able to talk about. This guide lists what the running kernel has loaded, reads a module's own description off disk, loads and removes one that cannot affect anything, and then looks at where device nodes and predictable interface names actually come from.

101: System Architecture Guide 33 of 33 Beginner

The Debian-family host. The only module loaded is `dummy`, whose documented purpose is to discard every packet sent to it.
Server NameIP AddressOSRolesCPURAMHDD
LPIC1-A01192.168.0.76Ubuntu 26.04 LTSDebian-family host - dpkg and apt, which objective 102.4 names2 Core4 GB50 GB

This guide includes

Use this when hardware is present and not working, or when you need to know whether support for something is compiled in, loadable, or blacklisted. This matters because a device that does not appear is usually a module question, and because /dev and /sys are the two places the answer is written down.

Before you start

  1. What the kernel has loaded right now

    A count, a table, and the directory the files came from.

    bash Example session
    lsmod | wc -l; echo "modules loaded"; lsmod | head -452modules loadedModule                  Size  Used byudp_diag               12288  0tcp_diag               20480  0inet_diag              24576  2 tcp_diag,udp_diaguname -r; ls -d /lib/modules/$(uname -r); ls /lib/modules/$(uname -r)/kernel/ | head -5; echo "--- modules are files on disk, grouped like the kernel source"7.0.0-30-generic/lib/modules/7.0.0-30-genericarchblockcryptodriversfs--- modules are files on disk, grouped like the kernel source

    Expected result52 modules, with inet_diag showing 2 tcp_diag,udp_diag in its Used by column - kernel 7.0.0-30-generic, and its module tree grouped into arch, block, crypto, drivers, fs.

    Success conditionYou can list a running kernel's modules and find them on disk.

  2. What one module says about itself

    The file, its description, and a dry run.

    bash Example session
    modinfo dummy | grep -E "^(filename|description|license|depends|parm)" | head -6filename:       /lib/modules/7.0.0-30-generic/kernel/drivers/net/dummy.ko.zstdescription:    Dummy netdevice driver which discards all packets sent to itlicense:        GPLdepends:parm:           numdummies:Number of dummy pseudo devices (int)modprobe -n -v dummy; echo "--- -n is a dry run: this is what WOULD be loaded, dependencies first"insmod /lib/modules/7.0.0-30-generic/kernel/drivers/net/dummy.ko.zst numdummies=0--- -n is a dry run: this is what WOULD be loaded, dependencies first

    Expected resultfilename: /lib/modules/7.0.0-30-generic/kernel/drivers/net/dummy.ko.zst, described as Dummy netdevice driver which discards all packets sent to it, depends: empty, and a parm: for numdummies. The dry run prints the insmod it would perform.

    Success conditionYou can find out what a module does before loading it.

  3. Loading one that cannot affect anything

    A module in, an interface out, and what the kernel then exposes about it.

    bash Example session
    lsmod | grep -c "^dummy "; echo "dummy modules loaded before"; sudo modprobe dummy numdummies=1 && lsmod | grep "^dummy"; ip -br link show type dummy 2>/dev/null | head -20dummy modules loaded beforedummy                  16384  0dummy0           DOWN           6e:75:0d:1e:13:9e <BROADCAST,NOARP>ls /sys/module/dummy/; echo "--- refcnt:"; cat /sys/module/dummy/refcnt; ls /sys/module/dummy/parameters/ 2>/dev/null || echo "(this module exposes no parameters at runtime)"coresizeholdersinitsizeinitstatenotesrefcntsectionssrcversiontaintuevent--- refcnt:0(this module exposes no parameters at runtime)

    Expected result0 before - then dummy loaded at 16384 bytes and a new dummy0 DOWN interface with <BROADCAST,NOARP> - and /sys/module/dummy/ holding refcnt, coresize, initstate and others, with refcnt 0 and no parameters directory at all.

    Success conditionYou can load a module and see the device it creates.

  4. The device tree that is not on a disk

    Two numbers instead of a size, and one file per attribute.

    bash Example session
    ls -l /dev/null /dev/zero | awk '{print $1, $5, $6, $NF}'; echo "--- the two numbers where a size would be are the major and minor device numbers"crw-rw-rw- 1, 3 /dev/nullcrw-rw-rw- 1, 5 /dev/zero--- the two numbers where a size would be are the major and minor device numbersls /sys/class/net/; echo "---"; cat /sys/class/net/eth0/address; cat /sys/class/net/eth0/mtu; echo "--- one file per attribute, which is what sysfs is"dummy0eth0lo---00:15:5d:01:11:721500--- one file per attribute, which is what sysfs isudevadm info -q property -p /sys/class/net/eth0 2>/dev/null | grep -E "ID_NET_NAME|DEVPATH|INTERFACE" | head -4DEVPATH=/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A03:00/device:07/VMBUS:01/1c3c68f3-d116-4fbe-9f64-e4dcdca05832/net/eth0INTERFACE=eth0ID_NET_NAME_MAC=enx00155d011172ID_NET_NAME=eth0

    Expected resultcrw-rw-rw- with 1, 3 for /dev/null and 1, 5 for /dev/zero - /sys/class/net/ listing dummy0, eth0, lo with the MAC and MTU each in its own file - and udevadm reporting ID_NET_NAME=eth0 alongside ID_NET_NAME_MAC=enx00155d011172.

    Success conditionYou can read a device node's identity and find its attributes in sysfs.

  5. What stops a module loading

    Two directories - one that prevents, one that requests.

    bash Example session
    ls /etc/modprobe.d/ | head -4; grep -rhE "^(blacklist|install|options)" /etc/modprobe.d/ 2>/dev/null | head -4; echo "--- blacklist and options both live here"amd64-microcode-blacklist.confblacklist-ath_pci.confblacklist-firewire.confblacklist-framebuffer.confblacklist evbugblacklist usbmouseblacklist usbkbdblacklist eepro100--- blacklist and options both live herels /etc/modules-load.d/ 2>/dev/null; cat /etc/modules 2>/dev/null | grep -vE "^#|^$" | head -3; echo "--- and this is where a module is asked for at boot"modules.conf--- and this is where a module is asked for at boot

    Expected resultblacklist-*.conf files under /etc/modprobe.d/ with entries such as blacklist evbug, blacklist usbmouse, blacklist eepro100 - and modules.conf under /etc/modules-load.d/.

    Success conditionYou can find out whether a module is being prevented from loading.

  6. Putting the machine back

    The module out, and the counts on both sides of it.

    bash Example session
    sudo ip link del dummy0 2>/dev/null; sudo modprobe -r dummy && lsmod | grep -c "^dummy "; echo "dummy modules loaded after"; ip -br link show type dummy 2>&1 | tail -10dummy modules loaded afterlsmod | wc -l; echo "modules loaded"; ip -br link show | head -2; ls /sys/module/dummy 2>&1 | tail -152modules loadedlo               UNKNOWN        00:00:00:00:00:00 <LOOPBACK,UP,LOWER_UP>eth0             UP             00:15:5d:01:11:72 <BROADCAST,MULTICAST,UP,LOWER_UP>ls: cannot access '/sys/module/dummy': No such file or directory

    Expected result0 dummy modules after removal, back to 52 modules, lo and eth0 alone with eth0 still UP, and /sys/module/dummy No such file or directory.

    Success conditionThe kernel is carrying exactly what it was before.

Troubleshooting

Official sources