Red Hat Enterprise Linux




Chapters     |     Exercises     |     Workshop     |    

Devices



Devices

Commands

[root@redhat ~]# lspci –options Shows all devices currently connected to the PCI (Peripheral Component Interconnect) bus. [+]

[root@redhat ~]# lsusb Lists USB (Universal Serial Bus) devices currently connected to the machine. [+]

[root@redhat ~]# lsgpio Lists Purpose Input/Output (GPIO) devices currently connected to the machine.

Hotplug is the term used to refer to the detection and configuration of a device while the system is running, such as when a USB device is inserted. The Linux kernel has supported hotplug features since version 2.6, allowing most system buses (PCI, USB, etc.) to trigger hotplug events when a device is connected or disconnected.

As new devices are detected, udev searches for a matching rule in the pre-defined rules stored in the directory /etc/udev/rules.d/. The most important rules are provided by the distribution, but new ones can be added for specific cases.

Information Files

This kind of information is kept in special files in the directories /proc and /sys.

These directories are mount points to filesystems not present in a device partition, but only in RAM space used by the kernel to store runtime configuration and information on running processes. Such filesystems are not intended for conventional file storage, so they are called pseudo-filesystems and only exist while the system is running.

The /proc directory contains files with information regarding running processes and hardware resources. Some of the important files in /proc for inspecting hardware are:

/proc/cpuinfo : Lists detailed information about the CPU(s) found by the operating system.
/proc/meminfo : Lists detailed information about the Memory found by the operating system.
/proc/interrupts : A list of numbers of the interrupts per IO device for each CPU.
/proc/ioports : Lists currently registered Input/Output port regions in use.
/proc/dma : Lists the registered DMA (direct memory access) channels in use.

Files inside the /sys directory have similar roles to those in /proc. However, the /sys directory has the specific purpose of storing device information and kernel data related to hardware, whilst /proc also contains information about various kernel data structures, including running processes and configuration.

Another directory directly related to devices in a standard Linux system is /dev. Every file inside /dev is associated with a system device, particularly storage devices. A legacy IDE hard drive, for example, when connected to the motherboard’s first IDE channel, is represented by the file /dev/hda. Every partition in this disk will be identified by /dev/hda1, /dev/hda2 up to the last partition found.

Removable devices are handled by the udev subsystem, which creates the corresponding devices in /dev. The Linux kernel captures the hardware detection event and passes it to the udev process, which then identifies the device and dynamically creates corresponding files in /dev, using predefined rules.

In current Linux distributions, udev is responsible for the identification and configuration of the devices already present during machine power-up (coldplug detection) and the devices identified while the system is running (hotplug detection). Udev relies on SysFS, the pseudo filesystem for hardware related information mounted in /sys.


Modules

Les Modules (Généralement apelés Pilotes sous Windows) sont des firmwares qui assurent la communication entre le Kernel et les périphériques.

Every hardware part requires a software component to control the corresponding device. This software component is called a kernel module and it can be part of the official Linux kernel or added separately from other sources.

Linux kernel modules related to hardware devices are also called drivers, as in other operating systems. Drivers for Linux, however, are not always supplied by the device’s manufacturer. Whilst some manufacturers provide their own binary drivers to be installed separately, many drivers are written by independent developers. Historically, parts that work on Windows, for example, may not have a counterpart kernel module for Linux. Nowadays, Linux-based operating systems have strong hardware support and most devices work effortlessly.

[root@redhat ~]# lsmod show all currently loaded modules [+]

[root@redhat ~]# modprobe –l Available modules (installed or not)
[root@redhat ~]# modprobe module Load and Unload modules [+]
[root@redhat ~]# modinfo module-name Display module detailed description [+]

Settings Files and Directories

/etc/modprobe.d/ : Directory for Customized parameters files for modules
/etc/modprobe.conf : Customized parameters for modules (May not present on some Systems)
/etc/modprobe.d/module-name.conf : Module settings File

/etc/modprobe.d/blacklist.conf : can be used to block the loading of the module.For example, to prevent the automatic loading of the module nouveau, the line "blacklist nouveau" must be added to the file (May not present by default on some Systems)

You can modify the /etc/modprobe.d/blacklist.conf file that already exists on the system by default. However, the preferred method is to create a separate configuration file, /etc/modprobe.d/module-name.conf, that will contain settings specific only to the given kernel module.

Customized parameters for a module can be made persistent by including them in the file /etc/modprobe.conf or in individual files with the extension .conf in the directory /etc/modprobe.d/.


Eninam BAGNABANA     |         |     bagnadavid@outlook.fr     |