From 540fd314f00433a16f39240e47f4af19b74297e8 Mon Sep 17 00:00:00 2001 From: Alex Gronenwoud Date: Sat, 7 Feb 2004 14:55:52 +0000 Subject: Replacing MAKEDEV with make_devices. git-svn-id: http://svn.linuxfromscratch.org/LFS/trunk/BOOK@3236 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689 --- chapter06/makedev.xml | 122 +++++++++++++++++++++++++++++--------------------- 1 file changed, 70 insertions(+), 52 deletions(-) (limited to 'chapter06') diff --git a/chapter06/makedev.xml b/chapter06/makedev.xml index 0763e8c8f..3fce5fb6a 100644 --- a/chapter06/makedev.xml +++ b/chapter06/makedev.xml @@ -1,8 +1,9 @@ - -Creating devices with Makedev-&makedev-version; - + +Creating devices with Make_devices-&makedev-version; + -The MAKEDEV package contains a script for making device nodes. +The Make_devices package contains a script for creating device +nodes. &buildtime; &makedev-time; &diskspace; &makedev-compsize; @@ -15,62 +16,79 @@ Making devices -Note that unpacking the MAKEDEV-&makedev-version;.bz2 -file doesn't create a directory for you to cd into, as -the file contains only a shell script. +Note that unpacking the +make_devices-&makedev-version;.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-&makedev-version;.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, and 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 piece of hardware the device 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 are 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: -Install the MAKEDEV script: - -bzcat MAKEDEV-&makedev-version;.bz2 > /dev/MAKEDEV -chmod 754 /dev/MAKEDEV +cd /dev +./make_devices -Run the script to create the device files: +(The FHS states that there should be a MAKEDEV +script present in the /dev directory. +But the FHS is mistaken: it should not dictate anything about files, and limit +itself to directories.) -cd /dev -./MAKEDEV -v generic-nopty - -The meaning of the arguments: - - --v: This tells the script to run in -verbose mode. - -generic-nopty: This instructs -MAKEDEV to create a generic selection of commonly used -device special files, except for the ptyXX and ttyXX range of files. We don't -need those files because we are going to use Unix98 PTYs via the -devpts file system. - - -If it turns out that some special device zzz that -you need is missing, try running ./MAKEDEV -v zzz. -Alternatively, you may create devices via the mknod -program. Please refer to its man and info pages if you need more -information. - -If you wish your system to be FHS-compliant, then the -MAKEDEV script has to remain present in the -/dev directory. This way it is always -available for making extra device nodes. - -Additionally, if you were unable to mount the devpts file system earlier -in , now is the time to try the alternatives. If -your kernel supports the devfs file system, run the following command to mount +If you had success with mounting the devpts file system earlier in , you can continue with the next section. If you were +unable to mount devpts, now is the time to try the alternatives. If your kernel +supports the devfs file system, run the following command to mount devfs: mount -t devfs devfs /dev This will mount the devfs file system over the top of the new static -/dev structure. This poses no problems, as the device nodes -created are still present, they are just hidden by the new devfs -file system. - -If this still doesn't work, the only option left is to use the MAKEDEV -script to create the ptyXX and ttyXX range of files that would otherwise not be -needed. Ensure you are still in the /dev directory then run -./MAKEDEV -v pty. The downside of this is, we are -creating an extra 512 device special files which will not be needed when we -finally boot into the finished LFS system. +/dev structure. This poses no problems, as the device +nodes created are still present, they are just hidden by the new devfs file +system. + +If that didn't work either, the only option left is to create a few ptyXX +and ttyXX device nodes. To do this, open make_devices in +your editor, go to the section "Pseudo-TTY masters" and enable as many ptyXX +devices as you think you will need (one for every active xterm, ssh connection, +telnet connection, and so on). 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. -- cgit v1.2.3-54-g00ecf