Наши партнеры








Книги по Linux (с отзывами читателей)

Библиотека сайта rus-linux.net

5.2. The mknod command

MAKEDEV is the preferred way of creating device files which are not present. However sometimes the MAKEDEV script will not know about the device file you wish to create. This is where the mknod command comes in. In order to use mknod you need to know the major and minor node numbers for the device you wish to create. The devices.txt file in the kernel source documentation is the canonical source of this information.

To take an example, let us suppose that our version of the MAKEDEV script does not know how to create the /dev/ttyS0 device file. We need to use mknod to create it. We know from looking at the devices.txt file that it should be a character device with major number 4 and minor number 64. So we now know all we need to create the file.
	# mknod /dev/ttyS0 c 4 64
	# chown root.dialout /dev/ttyS0
	# chmod 0644 /dev/ttyS0
	# ls -l /dev/ttyS0
crw-rw----   1 root dialout    4,   64 Oct 23 18:23 /dev/ttyS0 
	
As you can see, many more steps are required to create the file. In this example you can see the process required however. It is unlikely in the extreme that the ttyS0 file would not be provided by the MAKEDEV script, but it suffices to illustrate the point.