Creating directories
Let's now create the directory tree on the LFS partition based on
the FHS standard, which can be found at
.
Issuing the following commands will create a default directory layout:
mkdir -p /{bin,boot,dev/pts,etc/opt,home,lib,mnt,proc} &&
mkdir -p /{root,sbin,tmp,usr/local,var,opt} &&
for dirname in /usr /usr/local
do
mkdir $dirname/{bin,etc,include,lib,sbin,share,src}
ln -s share/{man,doc,info} $dirname
mkdir $dirname/share/{dict,doc,info,locale,man}
mkdir $dirname/share/{nls,misc,terminfo,zoneinfo}
mkdir $dirname/share/man/man{1,2,3,4,5,6,7,8}
done &&
mkdir /var/{lock,log,mail,run,spool} &&
mkdir -p /var/{tmp,opt,cache,lib/misc,local} &&
mkdir /opt/{bin,doc,include,info} &&
mkdir -p /opt/{lib,man/man{1,2,3,4,5,6,7,8}} &&
ln -s ../var/tmp /usr
Normally, directories are created with permission mode 755, which isn't
desired for all directories. The first change is a mode 0750 for the
/root directory. This is to make sure that not just everybody can
enter the /root directory (the same a user would do with his /home/username
directory). The second change is a mode 1777 for the tmp
directories. In this way any user can write to the /tmp and /var/tmp
directories, but cannot remove other users's files from them (the latter is prohibited
by the so-called "sticky bit" -- bit 1 in the 1777 bit mask).
chmod 0750 /root &&
chmod 1777 /tmp /var/tmp
Now that the directories are created, copy the source files that were
downloaded in chapter 3 to some subdirectory under /usr/src (you
will need to create the desired directory yourself).
FHS compliance notes
The FHS stipulates that the /usr/local directory should contain the
bin, games, include, lib, man, sbin, and share subdirectories. You can
alter your /usr/local directory yourself if you want your system to be
FHS-compliant.
Also, the standard says that there should exist a /usr/share/games
directory, which we don't much like for a base system. But feel free to
make your system FHS-compliant if you wish. The FHS isn't precise as
to the structure of the /usr/local/share subdirectories, so we took the
liberty of creating the directories that we felt were needed.