devices.xml 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. The device nodes will
  15. be created on the hard disk so that they are available before
  16. <command>udev</command> has been started, and additionally when Linux is started
  17. in single user mode (hence the restrictive permissions on
  18. <filename class="devicefile">console</filename>). Create the devices by running
  19. the following commands:</para>
  20. <screen><userinput>mknod -m 600 /dev/console c 5 1
  21. mknod -m 666 /dev/null c 1 3</userinput></screen>
  22. </sect2>
  23. <sect2>
  24. <title>Mounting tmpfs and Populating /dev</title>
  25. <para>The recommended method of populating the <filename
  26. class="directory">/dev</filename> directory with devices is to mount a virtual
  27. filesystem (such as <systemitem class="filesystem">tmpfs</systemitem>) on the
  28. <filename class="directory">/dev</filename> directory, and allow the devices to
  29. be created dynamically on that virtual filesystem as they are detected or
  30. accessed. This is generally done during the boot process. Since this new system
  31. has not been booted, it is necessary to do what the LFS-Bootscripts package would
  32. otherwise do by mounting <filename class="directory">/dev</filename>:</para>
  33. <screen><userinput>mount -nvt tmpfs none /dev</userinput></screen>
  34. <para>The Udev package is what actually creates the devices in the <filename
  35. class="directory">/dev</filename> directory. Since it will not be installed
  36. until later on in the process, manually create the minimal set of device nodes
  37. needed to complete the building of this system:</para>
  38. <screen><userinput>mknod -m 622 /dev/console c 5 1
  39. mknod -m 666 /dev/null c 1 3
  40. mknod -m 666 /dev/zero c 1 5
  41. mknod -m 666 /dev/ptmx c 5 2
  42. mknod -m 666 /dev/tty c 5 0
  43. mknod -m 444 /dev/random c 1 8
  44. mknod -m 444 /dev/urandom c 1 9
  45. chown -v root:tty /dev/{console,ptmx,tty}</userinput></screen>
  46. <para>There are some symlinks and directories required by LFS that are created
  47. during system startup by the LFS-Bootscripts package. Since this is a chroot
  48. environment and not a booted environment, those symlinks and directories need to
  49. be created here:</para>
  50. <screen><userinput>ln -sv /proc/self/fd /dev/fd
  51. ln -sv /proc/self/fd/0 /dev/stdin
  52. ln -sv /proc/self/fd/1 /dev/stdout
  53. ln -sv /proc/self/fd/2 /dev/stderr
  54. ln -sv /proc/kcore /dev/core
  55. mkdir -v /dev/pts
  56. mkdir -v /dev/shm</userinput></screen>
  57. <para>Finally, mount the proper virtual (kernel) file systems on the
  58. newly-created directories:</para>
  59. <screen><userinput>mount -vt devpts -o gid=4,mode=620 none /dev/pts
  60. mount -vt tmpfs none /dev/shm</userinput></screen>
  61. <para>The <command>mount</command> commands executed above may result
  62. in the following warning message:</para>
  63. <screen><computeroutput>can't open /etc/fstab: No such file or directory.</computeroutput></screen>
  64. <para>This file&mdash;<filename>/etc/fstab</filename>&mdash;has not
  65. been created yet but is also not required for the file systems to be
  66. properly mounted. As such, the warning can be safely ignored.</para>
  67. </sect2>
  68. </sect1>