Introduction to Linux Device files __linux

Source: Internet
Author: User
Tags generator reserved nfsd
OverviewThere are 2 types of devices in Linux: Character devices (no buffering and only sequential access), block devices (with buffering and random access). Each character device and block device must have a primary, secondary device number, and the same device as the primary device is the same device (using the same driver). Some of these devices are abstractions of physical hardware that actually exist, while others are functions provided by the kernel itself (not dependent on specific physical hardware, also known as "virtual Device"). Each device has a corresponding file (node) in the/dev directory. You can view the main device number of a device driver that is currently loaded by using the Cat/proc/devices command. All devices that the kernel can recognize are recorded in the Documentation/devices.txt file under the original code tree. In the/dev directory, in addition to character devices and block device nodes, there are usually also: FIFO pipes, sockets, soft/hard connections, directories. These things do not have a primary/secondary device number.
Device Files
----------------------------------------------------------------------main device number device type sub-device number = filename Brief description----------------------------------------------------------------------0 unnamed device (for example: mounted non-device) 0 = reserved for empty device number 1 C Har memory Device 1 =/dev/mem Direct access to physical memory 2 =/DEV/KMEM Access after kernel virtual memory 3 =/dev/null empty device.
		  Any writes will be discarded directly, and any reads will get EOF.
		  4 =/dev/port Access I/O port 5 =/dev/zero 0 byte source, can read only an unlimited number of 0 bytes. 7 =/dev/full Full equipment.
		  Any writes will fail with the errno set to ENOSPC to indicate that there is no space left. 8 =/dev/random random number generator.
					Random numbers are generated entirely by user input.
		  If the user stops all actions, the new random number is stopped. 9 =/dev/urandom faster, but less secure random number generator.
		 As far as possible by the user input to generate random numbers, if the user stops all actions, the already produced random number as a seed to produce new random number. /dev/aio asynchronous I/O notification interface one =/dev/kmsg any write to the file will be the output of PRINTK 1 Block RAM Disk 0 =/dev/ram0 1th RAM dis
		K (Initrd can only use ram0) 1 =/dev/ram1 2nd RAM disk ...
		 MB =/dev/ram200 No. 200 RAM Disk 4 char TTY (terminal) device 0 =/dev/tty0 Current Virtual Console 1 =/dev/tty1 1th Virtual Console ...	/dev/tty63 = 63rd Virtual Console 4 blockIf the root file system is mounted as read-only, then it is not possible to create a true device node by using the device as the alias for dynamically allocated primary (major) devices 0 =/dev/root 5 char Other TTY devices 0 =/dev/tty current TTY device 1 =/dev/console system console (typically/dev/tty0) 2 =/dev/ptmx all PTY master multiplexer 7 Char Virtual Console capture
		 Devices (These devices allow both read and write) 0 =/dev/vcs The text content of the current Virtual Console (VC) 1 =/dev/vcs1 tty1 text content ...
		tty63 =/dev/vcs63 text content 128 =/DEV/VCSA Text/property Content 129 =/DEV/VCSA1 tty1 text/attribute content for the current Virtual Console (VC) ... 191 =/dev/vcsa63 tty63 text/property content 7 block loop device (using a common disk file to simulate a piece of equipment) the binding of a loopback device is handled by Mount (8) or Losetup (8) 0 =/dev/lo


  OP0 1th Loopback Device 1 =/DEV/LOOP1 2nd loopback device ... 8 Block SCSI disk (0-15) 0 =/DEV/SDA 1th SCSI disk (entire disk) =/DEV/SDB 2nd SCSI disk (entire disk) =/DEV/SDC 3rd SCSI Magnetic
		Disk (entire disk) ... /DEV/SDP = the 16th SCSI disk (entire disk) partition representation method is as follows (for the 3rd SCSI disk for example)/DEV/SDC1 = 1th partition =/DEV/SDC2 2nd partition.
		 .


  /DEV/SDC15 = 15th partition for linux/i386, partition 1-4 is the primary partition and 5-15 is a logical partition. 9 Block Metadisk (RAID) Device 0 =/dev/md0		Group 1th Metadisk 1 =/dev/md1 2nd group Metadisk ... metadisk driver is used to split the same file system onto multiple physical disks.
		All kinds of miscellaneous devices and Features 1 =/dev/psaux PS/2 mouse 131 =/dev/temperature machine internal temperature 134 =/dev/apm_bios APM (Advanced Power Management) BIOS  135 =/DEV/RTC Realtime clock (real time Clock) 144 =/dev/nvram Non-volatile configuration RAM 162 =/dev/smbus System Management Bus (Systems Management buses) 164 =/DEV/IPMO Intel's Intelligent Platform Management (Intelligent Platform Management) Interface 173 =/DEV/IPMIKCS Intelligent Platform Management (Intelligent Platform Management) Interface 175 =/dev/agpgart AGP Graphics address remapping table (Graphics addresses remapping table) =/dev/perfctr performance monitoring Counters 183 =/DEV/HWRNG General Hardware
		Random number Generator 184 =/dev/cpu/microcode CPU Micro-code Update Interface 186 = Atomic snapshot of/dev/atomicps process state data 188 =/dev/smbusbios SMBus (System Management Bus) BIOS
		=/dev/net/tun Tap/tun Network device (Tap/tun implements network device in software) TAP simulates Ethernet frames (the second layer), Tun simulates IP packets (third tier). /dev/emd/ctl-Enhanced Metadisk RAID (EMD) Controller/DEV/MPTCTL = passing technology (MPT) Control 223 =/dev/i Nput/uinput user layer input device driver Support/dev/mcelog = x86_64 Machine Check Exception DriveR 228 =/dev/hpet Hpet driver 229 =/dev/fuse Fuse (virtual file system for user space) 231 =/dev/snapshot system memory Snapshot 232 =/DEV/KVM kernel based Fictitious machine (based on AMD SVM and Intel VT Hardware virtual Technology) one block SCSI CD-ROM device 0 =/dev/scd0 1th SCSI CD-ROM 1 =/DEV/SCD1 2nd SCSI CD


 -rom ...
		 char core input device =/dev/input/mouse0 1th mouse/dev/input/mouse1 = 2nd mouse ... The 31st mouse/dev/input/mouse30 =/dev/input/mice All mouse's 164 =/dev/input/event0 1th Event queue-/dev/input/even
		 T1 2nd Event Queue ... KM =/DEV/INPUT/EVENT1 32nd event queue char Universal SCSI device (usually SCSI optical drive) 0 =/dev/sg0 1th Universal SCSI Device 1 =/DEV/SG1 2nd General


 SCSI devices ...
		 -Char Universal frame buffer Device 0 =/dev/fb0 1th frame buffer Device 1 =/DEV/FB1 2nd frame buffer Device ... /DEV/FB31 32nd frame buffer device Char iBCS-2 compatible device 0 =/dev/socksys Socket Access interface 1 =/dev/spx SVR3 local X interface =/dev/ INET/IP Network Access Interface/dev/inet/icmp =/DEV/INET/GGP =/dev/inet/ipip =/dev/inet/tcp Notoginseng =/dev/inet /EGP 38 =/dev/inet/pup =/DEV/INET/UDP =/DEV/INET/IDP =/dev/inet/rawip In addition, IBCS-2 requires that the following connections must exist/DEV/IP ; /dev/inet/ip/dev/icmp->/dev/inet/icmp/dev/ggp->/dev/inet/ggp/dev/ipip->/dev/inet/ipip/dev/tcp-  >/DEV/INET/TCP/DEV/EGP->/dev/inet/egp/dev/pup->/dev/inet/pup/dev/udp->/DEV/INET/UDP/DEV/IDP ->/dev/inet/idp/dev/rawip->/dev/inet/rawip/dev/inet/arp->/dev/inet/udp/dev/inet/rip->/dev/ine T/UDP/DEV/NFSD->/dev/socksys/dev/x0r->/dev/null + char netlink support 0 =/dev/route routing, device Update, kernel to User 3 =/dev/fwmonitor Firewall packet replication char SF firewall module 0 =/dev/firewall with SF kernel module communication Block SCSI Magnetic
		    Disk (16-31) 0 =/DEV/SDQ 17th SCSI disk (entire disk) =/DEV/SDR 18th SCSI disk (entire disk) =/DEV/SDS 19th SCSI disk (entire disk)
		... /DEV/SDAF = 32nd SCSI disk (entire disk) block SCSI disk (32-47) 0 =/dev/sdag 33rd SCSI disk (entire disk) =/dev/sdah 3rd 4 SCSI Disks (wholeDisks) =/dev/sdai 35th SCSI disk (entire disk) ...
		    /dev/sdav = 48th SCSI disk (entire disk) 0 =/dev/i2c-0 1th I2C Adapter 1 =/dev/i2c-1 2nd I2C Adapter



 ...


