Перейти к содержимому

Directory - / sys в Linux

26

Может кто-нибудь объяснить мне, что происходит внутри /sysкаталога в системе Linux? Я прогуглил это и получил некоторые результаты, но мне нужно ясное мнение об этом. Кто-нибудь готов дать мне короткий (и сладкий) кристалл про / sys?

30 852 просмотра
user72789 спросил 12 лет назад
U 138

2 ответа

37
Принятый ответ

From sysfs.txt:

sysfs is a ram-based filesystem [...]. It provides a means to export kernel data structures, their attributes, and the linkages between them to userspace.

In essence /sys allows you to get information about the system and its components (mostly attached and installed hardware) in a structured way.

See also the Wikipedia Article on sysfs. The following statement makes it pretty clear:

sysfs is a virtual file system provided by Linux. sysfs provides a set of virtual files by exporting information about various kernel subsystems, hardware devices and associated device drivers from the kernel's device model to user space. In addition to providing information about various devices and kernel subsystems, exported virtual files are also used for their configuring. sysfs is similar to the sysctl mechanism found in BSD systems, but implemented as a file system instead of a separate mechanism.

See also this excellent answer to What is the difference between procfs and sysfs? on Unix & Linux StackExchange.

Должен ли sys быть включен в полную резервную копию машины?

Danijel · 10 лет назад · 0

Конечно, нет. Содержимое / sys перестраивается при каждой загрузке.

countermode · 10 лет назад · 1
countermode ответил 12 лет назад
C 621
11

Can't beat Wikipedia's simplicity:

Filesystem Hierarchy Standard > FHS compliance

Modern Linux distributions include a /sys directory as a virtual filesystem (sysfs, comparable to /proc, which is a procfs), which stores and allows modification of the devices connected to the system, whereas many traditional UNIX and Unix-like operating systems use /sys as a symbolic link to the kernel source tree.

I guess that, when this /sys directory got finally standardized, a description and its specification will be added to the Specifications Archive under the Filesystem Hierarchy Standard documentation.

jimm-cl ответил 12 лет назад
J 1 286