devices.xml 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN" "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
  3. <!ENTITY % general-entities SYSTEM "../general.ent">
  4. %general-entities;
  5. ]>
  6. <sect1 id="ch-system-devices">
  7. <title>Populating /dev</title>
  8. <?dbhtml filename="devices.html"?>
  9. <indexterm zone="ch-system-devices"><primary sortas="e-/dev/">/dev/*</primary></indexterm>
  10. <sect2>
  11. <title>Creating Initial Device Nodes</title>
  12. <para>When the kernel boots the system, it requires the presence of a few device
  13. nodes, in particular the <filename class="devicefile">console</filename> and
  14. <filename class="devicefile">null</filename> devices. Create these by
  15. running the following commands:</para>
  16. <screen><userinput>mknod -m 600 /dev/console c 5 1
  17. mknod -m 666 /dev/null c 1 3</userinput></screen>
  18. </sect2>
  19. <sect2>
  20. <title>Mounting ramfs and Populating /dev</title>
  21. <para>The recommended method of populating the <filename
  22. class="directory">/dev</filename> directory with devices is to mount a virtual
  23. filesystem (such as <systemitem class="filesystem">ramfs</systemitem> or
  24. <systemitem class="filesystem">tmpfs</systemitem>) on the <filename
  25. class="directory">/dev</filename> directory, and allow the devices to be created
  26. dynamically on that virtual filesystem as they are detected or accessed. This is
  27. generally done during the boot process. Since this new system has not been
  28. booted, it is necessary to do what the bootscripts would otherwise do by
  29. mounting <filename class="directory">/dev</filename>:</para>
  30. <screen><userinput>mount -n -t ramfs none /dev</userinput></screen>
  31. <para>The Udev package is what actually creates the devices in the <filename
  32. class="directory">/dev</filename> directory. Since it will not be installed
  33. until later on in the process, manually create the minimal set of device nodes
  34. needed to complete the building of this system:</para>
  35. <screen><userinput>mknod -m 622 /dev/console c 5 1
  36. mknod -m 666 /dev/null c 1 3
  37. mknod -m 666 /dev/zero c 1 5
  38. mknod -m 666 /dev/ptmx c 5 2
  39. mknod -m 666 /dev/tty c 5 0
  40. mknod -m 444 /dev/random c 1 8
  41. mknod -m 444 /dev/urandom c 1 9
  42. chown root:tty /dev/{console,ptmx,tty}</userinput></screen>
  43. <!-- -->
  44. <para>There are some symlinks and directories required by LFS that are
  45. not created by Udev, so create those here:</para>
  46. <screen><userinput>ln -s /proc/self/fd /dev/fd
  47. ln -s /proc/self/fd/0 /dev/stdin
  48. ln -s /proc/self/fd/1 /dev/stdout
  49. ln -s /proc/self/fd/2 /dev/stderr
  50. ln -s /proc/kcore /dev/core
  51. mkdir /dev/pts
  52. mkdir /dev/shm</userinput></screen>
  53. <para>Finally, mount the proper virtual (kernel) file systems on the
  54. newly-created directories:</para>
  55. <screen><userinput>mount -t devpts -o gid=4,mode=620 none /dev/pts
  56. mount -t tmpfs none /dev/shm</userinput></screen>
  57. <para>The <command>mount</command> commands executed above may result
  58. in the following warning message:</para>
  59. <screen><computeroutput>can't open /etc/fstab: No such file or directory.</computeroutput></screen>
  60. <para>This file&mdash;<filename>/etc/fstab</filename>&mdash;has not
  61. been created yet but is also not required for the file systems to be
  62. properly mounted. As such, the warning can be safely ignored.</para>
  63. </sect2>
  64. </sect1>