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