Virtual block device (same partition mode as SCSI disk) 0 =/dev/ubda 1th user mode block device =/DEV/UDBB 2nd user mode block device. Block Audit (Audit) Equipment 0 =/dev/audit Audit (Audit) device 128-135 Char Unix98 PTY Master These devices should not have device nodes, but should be visited through the/DEV/PTMX interface


Ask.
		136-143 Char Unix98 PTY Slave These device nodes are automatically generated (with the appropriate permissions and patterns) and cannot be created manually.
		  The method is to mount the Devpts file system to the/dev/pts directory by using the appropriate mount option (usually the gid> of the:mode=0620,gid=< "TTY" group).


0 =/dev/pts/0 1th Unix98 PTY Slave 1 =/dev/pts/1 2nd Unix98 PTY slave ... 153 Block Enhanced Metadisk RAID (EMD) storage unit (same partition mode as SCSI disk) 0 =/dev/emd/0 1th storage unit 1 =/DEV/EMD/0P1 1th storage Unit 1th
		 Partition 2 = 2nd partition of the 1th storage cell/dev/emd/0p2 ...
		/DEV/EMD/0P15 = 1th storage unit 15th partition =/DEV/EMD/1 2nd storage unit =/DEV/EMD/2 3rd storage unit ...
		/DEV/EMD/15 = 16th storage Unit 180 Char USB character device % =/dev/usb/hiddev0 1th USB Man-machine Interface Device (mouse/keyboard/joystick/handwriting version of the device to operate the computer) ...
		 /DEV/USB/HIDDEV15 16th USB Man-machine Interface Device 180 block USB device (U disk, etc.) 0 =/dev/uba 1th USB block Device 8 =/dev/ubb 2nd USB block device


