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