creatingdirs.xml 3.6 KB

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