=/DEV/UBC 3rd USB block Device ... Profiling interface 0 =/dev/profile Profiling control device 1 =/DEV/PROFILE0 CPU 0 Profiling Device 2 =/dev/profi


Le1 CPU 1 Profiling device ...


193 Char kernel event tracking Interface 0 =/dev/trace Tracking control device 1 =/DEV/TRACE0 CPU 0 Tracking Device 2 =/dev/trace1 CPU 1 tracking device ...
		195 Char Nvidia Graphics device (such as graphics card) 0 =/dev/nvidia0 1th nvidia Card 1 =/dev/nvidia1 2nd nvidia card ... 255 =/dev/nvidiactl Nvidia Card control device--CPU-specific registers (model-specific register,msr) 0 =/DEV/CPU/0/MSR CPU 0 MS

Rs 1 =/DEV/CPU/1/MSR CPU 1 MSRs ...
 203 Char CPU CPUID information 0 =/dev/cpu/0/cpuid CPU 0 CPUID 1 =/dev/cpu/1/cpuid CPU 1 CPUID ...

There was no wonder. Why not/dev/hda such a device, is not commonly used. The reason is that starting with the 2.6.19 version, the kernel introduced a new ATA driver, the Sata/pata hard drive unified use/DEV/SD? To show, so/DEV/HD? There is no need for existence. Specifically, instead of using the driver below "ATA/ATAPI/MFM/RLL support" when compiling the kernel, you use the updated "Serial ATA and Parallel ATA drivers" drive. links, sockets, pipes, mount points

This section details some of the files that should or might exist outside of the/dev directory. Links are best used in exactly the same format as this (absolute or relative path). Whether to use a hard link (hard) or a soft connection (symbolic) depends on different devices. Required Links

These connections must be present on all systems:

Link		target		link Type	brief description
/dev/fd		/proc/self/fd	Symbolic	File description mansion
/dev/stdin	fd/0		Symbolic	Standard input file description fu
/dev/stdout	fd/1		symbolic	standard output file descriptor
/dev/stderr	FD /2		Symbolic	standard error file descriptor
/dev/nfsd	Socksys		symbolic only iBCS-2	must
/dev/x0r	Null		symbolic	only iBCS-2 must
[note]/dev/x0r is < letter x>-< Digit 0>-< letter R>
Recommended links

It is recommended that these connections exist on all systems:

Link		target		link Type	brief description
/dev/core	/proc/kcore	symbolic	for backward compatibility
/dev/ramdisk	ram0		symbolic	for backward compatibility with
/dev/ftape	qft0		symbolic	for backward compatibility
/dev/bttv0	video0		symbolic	for backward compatibility with
/dev/radio	radio0		symbolic	for backward compatibility
/dev/i2o*	/dev/i2o/ *	symbolic	for backwards compatibility
/DEV/SCD?	SR?		Hard		instead of the SCSI CD-ROM name
locally-defined links

