devices.xml 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
  3. <!ENTITY % general-entities SYSTEM "../general.ent">
  4. %general-entities;
  5. ]>
  6. <sect1 id="ch-system-devices" xreflabel="devices">
  7. <title>Populating /dev</title>
  8. <?dbhtml filename="devices.html"?>
  9. <indexterm zone="ch-system-devices"><primary sortas="e-Devices">Devices</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:</para>
  15. <screen><userinput>mknod -m 600 /dev/console c 5 1
  16. mknod -m 666 /dev/null c 1 3</userinput></screen>
  17. </sect2>
  18. <sect2>
  19. <title>Mounting ramfs and populating /dev</title>
  20. <para>The ideal way to populate <filename class="directory">/dev</filename> is
  21. to mount a <systemitem class="filesystem">ramfs</systemitem> onto <filename class="directory">/dev </filename>
  22. like <systemitem class="filesystem">tmpfs</systemitem>, but it
  23. cannot be swapped) and create the devices on there during each bootup. Since we haven't
  24. booted the system, we have to do what the bootscripts would otherwise do for us, and
  25. populate <filename class="directory">/dev</filename> ourselves. Begin by mounting <filename class="directory">/dev</filename>:</para>
  26. <screen><userinput>mount -n -t ramfs none /dev</userinput></screen>
  27. <para>Since we do not have the Udev package installed yet, we'll create a
  28. minimal set of device nodes to use for building:</para>
  29. <screen><userinput>mknod -m 622 /dev/console c 5 1
  30. mknod -m 666 /dev/null c 1 3
  31. mknod -m 666 /dev/zero c 1 5
  32. mknod -m 666 /dev/ptmx c 5 2
  33. mknod -m 666 /dev/tty c 5 0
  34. mknod -m 444 /dev/random c 1 8
  35. mknod -m 444 /dev/urandom c 1 9
  36. chown root:tty /dev/{console,ptmx,tty}</userinput></screen>
  37. <para>There are some symlinks and directories required by LFS that are not created by
  38. Udev, so we create those ourselves here:</para>
  39. <screen><userinput>ln -s /proc/self/fd /dev/fd
  40. ln -s /proc/self/fd/0 /dev/stdin
  41. ln -s /proc/self/fd/1 /dev/stdout
  42. ln -s /proc/self/fd/2 /dev/stderr
  43. ln -s /proc/kcore /dev/core
  44. mkdir /dev/pts
  45. mkdir /dev/shm</userinput></screen>
  46. <para>Finally, mount the proper virtual (kernel) file systems on the directories we just
  47. created:</para>
  48. <screen><userinput>mount -t devpts -o gid=4,mode=620 none /dev/pts
  49. mount -t tmpfs none /dev/shm</userinput></screen>
  50. <para>The <command>mount</command> commands executed above may result in the
  51. following warning message:</para>
  52. <screen><computeroutput>can't open /etc/fstab: No such file or directory.</computeroutput></screen>
  53. <para>This file&mdash;<filename>/etc/fstab</filename>&mdash;has not
  54. been created yet but is also not required for the file systems to be
  55. properly mounted. As such, the warning can be safely ignored.</para>
  56. </sect2>
  57. </sect1>