creatingdirs.xml 3.2 KB

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