The links below will most likely require the creation of a portion or even all of them based on the actual hardware configuration of the machine. These links are only intended to cater to customary usage, and they are neither necessary nor recommended.

Link		target		link Type	brief description
/dev/mouse	mouse port	symbolic	current mouse
/dev/tape	tape Device	Symbolic	current tape
/dev/cdrom	CD-ROM device	symbolic	current CD-ROM
/dev/ Cdwriter	cd-writer	symbolic	current Cd-writer/dev/scanner scanner	Current Scanner
/dev/modem	modems Port	symbolic	Current modem
/dev/root	root device	symbolic	Device
/dev/swap	swap device	symbolic current	swap where the current root file system resides

/dev/modem should not be used for modems that can support both incoming and outgoing calls, because it often leads to lock-file problems. If there is a/dev/modem, then it should point to an appropriate master TTY device.

For SCSI devices,/dev/tape and/dev/cdrom should point to "cooked" devices/dev/st* and/dev/sr* respectively, while/dev/cdwriter and/dev/scanner should point to the appropriate/dev/sg*.

/dev/mouse can point to a primary serial TTY device, a hardware mouse, or a socket that corresponds to a mouse driver (for example,/dev/gpmdata). Sockets and Pipelines

Persistent sockets and named pipes can exist in/dev. Common to have:

/dev/printer	Socket		LPD local socket
/dev/log	socket		syslog local socket
/dev/gpmdata	socket		GPM Mouse multiplexer (multiplexer)
/dev/gpmctl	socket		(appearing in LFS-LIVECD)
/dev/initctl	FIFO pipe	Init listens to it and gets information from it (the channel that the user interacts with the init process)
mount point

The following names are reserved for mounting special file systems. These special file systems provide only the kernel interface and do not provide standard device nodes.

/dev/pts	devpts		PTY slave file system
/DEV/SHM		provides direct access to POSIX shared memory
Terminal Equipment

A terminal (or TTY) device is a special type of character device. Terminal equipment is any device that can play a controlling terminal role in a session, including: Virtual Console, serial interface (obsolete), pseudo terminal (PTY).

All terminals share a common set of functions: line discipline, which contains both the generic Terminal line discipline and the slip and PPP modes. All the terminal devices are named very similar. This section will explain naming conventions and the use of various types of TTY (terminals). It should be noted that these naming conventions contain a few legacy baggage. Some of these are unique to Linux, others are inherited from other systems, and some reflect the fact that Linux has grown out of the habit of borrowing from other systems. The pound sign (#) represents a decimal number with no leading zeros in the device name. Virtual Console (VPN console) and console device (console device)

The Virtual Console is the terminal that is displayed in full screen on the system video monitor. The Virtual Console is named the/dev/tty# that starts with the number/dev/tty1. /dev/tty0 is the current Virtual Console. /dev/tty0 is used to access system video cards on machines that cannot use frame buffer devices (/dev/fb*), and note that/dev/console is not used for this purpose. /dev/console is managed by the kernel, and system messages are sent here. Login must be allowed to use/dev/console in single user mode. Serial Interface

The "serial interface" referred to here refers to the RS-232 serial interface and any devices that simulate such interfaces, whether in hardware (such as modems) or in software (such as ISDN drives). Each serial interface in Linux has two device names: the main device or incoming (callin), alternating or outgoing (callout) devices. Device types are differentiated using the case of letters. For example, for any letter x, the "TTY" device is named/dev/ttyx#, and the "CU" Device name is/dev/cux#. Due to historical reasons,/dev/ttys# and/dev/ttyc# are equivalent to/dev/cua# and/dev/cub# respectively. Names/dev/ttyq# and/dev/cuq# are reserved for local use. pseudo terminal (PTY)

Pseudo terminals are used to create login sessions or provide other functions, such as handling arbitrary data generation via TTY line discipline (including slip or PPP functions). Each PTY has a master end and a slave end. According to the System v/unix98 PTY naming scheme, all master terminals share the same/DEV/PTMX device node (the kernel will automatically give an unassigned PTY), all slave are located in the/dev/pts directory, named/dev/pts/# ( The kernel automatically generates and deletes them as needed.

Once the master is opened, the corresponding slave device can be used in exactly the same way as the TTY device. The connection between the master device and the slave device through the kernel is equivalent to a bidirectional pipe (pipe) with TTY functionality.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.