Chapter 2. File System Structure and Maintenance
- Shareable and unsharable files
- Shareable files can be accessed locally and by remote hosts. Unsharable files are only available locally.
- Variable and static files
- Variable files, such as documents, can be changed at any time. Static files, such as binaries, do not change without an action from the system administrator.
2.1. Overview of Filesystem Hierarchy Standard (FHS)
- Compatibility with other FHS-compliant systems
- The ability to mount a
/usr/partition as read-only. This is crucial, since
/usr/contains common executables and should not be changed by users. In addition, since
/usr/is mounted as read-only, it should be mountable from the CD-ROM drive or from another machine via a read-only NFS mount.
2.1.1. FHS Organization
188.8.131.52. Gathering File System Information
dfcommand reports the system's disk space usage. Its output looks similar to the following:
df Command Output
Filesystem 1K-blocks Used Available Use% Mounted on /dev/mapper/VolGroup00-LogVol00 11675568 6272120 4810348 57% / /dev/sda1 100691 9281 86211 10% /boot none 322856 0 322856 0% /dev/shm
dfshows the partition size in 1 kilobyte blocks and the amount of used and available disk space in kilobytes. To view the information in megabytes and gigabytes, use the command
df -h. The
-hargument stands for "human-readable" format. The output for
df -hlooks similar to the following:
df -h Command Output
Filesystem Size Used Avail Use% Mounted on /dev/mapper/VolGroup00-LogVol00 12G 6.0G 4.6G 57% / /dev/sda1 99M 9.1M 85M 10% /boot none 316M 0 316M 0% /dev/shm
/dev/shmrepresents the system's virtual memory file system.
ducommand displays the estimated amount of space being used by files in a directory, displaying the disk usage of each subdirectory. The last line in the output of
dushows the total disk usage of the directory. To see only the total disk usage of a directory in human-readable format, use
du -hs. For more options, see
Gnome System Monitor
gnome-system-monitor. Select the File Systems tab to view the system's partitions. The following figure illustrates the File Systems tab.
Figure 2.1. File Systems Tab in GNOME System Monitor
/boot/directory contains static files required to boot the system, for example, the Linux kernel. These files are essential for the system to boot properly.
/boot/directory. Doing so renders the system unbootable.
/dev/directory contains device nodes that represent the following device types:
- devices attached to the system;
- virtual devices provided by the kernel.
udevddaemon creates and removes device nodes in
/dev/directory and subdirectories are defined as either character (providing only a serial stream of input and output, for example, mouse or keyboard) or block (accessible randomly, such as a hard drive or a floppy drive). If GNOME or KDE is installed, some storage devices are automatically detected when connected (such as with USB) or inserted (such as a CD or DVD drive), and a pop-up window displaying the contents appears.
Table 2.1. Examples of Common Files in the
| ||The master device on the primary IDE channel.|
| ||The slave device on the primary IDE channel.|
| ||The first virtual console.|
| ||The second virtual console.|
| ||The first device on the primary SCSI or SATA channel.|
| ||The first parallel port.|
- Mapped device
- A logical volume in a volume group, for example,
- Static device
- A traditional storage volume, for example,
/dev/sdbX, where sdb is a storage device name and X is the partition number.
/dev/sdbXcan also be
/dev/disk/by-uuid/UUID. For more information, see Section 25.8, “Persistent Naming”.
/etc/directory is reserved for configuration files that are local to the machine. It should not contain any binaries; if there are any binaries, move them to
/etc/skel/directory stores "skeleton" user files, which are used to populate a home directory when a user is first created. Applications also store their configuration files in this directory and may reference them when executed. The
/etc/exportsfile controls which file systems export to remote hosts.
/mnt/directory is reserved for temporarily mounted file systems, such as NFS file system mounts. For all removable storage media, use the
/media/directory. Automatically detected removable media is mounted in the
/mntdirectory must not be used by installation programs.
/opt/directory is normally reserved for software and add-on packages that are not part of the default installation. A package that installs to
/opt/creates a directory bearing its name, for example,
/opt/packagename/. In most cases, such packages follow a predictable subdirectory structure; most store their binaries in
/proc/directory contains special files that either extract information from the kernel or send information to it. Examples of such information include system memory, CPU information, and hardware configuration. For more information about
/proc/, see Section 2.3, “The /proc Virtual File System”.
/srv/directory contains site-specific data served by a Red Hat Enterprise Linux system. This directory gives users the location of data files for a particular service, such as FTP, WWW, or CVS. Data that only pertains to a specific user should go in the
/sys/directory utilizes the new
sysfsvirtual file system specific to the kernel. With the increased support for hot plug hardware devices in the kernel, the
/sys/directory contains information similar to that held by
/proc/, but displays a hierarchical view of device information specific to hot plug devices.
/usr/directory is for files that can be shared across multiple machines. The
/usr/directory is often on its own partition and is mounted read-only. At a minimum,
/usr/should contain the following subdirectories:
- This directory is used for binaries.
- This directory is used for system-wide configuration files.
- This directory stores games.
- This directory is used for C header files.
- This directory is used for Kerberos-related binaries and files.
- This directory is used for object files and libraries that are not designed to be directly utilized by shell scripts or users.As of Red Hat Enterprise Linux 7.0, the
/lib/directory has been merged with
/usr/lib. Now it also contains libraries needed to execute the binaries in
/usr/sbin/. These shared library images are used to boot the system or execute commands within the root file system.
- This directory contains small helper programs called by other programs.
- As of Red Hat Enterprise Linux 7.0,
/sbinhas been moved to
/usr/sbin. This means that it contains all system administration binaries, including those essential for booting, restoring, recovering, or repairing the system. The binaries in
/usr/sbin/require root privileges to use.
- This directory stores files that are not architecture-specific.
- This directory stores source code.
- This directory stores temporary files.
/usr/directory should also contain a
/local/subdirectory. As per the FHS, this subdirectory is used by the system administrator when installing software locally, and should be safe from being overwritten during system updates. The
/usr/localdirectory has a structure similar to
/usr/, and contains the following subdirectories:
/usr/local/differs slightly from the FHS. The FHS states that
/usr/local/should be used to store software that should remain safe from system software upgrades. Since the RPM Package Manager can perform software upgrades safely, it is not necessary to protect files by storing them in
/usr/local/for software local to the machine. For instance, if the
/usr/directory is mounted as a read-only NFS share from a remote host, it is still possible to install a package or program under the
/usr/as read-only, any programs that write log files or need
lock/directories should write them to the
/var/directory. The FHS states
/var/is for variable data, which includes spool directories and files, logging data, transient and temporary files.
/var/run/media/userdirectory contains subdirectories used as mount points for removable media such as USB storage media, DVDs, CD-ROMs, and Zip disks. Note that previously, the
/media/directory was used for this purpose.
lastlog, go in the
/var/lib/rpm/directory contains RPM system databases. Lock files go in the
/var/lock/directory, usually in directories for the program using the file. The
/var/spool/directory has subdirectories that store data files for some programs. These subdirectories include: