sysfs is a
pseudo file system
In computer science, a synthetic file system or a pseudo file system is a hierarchical interface to non-file objects that appear as if they were regular files in the tree of a disk-based or long-term-storage file system. These non-file objects m ...
provided by the
Linux kernel that exports information about various kernel subsystems, hardware devices, and associated
device drivers from the kernel's device model to
user space
A modern computer operating system usually segregates virtual memory into user space and kernel space. Primarily, this separation serves to provide memory protection and hardware protection from malicious or errant software behaviour.
Kernel ...
through
virtual file
In computing, file system or filesystem (often abbreviated to fs) is a method and data structure that the operating system uses to control how data is stored and retrieved. Without a file system, data placed in a storage medium would be one larg ...
s.
In addition to providing information about various devices and kernel subsystems, exported virtual files are also used for their configuration.
sysfs provides functionality similar to the
sysctl
sysctl is a software utility of some Unix-like operating systems that reads and modifies the attributes of the system kernel such as its version number, maximum limits, and security settings. It is available both as a system call for compiled ...
mechanism found in
BSD
The Berkeley Software Distribution or Berkeley Standard Distribution (BSD) is a discontinued operating system based on Research Unix, developed and distributed by the Computer Systems Research Group (CSRG) at the University of California, Berk ...
operating system
An operating system (OS) is system software that manages computer hardware, software resources, and provides common services for computer programs.
Time-sharing operating systems schedule tasks for efficient use of the system and may also i ...
s, with the difference that sysfs is implemented as a virtual file system instead of being a purpose-built kernel mechanism, and that, in Linux, ''sysctl'' configuration parameters are made available at ''/proc/sys/'' as part of
procfs
The proc filesystem (procfs) is a special filesystem in Unix-like operating systems that presents information about processes and other system information in a hierarchical file-like structure, providing a more convenient and standardized meth ...
, not sysfs which is mounted at ''/sys/''.
History
During the 2.5 development cycle, the Linux driver model was introduced to fix the following shortcomings of version 2.4:
* No unified method of representing driver-device relationships existed.
* There was no generic
hotplug
Hot swapping is the replacement or addition of components to a computer system without stopping, shutting down, or rebooting the system; hot plugging describes the addition of components only. Components which have such functionality are said ...
mechanism.
*
procfs
The proc filesystem (procfs) is a special filesystem in Unix-like operating systems that presents information about processes and other system information in a hierarchical file-like structure, providing a more convenient and standardized meth ...
was cluttered with non-process information.
Sysfs was designed to export the information present in the
device tree
In computing, a devicetree (also written device tree) is a data structure describing the hardware components of a particular computer so that the operating system's kernel can use and manage those components, including the CPU or CPUs, the memor ...
which would then no longer clutter up procfs. It was written by Patrick Mochel.
Maneesh Soni later wrote the sysfs backing store patch to reduce memory usage on large systems.
During the next year of 2.5 development the infrastructural capabilities of the driver model and driverfs began to prove useful to other subsystems.
kobjects were developed to provide a central object management mechanism and driverfs was renamed to sysfs to represent its subsystem agnosticism.
Sysfs is mounted under the mount point. If it is not mounted during initialization, you can always mount it using the command: "mount -t sysfs sysfs /sys"
Supported buses
; ACPI
: Exports information about
ACPI
Advanced Configuration and Power Interface (ACPI) is an open standard that operating systems can use to discover and configure computer hardware components, to perform power management (e.g. putting unused hardware components to sleep), auto c ...
devices.
; PCI
: Exports information about
PCI and
PCI Express devices.
; PCI Express
: Exports information about
PCI Express devices.
; USB
: Exports information about
USB
Universal Serial Bus (USB) is an industry standard that establishes specifications for cables, connectors and protocols for connection, communication and power supply (interfacing) between computers, peripherals and other computers. A broad ...
devices.
; SCSI
: Exports information about
mass storage
In computing, mass storage refers to the storage of large amounts of data in a persisting and machine-readable fashion. In general, the term is used as large in relation to contemporaneous hard disk drives, but it has been used large in relati ...
devices, including
USB
Universal Serial Bus (USB) is an industry standard that establishes specifications for cables, connectors and protocols for connection, communication and power supply (interfacing) between computers, peripherals and other computers. A broad ...
,
SATA
SATA (Serial AT Attachment) is a computer bus interface that connects host bus adapters to mass storage devices such as hard disk drives, optical drives, and solid-state drives. Serial ATA succeeded the earlier Parallel ATA (PATA) standard t ...
and
NVMe
NVM Express (NVMe) or Non-Volatile Memory Host Controller Interface Specification (NVMHCIS) is an open, logical-device interface specification for accessing a computer's non-volatile storage media usually attached via PCI Express (PCIe) bus. The ...
interfaces.
; S/390 buses
: As the
S/390 architecture contains devices not found elsewhere, special buses have been created:
:* ''css'': Contains subchannels (currently the only driver provided is for I/O subchannels).
:* ''ccw'': Contains channel attached devices (driven by
CCWs).
:* ''ccwgroup'': Artificial devices, created by the user and consisting of ccw devices. Replaces some of the 2.4 chandev functionality.
:* ''iucv'': Artificial devices like netiucv devices which use VM's
IUCV interface.
Sysfs and userspace
Sysfs is used by several utilities to access information about hardware and its driver (
kernel modules) such as
udev
udev (userspace ) is a device manager for the Linux kernel. As the successor of devfsd and hotplug, udev primarily manages device nodes in the directory. At the same time, udev also handles all user space events raised when hardware devices ...
or
HAL. Scripts have been written to access information previously obtained via
procfs
The proc filesystem (procfs) is a special filesystem in Unix-like operating systems that presents information about processes and other system information in a hierarchical file-like structure, providing a more convenient and standardized meth ...
, and some scripts configure device drivers and devices via their attributes.
See also
*
procfs
The proc filesystem (procfs) is a special filesystem in Unix-like operating systems that presents information about processes and other system information in a hierarchical file-like structure, providing a more convenient and standardized meth ...
*
configfs
*
tmpfs
tmpfs (short for Temporary File System) is a temporary file storage paradigm implemented in many Unix-like operating systems. It is intended to appear as a mounted file system, but data is stored in volatile memory instead of a persistent storage ...
*
sysctl
sysctl is a software utility of some Unix-like operating systems that reads and modifies the attributes of the system kernel such as its version number, maximum limits, and security settings. It is available both as a system call for compiled ...
, alternative way of exporting configuration used in BSD systems
References
External links
Driver model overview from the LWN porting to 2.6 serieskobjects and sysfs from the LWN porting to 2.6 seriesRamfsThe sysfs Filesystem, OLS'05Documentation/filesystems/sysfs.txtLinux kernel documentation for sysfs
{{File systems
Free special-purpose file systems
Interfaces of the Linux kernel
Linux kernel features
Pseudo file systems supported by the Linux kernel