makedev.xml 4.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <sect1 id="ch-system-MAKEDEV" xreflabel="Make_devices">
  2. <title>Creating devices with Make_devices-&makedev-version;</title>
  3. <?dbhtml filename="makedevices.html" dir="chapter06"?>
  4. <para>The Make_devices package contains a script for creating device
  5. nodes.</para>
  6. <screen>&buildtime; &makedev-time;
  7. &diskspace; &makedev-compsize;</screen>
  8. &aa-makedev-down;
  9. &aa-makedev-dep;
  10. <sect2><title>&nbsp;</title><para>&nbsp;</para></sect2>
  11. <sect2>
  12. <title>Making devices</title>
  13. <para>Note that unpacking the
  14. <filename>make_devices-&makedev-version;.bz2</filename> file doesn't
  15. create a directory for you to <command>cd</command> into, as the file
  16. contains only a shell script.</para>
  17. <para>Install the <filename>make_devices</filename> script:</para>
  18. <screen><userinput>bzcat make_devices-&makedev-version;.bz2 &gt; /dev/make_devices
  19. chmod 754 /dev/make_devices</userinput></screen>
  20. <para>Device nodes are special files: things that can generate or receive data.
  21. They usually correspond to physical pieces of hardware. Device nodes can be
  22. created by issuing commands of the form: <command>mknod -m mode name type major
  23. minor</command>. In such a command, <emphasis>mode</emphasis> is the usual
  24. octal read/write/execute permissions triplet, and <emphasis>name</emphasis> is
  25. the name of the device file to be created. It may seem surprising, but the
  26. device name is actually arbitrary, except that most programs rely on devices
  27. such as <filename>/dev/null</filename> having their usual names. The remaining
  28. three parameters tell the kernel what device the node
  29. actually refers to. The <emphasis>type</emphasis> is a letter, either b or c,
  30. indicating whether the device is accessed in blocks (such as a hard disk) or
  31. character by character (such as the console). And <emphasis>major</emphasis>
  32. and <emphasis>minor</emphasis> are numbers, together forming a code that
  33. identifies the device to the kernel. A list of the currently assigned device
  34. numbers for Linux can be found in the file <filename>devices.txt</filename> in
  35. the <filename class="directory">Documentation</filename> subdirectory of the
  36. kernel sources.</para>
  37. <para>Note that the same major/minor combination is usually assigned to both a
  38. block and a character device. These are, however, completely unrelated devices
  39. that cannot be interchanged. A device is identified by the type/major/minor
  40. triple, not just the major/minor pair, so when creating a device node it is
  41. important to choose the correct <emphasis>type</emphasis> of device.</para>
  42. <para>Because looking up the type/major/minor triples and using
  43. <command>mknod</command> manually is tedious and error-prone, the
  44. <filename>make_devices</filename> script has been created. It contains a whole
  45. series of <command>mknod</command> commands, one for each device, complete with
  46. recommended name, permissions and group assignment. It has been set up so that
  47. only a minimal set of commonly used devices is enabled and the other lines are
  48. commented out. You should open <filename>make_devices</filename> in an editor
  49. and customize it to your needs. This takes some time, but is very simple. When
  50. you are satisfied, run the script to create the device files:</para>
  51. <screen><userinput>cd /dev
  52. ./make_devices</userinput></screen>
  53. <para>If you had success with mounting the devpts file system earlier in <xref
  54. linkend="ch-system-proc"/>, you can continue with the next section. If you were
  55. unable to mount devpts, you will have to create a few static ptyXX and ttyXX
  56. device nodes instead. To do this, open <filename>make_devices</filename> in
  57. your editor, go to the section "Pseudo-TTY masters" and enable a few ptyXX
  58. devices -- a handful are enough to enable the test suites to run, but if you
  59. plan to run a kernel without devpts support you will probably need many more
  60. (every xterm, ssh connection, telnet connection, and the like, uses one of
  61. these pseudo terminals). In the immediately following section "Pseudo-TTY
  62. slaves", enable the corresponding ttyXX devices. When you are done, rerun
  63. <command>./make_devices</command> from inside <filename>/dev</filename> to
  64. have it create the new devices.</para>
  65. </sect2>
  66. &aa-makedev-shortdesc;
  67. &aa-makedev-desc;
  68. </sect1>