Wednesday 23 March 2016

Managing devices with CentOS (procfs, sysfs, udev, lsusb and lspci)

This post will look at some common components that relate to device management under CentOS and other commonly used distro's.

procfs

procfs (/proc) contains a series of files that describe the kernel's current view of the system (for example cpu information) - allowing applications and users to retrieve information about the system.

Files within the proc directory are not standard text or binary files - rather they are referred to as 'virtual files' (this is because they are continually updated) and you will also notice that the file size of them is 0 bytes even though there is sometimes a large amount of information within them.

The majority of files are read-only - although there are some files that can be manually edited - for example /proc/sys/net/ipv4/ip_forward - which allows you to turn on IP forwarding - although changes made here will not persist a reboot and you will need to use something like sysctl to ensure the change is applied after reboots.

sysfs

The sys filesystem (/sys) is a combination of the proc, devfs, and devpty file systems that provides users with a hierarchy that enumerates devices and busses attached to the system. It can make identifying hardware components quicker than simply looking in the devfs.

udev

udev is a component that is used to dynamically create (and remove) files within the devfs (/dev) upon boot and also any hotpluggable devices. It also provides the ability of change block device names - for example when you would like to change an interface name.

lsusb

lsusb is a utility that allows us to quickly get an overview of all usb devices connected to the system - we can also get more detailed information by running:

lsusb -v /dev/sdc

or see more information about a specific device with:

lsubs -D /dev/sdc

lspci

This utility outputs a list of PCI devices attached to the system - you can produce a more verbose output with the -v switch e.g.:

lspci -v

0 comments:

Post a Comment