devices.xml 3.7 KB

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