creatingdirs.xml 3.1 KB

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