creatingdirs.xml 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <sect1 id="ch05-creatingdirs">
  2. <title>Creating directories</title>
  3. <?dbhtml filename="creatingdirs.html" dir="chapter05"?>
  4. <para>Let's now create the directory tree on the LFS partition based on
  5. the FHS standard, which can be found at
  6. <ulink url="http://www.pathname.com/fhs/"/>.
  7. Issuing the following commands will create a default directory layout:</para>
  8. <para><screen><userinput>cd $LFS &amp;&amp;
  9. mkdir -p bin boot dev/pts etc/opt home lib mnt proc root sbin tmp var opt &amp;&amp;
  10. for dirname in $LFS/usr $LFS/usr/local
  11. &nbsp;&nbsp;&nbsp;&nbsp;do
  12. &nbsp;&nbsp;&nbsp;&nbsp;mkdir $dirname
  13. &nbsp;&nbsp;&nbsp;&nbsp;cd $dirname
  14. &nbsp;&nbsp;&nbsp;&nbsp;mkdir bin etc include lib sbin share src
  15. &nbsp;&nbsp;&nbsp;&nbsp;ln -s share/man
  16. &nbsp;&nbsp;&nbsp;&nbsp;ln -s share/doc
  17. &nbsp;&nbsp;&nbsp;&nbsp;ln -s share/info
  18. &nbsp;&nbsp;&nbsp;&nbsp;cd $dirname/share
  19. &nbsp;&nbsp;&nbsp;&nbsp;mkdir dict doc info locale man nls misc terminfo zoneinfo
  20. &nbsp;&nbsp;&nbsp;&nbsp;cd $dirname/share/man
  21. &nbsp;&nbsp;&nbsp;&nbsp;mkdir man{1,2,3,4,5,6,7,8}
  22. done &amp;&amp;
  23. cd $LFS/var &amp;&amp;
  24. mkdir -p lock log mail run spool tmp opt cache lib/misc local &amp;&amp;
  25. cd $LFS/opt &amp;&amp;
  26. mkdir bin doc include info lib man &amp;&amp;
  27. cd $LFS/usr &amp;&amp;
  28. ln -s ../var/tmp</userinput></screen></para>
  29. <para>Normally, directories are created with permission mode 755, which isn't
  30. desired for all directories. The first change is a mode 0750 for the
  31. $LFS/root directory. This is to make sure that not just everybody can
  32. enter the /root directory (the same a user would do with /home/username
  33. directories). The second change is a mode 1777 for the tmp
  34. directories. This way, any user can write data to the /tmp or /var/tmp
  35. directory but cannot remove another user's files (the latter is caused
  36. by the so-called "sticky bit" - bit 1 of the 1777 bit mask).</para>
  37. <para><screen><userinput>cd $LFS &amp;&amp;
  38. chmod 0750 root &amp;&amp;
  39. chmod 1777 tmp var/tmp</userinput></screen></para>
  40. <para>Now that the directories are created, copy the source files that were
  41. downloaded in chapter 3 to some subdirectory under $LFS/usr/src (you
  42. will need to create the desired directory yourself).</para>
  43. <sect2>
  44. <title>FHS compliance notes</title>
  45. <para>The FHS stipulates that the /usr/local directory should contain the
  46. bin, games, include, lib, man, sbin, and share subdirectories. You can
  47. alter your /usr/local directory yourself if you want your system to be
  48. FHS-compliant.</para>
  49. <para>Also, the standard says that there should exist a /usr/share/games
  50. directory, which we don't much like for a base system. But feel free to
  51. make your system FHS-compliant if you wish. The FHS isn't precise as
  52. to the structure of the /usr/local/share subdirectories, so we took the
  53. liberty of creating the directories that we felt were needed.</para>
  54. </sect2>
  55. </sect1>