devices.xml 3.3 KB

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