Creating devices with Make_devices-1.2

The Make_devices package contains a script for creating device nodes.

Approximate build time:  1 SBU
Required disk space:     160 KB

For its installation Make_devices depends on: Bash, Bzip2, Coreutils.

Making devices

Note that unpacking the make_devices-1.2.bz2 file doesn't create a directory for you to cd into, as the file contains only a shell script.

Install the make_devices script:

bzcat make_devices-1.2.bz2 > /dev/make_devices
chmod 754 /dev/make_devices

Device nodes are special files: things that can generate or receive data. They usually correspond to physical pieces of hardware. Device nodes can be created by issuing commands of the form: mknod -m mode name type major minor. In such a command, mode is the usual octal read/write/execute permissions triplet, and name is the name of the device file to be created. It may seem surprising, but the device name is actually arbitrary, except that most programs rely on devices such as /dev/null having their usual names. The remaining three parameters tell the kernel what device the node actually refers to. The type is a letter, either b or c, indicating whether the device is accessed in blocks (such as a hard disk) or character by character (such as the console). And major and minor are numbers, together forming a code that identifies the device to the kernel. A list of the currently assigned device numbers for Linux can be found in the file devices.txt in the Documentation subdirectory of the kernel sources.

Note that the same major/minor combination is usually assigned to both a block and a character device. These are, however, completely unrelated devices that cannot be interchanged. A device is identified by the type/major/minor triple, not just the major/minor pair, so when creating a device node it is important to choose the correct type of device.

Because looking up the type/major/minor triples and using mknod manually is tedious and error-prone, the make_devices script has been created. It contains a whole series of mknod commands, one for each device, complete with recommended name, permissions and group assignment. It has been set up so that only a minimal set of commonly used devices is enabled and the other lines are commented out. You should open make_devices in an editor and customize it to your needs. This takes some time, but is very simple. When you are satisfied, run the script to create the device files:

cd /dev
./make_devices

If you had success with mounting the devpts file system earlier in the section called “Mounting the proc and devpts file systems”, you can continue with the next section. If you were unable to mount devpts, you will have to create a few static ptyXX and ttyXX device nodes instead. To do this, open make_devices in your editor, go to the section “Pseudo-TTY masters” and enable a few ptyXX devices -- a handful are enough to enable the test suites to run, but if you plan to run a kernel without devpts support you will probably need many more (every xterm, ssh connection, telnet connection, and the like, uses one of these pseudo terminals). In the immediately following section “Pseudo-TTY slaves”, enable the corresponding ttyXX devices. When you are done, rerun ./make_devices from inside /dev to have it create the new devices.

Contents of Make_devices

Installed script: make_devices

Short description

make_devices is a script for creating a basic set of static device nodes, usually residing in the /dev directory.