Chapter 1
Linux Files and File Systems
|
|
|
|
|
|
In this chapter: |
|
|
|
|
Learning about different file types: regular files, directories, pipes,
named pipes, special device files, sockets, hard and soft links
|
|
Determining the type file type
|
|
Examining the structure of the ext2 file system
|
|
Understanding the File System Hierarchy
|
|
|
|
|
|
In Unix, system files are more than just names for a collection of
bits and bytes. Files are the central concept behind a variety of
functions. Files not only store information but also allow applications
to communicate, provide access to hardware devices, represent folders
of other files, act as pointers to information, or (virtually) connect
machines over a network.
To clearly understand the Unix system, you must understand the file
system. Linux, and of course SuSE Linux, inherited these features from
other Unix implementations. Understanding the file system is an
important first step for mastering the Unix system.
This chapter also contains a short introduction to the various file
types, permissions, file systems, and the File System Hierarchy. The
first section discusses general Unix file system issues such as the
different file types, permissions, and ownership issues. It also
provides an overview of the most common Linux file system types. The
second section gives an introduction to the File System
Hierarchy Standard (FHS). The FHS has been designed to give
system developers a basis for structuring the file system.
A brief description of inodes and a discussion of the basic concept of
implementing Unix filesystems are included. This discussion is not as
important as the overall structure of a file system and serves only as
brief introduction to give the reader a basic framework.
You should read this chapter if you are not familiar with these
concepts. It will give you pointers on where to look for files and
where to put files if you administer a system or if you are developing
an application. You can also find a detailed discussion of file types,
file system types,permissions, and ownerships. If you are already
experienced with the concepts behind files and file systems, you may
want to skip this chapter.
|
1.1 | Understanding File Types |
|
Files are the central concept behind Unix and Unix-like
systems. Almost everything is treated as a file: all directories, pipes
to other processes, the interface to hardware devices, even pointers
to files (links). There are even virtual files that give a user access
to kernel structures.
Whereas a file refers to a single entity, a file system describes the
way files are stored on media. The term media includes
the obvious hard or floppy disk and CD-ROMs, as well as a network
service or the RAM of your machine. Each file system type implements
different properties. Not every kind of file can reside on any file
system, and not every file system type supports every medium.
Files have properties that determine the file type. A common property
of all files is that they have a set of permissions, which is the
designation that indicates which group it belongs to and who is the
owner. Before we discuss file systems or permissions and ownerships,
let's take a closer look at the types of files.
|
1.1.1 | Regular Files |
|
Regular files are used to store data on a file system. This is the
"common sense" type of file, a container for persistent data.
|
1.1.2 | Directories |
|
Directories hold other files. Because modern file systems are
organized in hierarchies, you need something to hold the different
levels of the hierarchy. That is a directory's purpose. If you're not
used to referring to directories as files, remembering that they are
nothing other than files containing a list of other files is important.
|
1.1.3 | Special Device Files |
|
Special device files are simply interfaces to a device. Two kinds
exist: buffered device files and unbuffered device files. The buffered
special device files are called block device files; the
unbuffered ones are the character device files.
|
1.1.4 | Regular Pipes |
|
A pipe is a connection between two processes. It's treated like a file
inside the application, yet doesn't have a representation in the file
system. This type of file is interesting only if you mean to write an
application. From a user level, pipes are an easy method to use to
concatenate commands and give the output from one application as input
to another one.
|
1.1.5 | Named Pipes |
|
Named pipes are like pipes but are represented in the file
system. They are also used for interprocess communication, but they
can exist without any process accessing them.
|
1.1.6 | Sockets |
|
Sockets are similar to pipes and perform the same functions. The
difference is that sockets are used to communicate over a network. The
details are important only if you want to use sockets in your
application. Further details on sockets are beyond the scope of this
book. You can find excellent sources that explain the concept in
greater depth.
|
1.1.7 | Hard Links |
|
A hard link is a sequential entry in a directory structure for an
existing file. It's like a new name for a file.
|
1.1.8 | Soft Links |
|
A soft link is a pointer to a file. We'll discuss the difference
between hard and soft links later on in this chapter.
Executables are not a separate file type and are therefore not
included in this list. In Unix systems, being executable or not is a
property determined by the file permissions and does not depend on the
type of file. Remember that some files can be executed only by
designated users or user groups.
|
1.2 | Determining the File Type |
|
The main interface to the file system is the ls
command. Details on this command can be found in the man pages. If you
run ls -l in any directory, you receive a nine-column
listing of the files in that directory. Let's focus on the first column
as an example. The first column holds information about the files'
type and permissions. The first character indicates the type of
information and the remaining nine characters determine the
permissions. Some implementations of ls mark files by using different
colors. This use of color is convenient but not standard (they often
distinguish files by extensions, too).
Example:
|
| > ls -l
total 104
drwxr-xr-x 2 bb users 1024 Nov 1 17:20 Build/
-rw-r--r-- 1 bb users 32120 Nov 20 19:57 Duke
drwxr-xr-x 2 bb users 1024 Nov 1 16:49 Mail/
drwxr-xr-x 2 bb users 1024 Nov 23 23:00 SuSE-Book/
drwxr-xr-x 2 bb users 1024 Nov 19 20:01 bin/
drwxr-xr-x 8 bb users 1024 Oct 27 20:41 public_html/
-rw-r--r-- 1 bb users 190 Nov 8 23:33 quote
drwxr-xr-x 2 bb users 1024 Nov 1 13:52 tmp/
|
|
|
1.2.1 | Regular Files and Directories |
|
The preceding is the listing of a typical user home directory. You see
that the character d marks directories, whereas a single
dash (-) marks regular files.
One interesting feature is worth mentioning at this point. The second
column tells you how many hard links (or names) refer to each file. As
you can see, the hard link count is one for the regular files but is
at least two for the directories. Why is that? Well, a directory has a
name in the directory where it is contained, and has a reference to
itself (.). That makes two. If a directory has subdirectories, all of
these also have a reference to this directory. Take public_html as an
example. The d is the first letter in the first row, which tells you
that it's a directory, and the fact that it has eight references
indicates that it has six subdirectories:
|
| > ls -l public_html/
total 14
drwxr-xr-x 6 bb users 1024 Nov 19 20:53 Gallery/
drwxr-xr-x 2 bb users 1024 Oct 27 20:41 Info/
drwxr-xr-x 2 bb users 1024 Oct 27 20:41 Pilot/
drwxr-xr-x 2 bb users 1024 Oct 13 22:50 Private/
-rw-r--r-- 1 bb users 577 Oct 3 19:07 docs.html
drwxr-xr-x 2 bb users 1024 Oct 3 16:20 fw-howto/
-rw-r--r-- 1 bb users 996 Oct 6 06:40 gallery.html
drwxr-xr-x 2 bb users 2048 Nov 19 20:55 gif/
-rw-r--r-- 1 bb users 1319 Oct 3 16:07 index.html
-rw-r--r-- 1 bb users 1508 Oct 26 17:40 index1.html
-rw-r--r-- 1 bb users 500 Oct 3 19:09 links.html
|
|
As you can see, there is no special mark for hard links. You know
there is another reference to this file if the link count is greater
than one. You learn more about hard links a little bit later on in this
chapter.
Directories are files that contain information about other files. They
translate names into inodes. An inode is the file system, or the
internal representation of a storage structure.
|
1.2.2 | Device Special Files |
|
That's enough about directories for now. Look through the following
code to see what other kinds of files you can find.
|
| > ls -l /dev
[...]
brw-rw---- 1 root disk 3, 0 Jul 26 12:45 /dev/hda
brw-rw---- 1 root disk 3, 1 Jul 26 12:45 /dev/hda1
brw-rw---- 1 root disk 3, 2 Jul 26 12:45 /dev/hda2
brw-rw---- 1 root disk 3, 3 Jul 26 12:45 /dev/hda3
brw-rw---- 1 root disk 3, 4 Jul 26 12:45 /dev/hda4
brw-rw---- 1 root disk 3, 5 Jul 26 12:45 /dev/hda5
brw-rw---- 1 root disk 3, 6 Jul 26 12:45 /dev/hda6
brw-rw---- 1 root disk 3, 7 Jul 26 12:45 /dev/hda7
brw-rw---- 1 root disk 3, 8 Jul 26 12:45 /dev/hda8
brw-rw---- 1 root disk 3, 9 Jul 26 12:45 /dev/hda9
crwx-w---- 1 bb tty 4, 1 Nov 23 23:19 /dev/tty1
crw-rw---- 1 root tty 4, 11 Jul 26 12:45 /dev/tty11
[...]
|
|
If you list the /dev directory, you'll find many special
device files. They are marked with a b for block, or
buffered devices, or with a c for character, or
unbuffered devices. As previously mentioned, special device files
represent interfaces to device drivers. Beware of the fact
that accessing one of those files means accessing some kind of device
and not the actual file system. Of course, accessing a device means to
retrieve or store data somewhere, but it is completely different from
accessing a regular file.
What happens if you access such a file -- which device do you access,
and how are the file and device connected? You may have noticed that
the column that usually tells you about the size of the file has been
split up into two columns. This is where the connection between file
and device is made. The naming may seem arbitrary, yet conventions to
name special device files do exist.
The two numbers are called major and
minor device numbers. You can think of these numbers
as parameters passed to the kernel as you access the file. The major
device number (the first one)selects the device driver, and the minor
device number (the second one) is passed to that driver to allow
further selection.
Now for a closer look at the /dev/hda files. You can tell
they are block device files by the preface b. All of them
have the same major device number 3, and all have different minor
device numbers. The /dev/hda files represent the first
IDE hard drive in the system (Hard Drive A). The driver responsible for
this drive registers with number 3 in the kernel. The minor device
number decides which partition of this drive you reference to. Zero
means the whole drive; one, partition number one; two, partition
number two, and so on.
|
|
You can find a list of all important major and minor device
numbers, and the referencing naming conventions, in Appendix A
.
If you have the Linux kernel sources installed, this list can also be
found in the file devices.txt in the directory
/usr/src/linux/Documentation. Because the names and numbers change
slightly with kernel versions (that is, if new hardware types are
supported), checking this file first, if it's available, may be a good idea.
|
|
|
1.2.3 | Named Pipes |
|
Pipes are closely related to device special files. Like device special
files, pipes don't refer to actual data stored in the file system. A
pipe is used as a way to communicate between two processes. These
processes can be threads of the same application, or two different
applications in which the output of one application is piped as input
to the other application. You can think of a named pipe as a regular
pipe with a representation in the file system.
Whereas regular pipes are temporary and exist only as long as the
processes that use the pipe exist, named pipes are more permanent
fixtures.
If you think of a pipe as a jet stream of water, then a named pipe is
like a hose. You can create a named pipe, fill it with data from one
application, and read the data out of the named pipe with another
application at the same time or later. The buffer capacity is not
great. Remember, it's a hose, not a bucket (which, in this analogy,
would be a regular file). Another name for named pipes is
FIFO, which stands for First In First Out.
Named pipes are marked by a p in the ls -l output:
|
| > ls -l /dev/initctl
prw------- 1 root root 0 Dec 31 1989 /dev/initctl|
|
|
|
1.2.4 | Hard and Soft Links |
|
Now that we've reviewed regular files, directories, device special
files, and named pipes, we'll examine one last group that makes the
list complete: links.
Links are used to provide more than one reference to a file. We
examined this concept in the section on directories. Recall that a
directory is no more than a special kind of file. Directories are
linked together when hard links are created from the children to the
parents. These hard links have special names and are created on the
fly when a directory is created: . points to the
directory itself, and .. points to the parent
directory. It's commonly thought that . and
.. are special characters that are treated in a special
way. In truth, they are nothing other than hard links to directories.
Of course, hard links can point to regular files. A hard link is just
a new entry in the directory file that points to the same inode as
another entry. No way exists to distinguish between hard links and the
files they point to. There is no original and copy. Recall that the
hard link counter (the number given) tells the system when the actual
data can be removed from the storage medium. Every time you delete a
reference to a file, the hard link count is decreased. The data will
be removed when the counter reaches zero. Makes sense, doesn't it?
There is one problem with hard links: they can point only to files
within the same file system. We discuss file systems later on in this
chapter, at which point you'll see why this is a hard limit to live
with. The way around this limitation is to use soft links. Soft links
are like hard links; they point to files. The difference is that soft
links are files themselves. The only data they contain is a pointer to
the filename they refer to. Refer to the /dev directory
for an example:
|
| > ls -l /dev/modem
lrwxrwxrwx 1 root root 9 Oct 3 18:09 /dev/modem -> /dev/cua1
|
|
You see that /dev/modem is a pointer to
/dev/cua1, the second serial port in the
system. Because soft links don't make use of internal file system
structures as hard links do, there is no problem having them point to
other file systems, or even to different file system types. A soft
link stores only the name of the file and holds no information about
where it's stored or anything else. This also means that soft links can
point to nothing. Imagine, for example, that you remove /dev/cua1.
The link will still exist, but it will be of no use.
|
|
Soft links can be relative or absolute. A relative soft link contains
a path to the target file, which is relative to the location of the
link itself. An absolute soft link contains the path beginning with the
root directory.
|
|
Following is an absolute soft link:
|
| > ls -l /var/X11R6/bin/
lrwxrwxrwx 1 root root 24 Dec 4 16:38 X -> /usr/X11R6/bin/XF86_SVGA
|
|
And here is a relative link:
|
| > ls -l /usr/spool
lrwxrwxrwx 1 root root 12 Dec 17 21:21 /usr/spool -> ../var/spool
|
|
Both types have their advantages and pitfalls. Relative links are
useful when you want to move entire file trees around. As long as the
internal structure stays the same, the soft links inside this tree
will still work. Absolute links are useful if the link itself is
likely to be moved. Because it contains the absolute path to the
referenced file, the position of the link itself is not important.
|
1.3 | Creating Files |
|
Now that you know about the various file types, you're probably
interested in learning how to create them. As with most things in the
Unix world, no one way exists to accomplish this. You can create every
type of file in many different ways. Every programming language
provides different ways of integrating file access. It may be better if
we leave it to the manuals of these languages to explain how they
handle files. We'll provide a short overview of the shell commands
that can be used to do this on the command line.
The easiest way to create a regular file is as follows:
|
| > touch filename
|
|
The touch command creates the file if it doesn't exist already. If it
does, it sets the access and modification time to the actual time and
date. Touch has some more functions, which are explained in touch(1).
Directories are created with:
|
| > mkdir directory
|
|
There's not much to say about this command. It creates the directory
itself, and the . and .. links in this
directory as explained in the previous section.
The command mknod is used to create device specific files
and named pipes. Device specific files need a major and minor device
number and the type -- block or character -- of the new file.
|
| > mknod /dev/cua1 c 5 65
|
|
creates a character special file with major device number 5 and minor
device number 65.
|
| > mknod /dev/hda10 b 3 10
|
|
creates a block special device file with minor device number 3 and
major device number 10.
|
| > mknod /dev/initctl p
|
|
creates a named pipe.
The man page mknod(1) explains a few more parameters. We
advise you to have a look at it when you are creating these kinds of
files.
Links are created by the command ln.
|
| > ln -s /dev/cua1 /dev/modem
|
|
creates the soft link /dev/modem, which points to /dev/cua1.
|
| > ln file1 file2
|
|
creates the name file2 for file1.
|
|
Some people get confused by the order of the arguments given to
ln. Think of ln in the same way as cp. The
first argument is the source and the second is the target name.
|
|
|
1.4 | Understanding File Systems |
|
Now that we've reviewed the basics, single files, it's time to take
this review to another level -- file systems. We've used the term file
system quite frequently up to now without a working definition. Because
file system has two different meanings, it can become quite
confusing. When we talk about file systems, we usually think of
directory trees. This is a hierarchical structure of directories that
contain other directories and/or any kind of file.
|
|
The second meaning of file systems is the lower-level format, used on
a given media to store files. You probably never think of this meaning
because it's natural to store a file somewhere, and most of the time
how files are stored is of less interest.
|
|
Alternatives to File Systems Storing data to media can be done in many
ways. The simplest one is to dump the raw data to the medium. This
works fine but makes accessing the data inconvenient. You lack meta
information such as size, type, or identifier. Matters are complicated
if you want to store a second set of data to this medium. You have to
remember the offset (where the first set ends), or you risk
overwriting, which means losing data.
This meta information can be supplied by special applications or made
transparent for the user by a file system. It's important to remember
that using a file system is not always the best way. For example,
using floppy disks as a raw storage medium without any file system is
common practice. Because floppies are usually used to exchange or
archive data, you don't need a file system. Just tar the files to
floppy:
|
| > tar cvzf /dev/fd0 public_html/Info/
public_html/Info/
public_html/Info/index.html
public_html/Info/bbatwork.jpg
public_html/Info/resumee.html
|
|
tar creates all the meta information needed to list the
files and to restore them to another (or the same) location.
This seems inconvenient at first, but it has some advantages. File
Systems are dependent on the OS that you use. If you want to exchange
data with other systems, make sure to use a file system type that is
supported by all systems that would access the data or use an
application to write the data that is available on those systems. The
DOS FAT16 file system is common and is a good candidate for data
exchange on floppy disks. Programs such as tar or
cpio are available for almost every system.
Another problem with most file system types is that they need random
access to the storage medium. Although this access is no problem with
hard disks, floppies, or any kind of RAM, it's not available on most
tape drives. Again, tar and cpio are good
choices to store data on those medias.
|
1.4.1 | The ext2 File System |
|
File systems organize files into logical hierarchical structures with
directories, links, and so on. With kernel version 2.2, the Linux
system supports twenty-one different file system types: minix, ext2,
iso9660, msdos, umsdos, vfat, proc, nfs, smb, ncp, hpfs, sysv, adfs,
amiga-fs, ROM-fs,NTFS, joilet, Apple Macintosh fs, QNX fs, Coda, and
ufs.
A file system organizes the data on a block device. This can be a hard
disk, a floppy disk, RAM, a flash RAM cartridge, or even a network link
to a remote system. The file system itself doesn't know anything about
the medium it uses. This is handled by the device driver. It's the job
of the device driver to translate the address of a specific block to a
physical position on a hard drive, a memory region, and so on.
The de facto standard file system on Linux systems is Extended 2 File
System (ext2). It was designed by Remy Card as a successor to the
Extended File System ext (also by Remy Card), which was dropped with
the 2.2 kernel release.
The first file system for Linux was the Minix file system
(Minixfs). It had many disadvantages. Partitions were limited to 64MB,
filenames to 14 characters. The extended file system, introduced to
the Linux world in April 1992, was mostly based on the Minixfs; it
removed the previously mentioned limits, but still was far from the
perfect file system Remy had in mind. He therefore decided to write a
completely new file system, ext2. It added better space allocation
management to extfs, exhibited better performance, allowed the use of
special flags for file management, and was extensible. It's been
available since 1993 and is the most successful Linux file system to
date.
When the extfs was added to the Linux kernel, a new layer entered the
system, the so-called Virtual File System (VFS)
layer. With this layer, the file system and the kernel were no longer
one unit. A well-defined interface between kernel and file system was
created. VFS allows Linux to support many different file systems. All
file systems appear identical to the kernel and to the programs
running on the system. The VFS layer allows you to transparently mount
different file systems at a time. Figure 1-1
shows the relation
between the kernels VFS and the real filesystems.
|
Figure 1-1 |
|
| Schema of the Virtual File System |
|
|
1.4.2 | How the ext2 File System Works |
|
In this section, we return to the ext2 file system and review its
structure.
The ext2 file system is built on the premise that data is held in
blocks of equal size on the storage medium. The block size can vary on
different ext2 file systems, but within one file system, all blocks
have the same length. The length is set when the file system is
created by mke2fs. This strategy's disadvantage is that on average,
half the block size is wasted for each file. Assuming that the block
size is 1024 bytes, a file with 1025 bytes will use two blocks, just
as a file with 2047 will. By handling the files this way, you reduce
the CPU's workload.
Not all blocks on the file system hold actual file data. Some are used
to hold information about the structure of the file system. Ext2 uses
inode data structures for each file stored in the file system. An inode
describes which blocks contain the data of the specified file, its
type, owner, and group, the permissions and the date of the last
access, the last modification, and its creation date. The inodes are
held in inode tables. A directory is simply a file that contains
pointers to the inodes of the files within this directory.
Figure 1-2
shows the format of an ext2 inode. You can see four
fields at the beginning of the structure. The first field is for the
mode (permission); the second holds the owner and group information;
the third shows the size of the system in bytes; and the fourth shows
the three timestamps. Following these fields are pointers to the data
blocks of the file. There are 12 direct pointers and 3 indirect
pointers with an indirection level of one, two, and three.
|
Figure 1-2 |
|
| Ext2 Inode Structure |
|
The direct pointers point directly to data blocks. The single indirect
refers to blocks of pointers that point to data or, in case of level
two and three, again to pointer blocks. This means that smaller files
are more quickly accessed than larger files because fewer pointers
have to be dereferenced.
The other important structure of the ext2 file system is the super
block. It contains information on the basic shape and size of the file
system. It's read at the time the file system is mounted. The super
block is located in block group zero, but a copy of the superblock is
stored in each block group of the file system. These redundant copies
make restoring the file system possible incase the first superblock is
corrupted.
|
|
A detailed description of the whole ext2 file system can be found in
David A Rusling's book The Linux Kernel, in Chapter 9, "The File
System," available online at
http://sunsite.unc.edu/LDP/LDP/tlk/tlk.html.
|
|
|
1.5 | Exploring the File System Hierarchy |
|
Now that we've had a look at the internals of the ext2 file system,
it's time to talk about how it's used in the system. In Linux, as in
all Unix-type systems, separate file systems are not accessed by
device identifiers such as drive names or volume identifiers. You'll
find a single hierarchical structure. Separate file systems are
mounted into this hierarchy no matter the type of storage
medium. Separate file systems are mounted into the existing hierarchy
to mount points. A mount point is nothing more than a directory in the
existing tree. If the directory already contains something, this
information will be overlaid (and not accessible) when a file system
is mounted to this directory. It'll be visible again when the
overlaying tree is unmounted:
|
| # touch /mnt/This-Directory-is-not-empty
# ls /mnt/
. This-Directory-is-not-empty
..
# mount -oro /dev/cdrom /mnt
# ls /mnt/
. TRANS.TBL
.. full-names
.S.u.S.E-disk-002.1998111916 suse
# umount /mnt/
ls /mnt/
. This-Directory-is-not-empty
..
|
|
The master mount point is /. This is where the root file
system is mounted. The root file system is the only one required;
other file systems are optional. However, having this file system on
aprivate workstation, on which there are good reasons to split up the
directory tree into several file systems for different kinds of
systems, is okay.
|
1.5.1 | Mount Points |
|
The layout of the directory tree is not arbitrary. The overall
structure of the directory layout is defined in the File System
Hierarchy Standard. If you look in the root of a SuSE Linux 6.0
system, you'll see the following directories:
|
| boot etc lost+found proc tmp cdrom opt
home mnt root usr bin dev lib
sbin var
|
|
The root file system has to contain everything needed to boot the
system to the point where additional file systems can be
mounted. Another criterion is that you want to have all utilities
needed to repair other file systems on the root file system.
|
|
You can learn more about the File System Hierarchy Standard in Chapter 2
.
|
|
For SuSE Linux systems, these are the directories:
|
| etc root bin lib sbin dev
|
|
This means you should never use these five directories as mount points
for other file systems. You will get a system that is not able to
boot.
|
|
Although severe consequences can ensue if you incorrectly split up
the hierarchy, you may save yourself trouble in other areas if you know
how to do it wisely.
|
|
Parts of the directory tree have certain properties that make them
good candidates for mount points. The data in these parts can be
shareable or unshareable and can be static or variable. Table 1-1
shows a matrix that sorts the major subdirectories into these
categories.
|
Table 1-1 |
Classification of file systems |
|
|
shareable |
unshareable |
static |
/usr |
/etc |
|
/opt |
/boot |
variable |
/var/mail |
/var/run |
|
/var/spool/news |
/var/lock |
|
/home |
/tmp |
|
|
Shareable data can be mounted over the network on several systems at a
time. This minimizes system administration and saves disk space on the
client machines. Unshareable data has to be local. If it is variable,
it's a good idea to have it on the separate file system to protect the
rest of the tree in case of overruns. Splitting the variable data into
separate file systems decreases the likelihood that the system will
crash when one file system runs out of free space.
Another argument for having different file systems is the average file
size. We have seen that, depending on the block size, there may be a
lot of wasted space in the file system if you have a huge block size
and lots of small files. Files in the spool directories for mail and
news are usually rather small, so you may want to create file systems
with smaller block sizes, such as 1024 or 2048 bytes rather than the
default size of 4096 bytes for these directories.
|
|
You should consider potential problems when you update or reinstall
the system. The /home and the /usr/local
hierarchies are intended to be independent of the rest of the
system. It's a good idea to keep them separate by putting these file
systems by themselves.
|
|
This leads us to the list of possible mount points shown in Table
1-2
. The sizes shown are taken from the standard configurations
offered by YaST in SuSE Linux 6.1.
|
Table 1-2 |
File system size |
|
Mount point |
Minimum |
Default |
Network |
Development |
Everything |
/ |
29,791 |
32,675 |
39,365 |
33,039 |
39,457 |
/usr |
50,787 |
434,792 |
684,468 |
442,996 |
3,774,819 |
/usr/local |
16 |
856 |
856 |
856 |
9,942 |
/usr/local/ftp |
3 |
1 |
1,218 |
1 |
1,218 |
/usr/local/http |
- |
2,830 |
2,846 |
2,829 |
3,896 |
/opt |
2 |
308,478 |
71,570 |
8,130 |
1,038,502 |
/boot |
880 |
880 |
880 |
880 |
900 |
/tmp |
1 |
1 |
1 |
1 |
1,550 |
/home |
1 |
1 |
1 |
1 |
1 |
/var |
1,868 |
1,547 |
18,664 |
1,4740 |
81,466 |
/var/spool |
8 |
15 |
660 |
15 |
760 |
/var/spool/mail |
1 |
1 |
1 |
1 |
1 |
/var/spool/news |
- |
9 |
9 |
9 |
9 |
/var/log |
2 |
2 |
2 |
2 |
2 |
/var/tmp |
2 |
2 |
2 |
2 |
2 |
Total |
83,330 |
778,374 |
814,949 |
577,787 |
4,952,535 |
|
|
Determining which separation makes sense for the system you install is
an individual decision. The megabyte values shown in Table 1-2
should give you an idea of how big the partition, which holds
the file system, has to be. Some parts of the file system get filled
up during the runtime of the system, and some are dependent on what
you are going to do with it. To use an FTP server as an example, you
might want to create a huge partition for /usr/local/ftp. If you set
up a mail server, the size of /var/spool/mail decides how much mail
your users can hold in their incoming folders.
There is no general advice for the structure and size of the file
systems you use in your installation. The information in this chapter
should give you an idea of how to design your system for the task you
have in mind for it.
|
1.5.2 | The /proc File System |
|
One part of the standard file system that deserves to be explained in
more detail is the tree beginning with /proc. This file
system is becoming the de facto method for Linux to handle process and
system information. It is a nice example of the power of Linux's
Virtual File System, a file system that does not really exist, either
in the /proc directory or in its subdirectories. The
content of files in the /proc is generated by the kernel
at the moment a user reads them, representing information about
running processes and kernel internals. Some files are writable, which
allows the possibility of changing kernel parameters during runtime.
|
|
A detailed discussion of the contents of /proc can
be found in Chapters 3
and 4
.
|
|
|
|
Summary: |
|
Files are the central concept you must understand to interact with
Unix systems. These are not only used as containers for data but also
act as the main interface for communication between applications and
kernel.
A file's type can be determined using the ls -l command,
where the first letter tells you the kind of file you are looking at.
Files are organized in file systems. The term file system has two
meanings. In some instances,it's used to determine a file system
hierarchy; in other cases, it is used for the type of storage
structure that is used to make files and their contents persistent in
the system.
The most common file system on Linux machines is the ext2 file
system. It's efficient and reliable, and it offers features such as
long filenames and different levels of file permissions. It also
assigns users and groups to files. The file system hierarchy is
standardized in the FHS, the File System Hierarchy Standard. This
standard defines which file system trees hold which kind of data.
|
|