1 | <sect1 id="ch04-creatingdirs">
|
---|
2 | <title>Creating directories</title>
|
---|
3 |
|
---|
4 | <para>
|
---|
5 | Let's create the directory tree on the LFS partition based on the FHS
|
---|
6 | standard, which can be found at <ulink
|
---|
7 | url="http://www.pathname.com/fhs/">http://www.pathname.com/fhs/</ulink>.
|
---|
8 | Issuing the following commands will create a default directory layout:
|
---|
9 | </para>
|
---|
10 |
|
---|
11 | <para>
|
---|
12 | <screen>
|
---|
13 | <userinput>cd $LFS</userinput>
|
---|
14 | <userinput>mkdir -p bin boot dev/pts etc/opt home lib mnt proc root sbin tmp var opt</userinput>
|
---|
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 src var</userinput>
|
---|
20 | <userinput> ln -s share/man man</userinput>
|
---|
21 | <userinput> ln -s share/doc doc</userinput>
|
---|
22 | <userinput> ln -s share/info info</userinput>
|
---|
23 | <userinput> cd $dirname/share</userinput>
|
---|
24 | <userinput> mkdir dict doc info locale man nls misc terminfo zoneinfo</userinput>
|
---|
25 | <userinput> cd $dirname/share/man</userinput>
|
---|
26 | <userinput> 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 local</userinput>
|
---|
30 | <userinput>cd $LFS/opt</userinput>
|
---|
31 | <userinput>mkdir bin doc include info lib man</userinput>
|
---|
32 | <userinput>cd $LFS/usr</userinput>
|
---|
33 | <userinput>ln -s ../var/tmp tmp</userinput>
|
---|
34 | </screen></para>
|
---|
35 |
|
---|
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 |
|
---|
47 | <para>
|
---|
48 | <screen>
|
---|
49 | <userinput>cd $LFS &&</userinput>
|
---|
50 | <userinput>chmod 0750 root &&</userinput>
|
---|
51 | <userinput>chmod 1777 tmp var/tmp</userinput>
|
---|
52 | </screen>
|
---|
53 | </para>
|
---|
54 |
|
---|
55 | <para>
|
---|
56 | Now that the directories are created, copy the source files that were
|
---|
57 | downloaded in chapter 3 to some subdirectory under $LFS/usr/src (you
|
---|
58 | will need to create the desired directory yourself).
|
---|
59 | </para>
|
---|
60 |
|
---|
61 | <sect2>
|
---|
62 | <title>FHS compliance notes</title>
|
---|
63 |
|
---|
64 | <para>
|
---|
65 | The FHS stipulates that the /usr/local directory should contain the bin, games,
|
---|
66 | include, lib, man, sbin, and share subdirectories. You can alter your /usr/local
|
---|
67 | directory yourself if you want your system to be FHS-compliant.
|
---|
68 | </para>
|
---|
69 |
|
---|
70 | <para>
|
---|
71 | Also, the standard says that there should exist a /usr/share/games directory,
|
---|
72 | which we don't much like for a base system. But feel free to make your system
|
---|
73 | FHS-compliant if you wish. The FHS isn't precise as to the structure of the
|
---|
74 | /usr/local/share subdirectories, so we took the liberty of creating the
|
---|
75 | directories that we felt needed.
|
---|
76 | </para>
|
---|
77 |
|
---|
78 | </sect2>
|
---|
79 |
|
---|
80 | </sect1>
|
---|
81 |
|
---|