The Linux File System
◾
407
partition to be mounted remotely, www.someserver.com: /home/stuff. There may also be
special file systems that are not placed on physical devices. In Figure 10.5, we see two such
file systems, one for proc and one for tmpfs. tmpfs is the device
name for shared memory
(which is stored in memory as a ramdisk rather than hard disk; see Section 10.5 for details
on ramdisks). Another file system which might appear is devpts to communicate with
terminal windows. Not shown here is sysfs, which stores the /sys directory, used for plug-
and-play devices.
The second column in fstab is the mount point. This is the logical location in the file
system where the file system is made accessible. This will usually be at the top level of the
Linux file system, that is, a directory under /. There are some occasions where a mount
point will be placed within a subdirectory. For instance, we might find mount points under
/usr or under /home. The remotely mounted partition listed in Figure 10.5 will be mounted
under /home/coolstuff while the cdrom will be mounted under /media/cdrom.
Not all file systems have explicit mount points. The swap file system is one such example.
The consequences of not having an explicit mount point is that the file system in question
could not be mounted or unmounted using the typical mount and umount commands
(covered later in this section). We discussed swap space in Chapter 8 and will refer to it in
more detail later in this chapter.
The third column in the fstab specifies the file system’s type. These include ext, ext2,
ext3, ext4, and others. The ext file system is appropriate for either internal or removable
storage. Today, we do not see ext in use but instead most systems are based on ext2, which
is
far more efficient; ext3, which provides journaling; or ext4, which can accommodate
very large files (terabytes in size). The term
journaling
means that the file system tracks
changes so that the hard disk contents can be rolled back. Other alternatives that are often
used in a Linux operating system include NFS (the networked file system), JFS (a journal-
ing file system), umsdos (a version of MS DOS for Linux), iso9660 (used for optical disk
drives), and proc, which is a virtual file system. The idea behind a virtual file system is that
it is stored in memory instead of on a storage device. The proc
file system contains data
on all running processes. In Figure 10.5, we see the remote file system is of type nfs (net-
worked file system).
The fourth field in fstab for each file system consists of the mount options specified for
that partition. The defaults option is common and the obvious choice if you do not want
to make changes. Aside from defaults, you can specify any of a number of options. You
can specify whether the file system should be mounted at boot time or not using auto and
noauto, respectively. The option user/nouser specifies whether ordinary users can mount
the given partition (user) or whether only root can mount it (nouser). The user option is
commonly used for devices that a user should be able to mount after system initialization
takes place such as with an optical disk (cdrom) or a USB flash drive.
The exec/noexec option indicates whether binary programs can be executed from the
partition or not. You might apply noexec if you do not want users to be able to run pro-
grams stored in a particular partition. As an example, we
may want to place noexec on
the /home partition. This would prevent a user from writing a program, storing it in their
home directory, and executing it from there. Instead, any such program would have to be
408
◾
Linux with Operating System Concepts
moved to another partition, for instance, /usr. This restriction may be overly cautious if
we expect our users to write and execute their own programs. But if we do not expect that
of our users, the precaution could prevent users from downloading
executable programs
into their home directories and executing them. This is a reasonable security measure in
that we are preventing users from possibly downloading programs that are some form of
malware.
Two other options are ro versus rw (read-only, read/write) and sync/async. In the former
case, the ro option means that data files on this partition can only be read. We might use
this option if the files are all executable programs, as found in /bin and /sbin. Partitions
with data files such as /var and /home would be rw. The latter option indicates whether files
have to be accessed in a synchronized way or not. With sync,
any read or write operation
must be completed before the process moves on to the next step. This is sometimes referred
to as
blocking I/O
because the process is blocked from continuing until I/O has completed.
In asynchronous I/O, the process issues the I/O command and then continues on without
stopping.
The defaults option consists of rw, exec, auto, nouser, and async. Other options are avail-
able. The swap partition has an added option of pri
=
2000. This is known as a configura-
tion priority. When multiple partitions have a priority, mounting of those partitions is
handled based on the order of the priority (the higher the number, the higher the priority).
The final column in the fstab file is a sequence of two numbers.
This pair of values
indicates the order by which all partitions will be examined by fsck and the order that the
Do'stlaringiz bilan baham: