kernfs.xml 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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-kernfs">
  8. <?dbhtml filename="kernfs.html"?>
  9. <title>Preparing Virtual Kernel File Systems</title>
  10. <indexterm zone="ch-system-kernfs">
  11. <primary sortas="e-/dev/">/dev/*</primary>
  12. </indexterm>
  13. <para>Various file systems exported by the kernel are used to communicate to
  14. and from the kernel itself. These file systems are virtual in that no disk
  15. space is used for them. The content of the file systems resides in
  16. memory.</para>
  17. <para>Begin by creating directories onto which the file systems will be
  18. mounted:</para>
  19. <screen><userinput>mkdir -pv $LFS/{dev,proc,sys}</userinput></screen>
  20. <sect2>
  21. <title>Creating Initial Device Nodes</title>
  22. <para>When the kernel boots the system, it requires the presence of a few
  23. device nodes, in particular the <filename
  24. class="devicefile">console</filename> and <filename
  25. class="devicefile">null</filename> devices. The device nodes will be created
  26. on the hard disk so that they are available before <command>udev</command>
  27. has been started, and additionally when Linux is started in single user mode
  28. (hence the restrictive permissions on <filename
  29. class="devicefile">console</filename>). Create the devices by running the
  30. following commands:</para>
  31. <screen><userinput>mknod -m 600 $LFS/dev/console c 5 1
  32. mknod -m 666 $LFS/dev/null c 1 3</userinput></screen>
  33. </sect2>
  34. <sect2 id="ch-system-bindmount">
  35. <title>Mounting and Populating /dev</title>
  36. <para>The recommended method of populating the <filename
  37. class="directory">/dev</filename> directory with devices is to mount a
  38. virtual filesystem (such as <systemitem
  39. class="filesystem">tmpfs</systemitem>) on the <filename
  40. class="directory">/dev</filename> directory, and allow the devices to be
  41. created dynamically on that virtual filesystem as they are detected or
  42. accessed. This is generally done during the boot process by Udev. Since
  43. this new system does not yet have Udev and has not yet been booted, it is
  44. necessary to mount and populate <filename
  45. class="directory">/dev</filename> manually. This is accomplished by bind
  46. mounting the host system's <filename class="directory">/dev</filename>
  47. directory. A bind mount is a special type of mount that allows you to
  48. create a mirror of a directory or mount point to some other location. Use
  49. the following command to achieve this:</para>
  50. <screen><userinput>mount --bind /dev $LFS/dev</userinput></screen>
  51. </sect2>
  52. <sect2 id="ch-system-kernfsmount">
  53. <title>Mounting Virtual Kernel File Systems</title>
  54. <para>Now mount the remaining virtual kernel filesystems:</para>
  55. <screen><userinput>mount -vt devpts devpts $LFS/dev/pts
  56. mount -vt tmpfs shm $LFS/dev/shm
  57. mount -vt proc proc $LFS/proc
  58. mount -vt sysfs sysfs $LFS/sys</userinput></screen>
  59. </sect2>
  60. </sect1>