18c2ecf20Sopenharmony_ci.. _admin_devices:
28c2ecf20Sopenharmony_ci
38c2ecf20Sopenharmony_ciLinux allocated devices (4.x+ version)
48c2ecf20Sopenharmony_ci======================================
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ciThis list is the Linux Device List, the official registry of allocated
78c2ecf20Sopenharmony_cidevice numbers and ``/dev`` directory nodes for the Linux operating
88c2ecf20Sopenharmony_cisystem.
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ciThe LaTeX version of this document is no longer maintained, nor is
118c2ecf20Sopenharmony_cithe document that used to reside at lanana.org.  This version in the
128c2ecf20Sopenharmony_cimainline Linux kernel is the master document.  Updates shall be sent
138c2ecf20Sopenharmony_cias patches to the kernel maintainers (see the
148c2ecf20Sopenharmony_ci:ref:`Documentation/process/submitting-patches.rst <submittingpatches>` document).
158c2ecf20Sopenharmony_ciSpecifically explore the sections titled "CHAR and MISC DRIVERS", and
168c2ecf20Sopenharmony_ci"BLOCK LAYER" in the MAINTAINERS file to find the right maintainers
178c2ecf20Sopenharmony_cito involve for character and block devices.
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ciThis document is included by reference into the Filesystem Hierarchy
208c2ecf20Sopenharmony_ciStandard (FHS).	 The FHS is available from https://www.pathname.com/fhs/.
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ciAllocations marked (68k/Amiga) apply to Linux/68k on the Amiga
238c2ecf20Sopenharmony_ciplatform only.	Allocations marked (68k/Atari) apply to Linux/68k on
248c2ecf20Sopenharmony_cithe Atari platform only.
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ciThis document is in the public domain.	The authors requests, however,
278c2ecf20Sopenharmony_cithat semantically altered versions are not distributed without
288c2ecf20Sopenharmony_cipermission of the authors, assuming the authors can be contacted without
298c2ecf20Sopenharmony_cian unreasonable effort.
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_ci.. attention::
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ci  DEVICE DRIVERS AUTHORS PLEASE READ THIS
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ci  Linux now has extensive support for dynamic allocation of device numbering
378c2ecf20Sopenharmony_ci  and can use ``sysfs`` and ``udev`` (``systemd``) to handle the naming needs.
388c2ecf20Sopenharmony_ci  There are still some exceptions in the serial and boot device area. Before
398c2ecf20Sopenharmony_ci  asking   for a device number make sure you actually need one.
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_ci  To have a major number allocated, or a minor number in situations
428c2ecf20Sopenharmony_ci  where that applies (e.g. busmice), please submit a patch and send to
438c2ecf20Sopenharmony_ci  the authors as indicated above.
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ci  Keep the description of the device *in the same format
468c2ecf20Sopenharmony_ci  as this list*. The reason for this is that it is the only way we have
478c2ecf20Sopenharmony_ci  found to ensure we have all the requisite information to publish your
488c2ecf20Sopenharmony_ci  device and avoid conflicts.
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_ci  Finally, sometimes we have to play "namespace police."  Please don't be
518c2ecf20Sopenharmony_ci  offended.  We often get submissions for ``/dev`` names that would be bound
528c2ecf20Sopenharmony_ci  to cause conflicts down the road.  We are trying to avoid getting in a
538c2ecf20Sopenharmony_ci  situation where we would have to suffer an incompatible forward
548c2ecf20Sopenharmony_ci  change.  Therefore, please consult with us **before** you make your
558c2ecf20Sopenharmony_ci  device names and numbers in any way public, at least to the point
568c2ecf20Sopenharmony_ci  where it would be at all difficult to get them changed.
578c2ecf20Sopenharmony_ci
588c2ecf20Sopenharmony_ci  Your cooperation is appreciated.
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_ci.. include:: devices.txt
618c2ecf20Sopenharmony_ci   :literal:
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_ciAdditional ``/dev/`` directory entries
648c2ecf20Sopenharmony_ci--------------------------------------
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_ciThis section details additional entries that should or may exist in
678c2ecf20Sopenharmony_cithe /dev directory.  It is preferred that symbolic links use the same
688c2ecf20Sopenharmony_ciform (absolute or relative) as is indicated here.  Links are
698c2ecf20Sopenharmony_ciclassified as "hard" or "symbolic" depending on the preferred type of
708c2ecf20Sopenharmony_cilink; if possible, the indicated type of link should be used.
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_ciCompulsory links
738c2ecf20Sopenharmony_ci++++++++++++++++
748c2ecf20Sopenharmony_ci
758c2ecf20Sopenharmony_ciThese links should exist on all systems:
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_ci=============== =============== =============== ===============================
788c2ecf20Sopenharmony_ci/dev/fd		/proc/self/fd	symbolic	File descriptors
798c2ecf20Sopenharmony_ci/dev/stdin	fd/0		symbolic	stdin file descriptor
808c2ecf20Sopenharmony_ci/dev/stdout	fd/1		symbolic	stdout file descriptor
818c2ecf20Sopenharmony_ci/dev/stderr	fd/2		symbolic	stderr file descriptor
828c2ecf20Sopenharmony_ci/dev/nfsd	socksys		symbolic	Required by iBCS-2
838c2ecf20Sopenharmony_ci/dev/X0R	null		symbolic	Required by iBCS-2
848c2ecf20Sopenharmony_ci=============== =============== =============== ===============================
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_ciNote: ``/dev/X0R`` is <letter X>-<digit 0>-<letter R>.
878c2ecf20Sopenharmony_ci
888c2ecf20Sopenharmony_ciRecommended links
898c2ecf20Sopenharmony_ci+++++++++++++++++
908c2ecf20Sopenharmony_ci
918c2ecf20Sopenharmony_ciIt is recommended that these links exist on all systems:
928c2ecf20Sopenharmony_ci
938c2ecf20Sopenharmony_ci
948c2ecf20Sopenharmony_ci=============== =============== =============== ===============================
958c2ecf20Sopenharmony_ci/dev/core	/proc/kcore	symbolic	Backward compatibility
968c2ecf20Sopenharmony_ci/dev/ramdisk	ram0		symbolic	Backward compatibility
978c2ecf20Sopenharmony_ci/dev/ftape	qft0		symbolic	Backward compatibility
988c2ecf20Sopenharmony_ci/dev/bttv0	video0		symbolic	Backward compatibility
998c2ecf20Sopenharmony_ci/dev/radio	radio0		symbolic	Backward compatibility
1008c2ecf20Sopenharmony_ci/dev/i2o*	/dev/i2o/*	symbolic	Backward compatibility
1018c2ecf20Sopenharmony_ci/dev/scd?	sr?		hard		Alternate SCSI CD-ROM name
1028c2ecf20Sopenharmony_ci=============== =============== =============== ===============================
1038c2ecf20Sopenharmony_ci
1048c2ecf20Sopenharmony_ciLocally defined links
1058c2ecf20Sopenharmony_ci+++++++++++++++++++++
1068c2ecf20Sopenharmony_ci
1078c2ecf20Sopenharmony_ciThe following links may be established locally to conform to the
1088c2ecf20Sopenharmony_ciconfiguration of the system.  This is merely a tabulation of existing
1098c2ecf20Sopenharmony_cipractice, and does not constitute a recommendation.  However, if they
1108c2ecf20Sopenharmony_ciexist, they should have the following uses.
1118c2ecf20Sopenharmony_ci
1128c2ecf20Sopenharmony_ci=============== =============== =============== ===============================
1138c2ecf20Sopenharmony_ci/dev/mouse	mouse port	symbolic	Current mouse device
1148c2ecf20Sopenharmony_ci/dev/tape	tape device	symbolic	Current tape device
1158c2ecf20Sopenharmony_ci/dev/cdrom	CD-ROM device	symbolic	Current CD-ROM device
1168c2ecf20Sopenharmony_ci/dev/cdwriter	CD-writer	symbolic	Current CD-writer device
1178c2ecf20Sopenharmony_ci/dev/scanner	scanner		symbolic	Current scanner device
1188c2ecf20Sopenharmony_ci/dev/modem	modem port	symbolic	Current dialout device
1198c2ecf20Sopenharmony_ci/dev/root	root device	symbolic	Current root filesystem
1208c2ecf20Sopenharmony_ci/dev/swap	swap device	symbolic	Current swap device
1218c2ecf20Sopenharmony_ci=============== =============== =============== ===============================
1228c2ecf20Sopenharmony_ci
1238c2ecf20Sopenharmony_ci``/dev/modem`` should not be used for a modem which supports dialin as
1248c2ecf20Sopenharmony_ciwell as dialout, as it tends to cause lock file problems.  If it
1258c2ecf20Sopenharmony_ciexists, ``/dev/modem`` should point to the appropriate primary TTY device
1268c2ecf20Sopenharmony_ci(the use of the alternate callout devices is deprecated).
1278c2ecf20Sopenharmony_ci
1288c2ecf20Sopenharmony_ciFor SCSI devices, ``/dev/tape`` and ``/dev/cdrom`` should point to the
1298c2ecf20Sopenharmony_ci*cooked* devices (``/dev/st*`` and ``/dev/sr*``, respectively), whereas
1308c2ecf20Sopenharmony_ci``/dev/cdwriter`` and /dev/scanner should point to the appropriate generic
1318c2ecf20Sopenharmony_ciSCSI devices (/dev/sg*).
1328c2ecf20Sopenharmony_ci
1338c2ecf20Sopenharmony_ci``/dev/mouse`` may point to a primary serial TTY device, a hardware mouse
1348c2ecf20Sopenharmony_cidevice, or a socket for a mouse driver program (e.g. ``/dev/gpmdata``).
1358c2ecf20Sopenharmony_ci
1368c2ecf20Sopenharmony_ciSockets and pipes
1378c2ecf20Sopenharmony_ci+++++++++++++++++
1388c2ecf20Sopenharmony_ci
1398c2ecf20Sopenharmony_ciNon-transient sockets and named pipes may exist in /dev.  Common entries are:
1408c2ecf20Sopenharmony_ci
1418c2ecf20Sopenharmony_ci=============== =============== ===============================================
1428c2ecf20Sopenharmony_ci/dev/printer	socket		lpd local socket
1438c2ecf20Sopenharmony_ci/dev/log	socket		syslog local socket
1448c2ecf20Sopenharmony_ci/dev/gpmdata	socket		gpm mouse multiplexer
1458c2ecf20Sopenharmony_ci=============== =============== ===============================================
1468c2ecf20Sopenharmony_ci
1478c2ecf20Sopenharmony_ciMount points
1488c2ecf20Sopenharmony_ci++++++++++++
1498c2ecf20Sopenharmony_ci
1508c2ecf20Sopenharmony_ciThe following names are reserved for mounting special filesystems
1518c2ecf20Sopenharmony_ciunder /dev.  These special filesystems provide kernel interfaces that
1528c2ecf20Sopenharmony_cicannot be provided with standard device nodes.
1538c2ecf20Sopenharmony_ci
1548c2ecf20Sopenharmony_ci=============== =============== ===============================================
1558c2ecf20Sopenharmony_ci/dev/pts	devpts		PTY slave filesystem
1568c2ecf20Sopenharmony_ci/dev/shm	tmpfs		POSIX shared memory maintenance access
1578c2ecf20Sopenharmony_ci=============== =============== ===============================================
1588c2ecf20Sopenharmony_ci
1598c2ecf20Sopenharmony_ciTerminal devices
1608c2ecf20Sopenharmony_ci----------------
1618c2ecf20Sopenharmony_ci
1628c2ecf20Sopenharmony_ciTerminal, or TTY devices are a special class of character devices.  A
1638c2ecf20Sopenharmony_citerminal device is any device that could act as a controlling terminal
1648c2ecf20Sopenharmony_cifor a session; this includes virtual consoles, serial ports, and
1658c2ecf20Sopenharmony_cipseudoterminals (PTYs).
1668c2ecf20Sopenharmony_ci
1678c2ecf20Sopenharmony_ciAll terminal devices share a common set of capabilities known as line
1688c2ecf20Sopenharmony_cidisciplines; these include the common terminal line discipline as well
1698c2ecf20Sopenharmony_cias SLIP and PPP modes.
1708c2ecf20Sopenharmony_ci
1718c2ecf20Sopenharmony_ciAll terminal devices are named similarly; this section explains the
1728c2ecf20Sopenharmony_cinaming and use of the various types of TTYs.  Note that the naming
1738c2ecf20Sopenharmony_ciconventions include several historical warts; some of these are
1748c2ecf20Sopenharmony_ciLinux-specific, some were inherited from other systems, and some
1758c2ecf20Sopenharmony_cireflect Linux outgrowing a borrowed convention.
1768c2ecf20Sopenharmony_ci
1778c2ecf20Sopenharmony_ciA hash mark (``#``) in a device name is used here to indicate a decimal
1788c2ecf20Sopenharmony_cinumber without leading zeroes.
1798c2ecf20Sopenharmony_ci
1808c2ecf20Sopenharmony_ciVirtual consoles and the console device
1818c2ecf20Sopenharmony_ci+++++++++++++++++++++++++++++++++++++++
1828c2ecf20Sopenharmony_ci
1838c2ecf20Sopenharmony_ciVirtual consoles are full-screen terminal displays on the system video
1848c2ecf20Sopenharmony_cimonitor.  Virtual consoles are named ``/dev/tty#``, with numbering
1858c2ecf20Sopenharmony_cistarting at ``/dev/tty1``; ``/dev/tty0`` is the current virtual console.
1868c2ecf20Sopenharmony_ci``/dev/tty0`` is the device that should be used to access the system video
1878c2ecf20Sopenharmony_cicard on those architectures for which the frame buffer devices
1888c2ecf20Sopenharmony_ci(``/dev/fb*``) are not applicable. Do not use ``/dev/console``
1898c2ecf20Sopenharmony_cifor this purpose.
1908c2ecf20Sopenharmony_ci
1918c2ecf20Sopenharmony_ciThe console device, ``/dev/console``, is the device to which system
1928c2ecf20Sopenharmony_cimessages should be sent, and on which logins should be permitted in
1938c2ecf20Sopenharmony_cisingle-user mode.  Starting with Linux 2.1.71, ``/dev/console`` is managed
1948c2ecf20Sopenharmony_ciby the kernel; for previous versions it should be a symbolic link to
1958c2ecf20Sopenharmony_cieither ``/dev/tty0``, a specific virtual console such as ``/dev/tty1``, or to
1968c2ecf20Sopenharmony_cia serial port primary (``tty*``, not ``cu*``) device, depending on the
1978c2ecf20Sopenharmony_ciconfiguration of the system.
1988c2ecf20Sopenharmony_ci
1998c2ecf20Sopenharmony_ciSerial ports
2008c2ecf20Sopenharmony_ci++++++++++++
2018c2ecf20Sopenharmony_ci
2028c2ecf20Sopenharmony_ciSerial ports are RS-232 serial ports and any device which simulates
2038c2ecf20Sopenharmony_cione, either in hardware (such as internal modems) or in software (such
2048c2ecf20Sopenharmony_cias the ISDN driver.)  Under Linux, each serial ports has two device
2058c2ecf20Sopenharmony_cinames, the primary or callin device and the alternate or callout one.
2068c2ecf20Sopenharmony_ciEach kind of device is indicated by a different letter.	 For any
2078c2ecf20Sopenharmony_ciletter X, the names of the devices are ``/dev/ttyX#`` and ``/dev/cux#``,
2088c2ecf20Sopenharmony_cirespectively; for historical reasons, ``/dev/ttyS#`` and ``/dev/ttyC#``
2098c2ecf20Sopenharmony_cicorrespond to ``/dev/cua#`` and ``/dev/cub#``. In the future, it should be
2108c2ecf20Sopenharmony_ciexpected that multiple letters will be used; all letters will be upper
2118c2ecf20Sopenharmony_cicase for the "tty" device (e.g. ``/dev/ttyDP#``) and lower case for the
2128c2ecf20Sopenharmony_ci"cu" device (e.g. ``/dev/cudp#``).
2138c2ecf20Sopenharmony_ci
2148c2ecf20Sopenharmony_ciThe names ``/dev/ttyQ#`` and ``/dev/cuq#`` are reserved for local use.
2158c2ecf20Sopenharmony_ci
2168c2ecf20Sopenharmony_ciThe alternate devices provide for kernel-based exclusion and somewhat
2178c2ecf20Sopenharmony_cidifferent defaults than the primary devices.  Their main purpose is to
2188c2ecf20Sopenharmony_ciallow the use of serial ports with programs with no inherent or broken
2198c2ecf20Sopenharmony_cisupport for serial ports.  Their use is deprecated, and they may be
2208c2ecf20Sopenharmony_ciremoved from a future version of Linux.
2218c2ecf20Sopenharmony_ci
2228c2ecf20Sopenharmony_ciArbitration of serial ports is provided by the use of lock files with
2238c2ecf20Sopenharmony_cithe names ``/var/lock/LCK..ttyX#``. The contents of the lock file should
2248c2ecf20Sopenharmony_cibe the PID of the locking process as an ASCII number.
2258c2ecf20Sopenharmony_ci
2268c2ecf20Sopenharmony_ciIt is common practice to install links such as /dev/modem
2278c2ecf20Sopenharmony_ciwhich point to serial ports.  In order to ensure proper locking in the
2288c2ecf20Sopenharmony_cipresence of these links, it is recommended that software chase
2298c2ecf20Sopenharmony_cisymlinks and lock all possible names; additionally, it is recommended
2308c2ecf20Sopenharmony_cithat a lock file be installed with the corresponding alternate
2318c2ecf20Sopenharmony_cidevice.	 In order to avoid deadlocks, it is recommended that the locks
2328c2ecf20Sopenharmony_ciare acquired in the following order, and released in the reverse:
2338c2ecf20Sopenharmony_ci
2348c2ecf20Sopenharmony_ci	1. The symbolic link name, if any (``/var/lock/LCK..modem``)
2358c2ecf20Sopenharmony_ci	2. The "tty" name (``/var/lock/LCK..ttyS2``)
2368c2ecf20Sopenharmony_ci	3. The alternate device name (``/var/lock/LCK..cua2``)
2378c2ecf20Sopenharmony_ci
2388c2ecf20Sopenharmony_ciIn the case of nested symbolic links, the lock files should be
2398c2ecf20Sopenharmony_ciinstalled in the order the symlinks are resolved.
2408c2ecf20Sopenharmony_ci
2418c2ecf20Sopenharmony_ciUnder no circumstances should an application hold a lock while waiting
2428c2ecf20Sopenharmony_cifor another to be released.  In addition, applications which attempt
2438c2ecf20Sopenharmony_cito create lock files for the corresponding alternate device names
2448c2ecf20Sopenharmony_cishould take into account the possibility of being used on a non-serial
2458c2ecf20Sopenharmony_ciport TTY, for which no alternate device would exist.
2468c2ecf20Sopenharmony_ci
2478c2ecf20Sopenharmony_ciPseudoterminals (PTYs)
2488c2ecf20Sopenharmony_ci++++++++++++++++++++++
2498c2ecf20Sopenharmony_ci
2508c2ecf20Sopenharmony_ciPseudoterminals, or PTYs, are used to create login sessions or provide
2518c2ecf20Sopenharmony_ciother capabilities requiring a TTY line discipline (including SLIP or
2528c2ecf20Sopenharmony_ciPPP capability) to arbitrary data-generation processes.	 Each PTY has
2538c2ecf20Sopenharmony_cia master side, named ``/dev/pty[p-za-e][0-9a-f]``, and a slave side, named
2548c2ecf20Sopenharmony_ci``/dev/tty[p-za-e][0-9a-f]``.  The kernel arbitrates the use of PTYs by
2558c2ecf20Sopenharmony_ciallowing each master side to be opened only once.
2568c2ecf20Sopenharmony_ci
2578c2ecf20Sopenharmony_ciOnce the master side has been opened, the corresponding slave device
2588c2ecf20Sopenharmony_cican be used in the same manner as any TTY device.  The master and
2598c2ecf20Sopenharmony_cislave devices are connected by the kernel, generating the equivalent
2608c2ecf20Sopenharmony_ciof a bidirectional pipe with TTY capabilities.
2618c2ecf20Sopenharmony_ci
2628c2ecf20Sopenharmony_ciRecent versions of the Linux kernels and GNU libc contain support for
2638c2ecf20Sopenharmony_cithe System V/Unix98 naming scheme for PTYs, which assigns a common
2648c2ecf20Sopenharmony_cidevice, ``/dev/ptmx``, to all the masters (opening it will automatically
2658c2ecf20Sopenharmony_cigive you a previously unassigned PTY) and a subdirectory, ``/dev/pts``,
2668c2ecf20Sopenharmony_cifor the slaves; the slaves are named with decimal integers (``/dev/pts/#``
2678c2ecf20Sopenharmony_ciin our notation).  This removes the problem of exhausting the
2688c2ecf20Sopenharmony_cinamespace and enables the kernel to automatically create the device
2698c2ecf20Sopenharmony_cinodes for the slaves on demand using the "devpts" filesystem.
270