Arch ファイルシステム階層

提供: ArchWiki
ナビゲーションに移動 検索に移動

Arch Linux は他の多数のディストリビューションと同じようにファイルシステム階層標準に従っています。それぞれのディレクトリについてその目的を説明するのに加えて、この記事では Arch 固有の事情についても説明しています。

目次

ファイルシステム階層標準

Filesystem Hierarchy Standard (FHS) のホームページ より:

"ファイルシステムスタンダードは Unix ディストリビューションの開発者やパッケージの開発者、そしてシステムの実装者によって使われることを想定して策定されました。ただし、この標準はあくまでリファレンスであり、Unix のファイルシステムやディレクトリ階層を管理する方法のチュートリアルではありません。"

共有可能ファイルと共有不能ファイル

共有可能ファイルとはあるホストで保存されていながら他者からも利用できるファイルです。共有不能ファイルは共有できないファイルのことです。例えば、ユーザーのホームディレクトリ内のファイルは共有可能であり、デバイスのロックファイルは共有不能です。

静的ファイルと可変ファイル

静的ファイルとは例えば、バイナリやライブラリ、ドキュメントなどのシステムの管理者以外からは変更を加えられることがないファイルを意味します。可変ファイルは静的ファイルでないファイルとして定義されます。

ディレクトリ

root ファイルシステム

root ファイルシステム (スラッシュ記号 (/) で表されます) は他の全てのファイルシステムの根幹となるファイルシステムです。階層の一番上に位置します。たとえファイルやディレクトリが別の物理デバイスに保存されていたとしても、全てのファイルとディレクトリは root ディレクトリ "/" 下に配置されます。root ファイルシステムの中身だけでシステムを起動・復旧・修復できるようになっている必要があります。

/bin: 重要なコマンドラインバイナリ (廃止)

シングルユーザーモードで、全てのユーザーから利用できるバイナリを置くための伝統的なディレクトリです (例: cat, ls, cp)。/bin のプログラムはたとえ / を含むパーティションしかマウントされてないときも利用することができます。実際には、Arch では必要なライブラリは全て /usr/lib に存在しています。2013年6月から、/bin は /usr/bin に統合されましたfilesystem パッケージには /bin から /usr/bin へのシンボリックリンクが含まれており、全てのパッケージは /usr/bin にインストールされるようになっています。

/boot: ブートローダーの静的なファイル

共有不能の、静的なディレクトリです。ブートローダーの設定ファイルやブートローダーのステージだけでなく、カーネルや ramdisk イメージも含みます。/boot にはカーネルがユーザー空間のプログラムを実行する前に使用されるデータも保存されます。マスターブートセクタやセクターマップファイルなどです。

/dev: デバイスファイル

Essential device nodes created by udev during the boot process and as machine hardware is discovered by events. This directory highlights one important aspect of the UNIX filesystem - everything is a file or a directory. Exploring this directory will reveal many files, each representing a hardware component of the system. The majority of devices are either block or character devices; however other types of devices exist and can be created. In general, 'block devices' are devices that store or hold data, whereas 'character devices' can be thought of as devices that transmit or transfer data. For example, hard disk drives and optical drives are categorized as block devices while serial ports, mice and USB ports are all character devices.

/etc: ホスト固有の設定

Host-specific, unsharable configuration files shall be placed in the /etc directory. If more than one configuration file is required for an application, it is customary to use a subdirectory in order to keep the /etc/ area as clean as possible. It is considered good practice to make frequent backups of this directory as it contains all system related configuration files.

/etc/X11

X Window System の設定ファイル。

/etc/X11/xinit

xinit configuration files. 'xinit' is a configuration method of starting up an X session that is designed to be used as part of a script.

/etc/X11/xinit/xinitrc

Global xinitrc file, used by all X sessions started by xinit (startx). Its usage is of course overridden by a .xinitrc file located in the home directory of a user.

/home: ユーザーディレクトリ

UNIX is a multi-user environment. Therefore, each user is also assigned a specific directory that is accessible only to them and to the root user. These are the user home directories, which can be found under '/home/$USER' (~/). Within their home directory, a user can write files, delete them, install programs, etc. Users' home directories contain their data and personal configuration files, the so-called 'dot files' (their name is preceded by a dot), which are 'hidden'. To view dotfiles, enable the appropriate option in your file manager or run ls with the -a switch. If there is a conflict between personal and system wide configuration files, the settings in the personal file will prevail. Dotfiles most likely to be altered by the end user include .xinitrc and .bashrc files. The configuration files for xinit and Bash respectively. They allow the user the ability to change the window manager to be started upon login and also aliases, user-specified commands and environment variables respectively. When a user is created, their dotfiles shall be taken from the /etc/skel directory where system sample files reside.

Directory /home can become quite large as it is typically used for storing downloads, compiling, installing and running programs, mail, collections of multimedia files etc.

/lost+found: ファイルシステム固有の復元可能なデータ

UNIX-like operating systems must execute a proper shutdown sequence. At times, a system might crash or a power failure might take the machine down. Either way, at the next boot, a filesystem check using the fsck program shall be performed. Fsck will go through the system and try to recover any corrupt files that it finds. The result of this recovery operation will be placed in this directory. The files recovered are not likely to be complete or make much sense but there always is a chance that something worthwhile is recovered.

/mnt: 一時的なマウントポイント

This is a generic mount point for temporary filesystems or devices. Mounting is the process of making a filesystem available to the system. After mounting, files will be accessible under the mount-point. Additional mount-points (subdirectories) may be created under /mnt/. There is no limitation to creating a mount-point anywhere on the system, but by convention and for practicality, littering a file system with mount-points should be avoided.

/opt: 問題のあるパッケージ

Packages and large static files that do not fit cleanly into the above GNU filesystem layout can be placed in /opt. FHS 2.3 denotes /opt as reserved for the installation of add-on application software packages. A package placing files in the /opt/ directory creates a directory bearing the same name as the package. This directory in turn holds files that otherwise would be scattered throughout the file system. For example, the acrobat package has Browser, Reader, and Resource directories sitting at the same level as the bin directory. This doesn't fit into a normal GNU filesystem layout, so Arch places all the files in a subdirectory of /opt.

/proc: プロセス情報

Directory /proc is very special in that it is also a virtual filesystem. It is sometimes referred to as the process information pseudo-file system. It doesn't contain 'real' files, but rather, runtime system information (e.g. system memory, devices mounted, hardware configuration, etc). For this reason it can be regarded as a control and information center for the kernel. In fact, quite a lot of system utilities are simply calls to files in this directory. For example, 'lsmod' is the same as 'cat /proc/modules' while 'lspci' is a synonym for 'cat /proc/pci'. By altering files located in this directory, kernel parameters may be read/changed (sysctl) while the system is running.

The most distinctive facet about files in this directory is the fact that all of them have a file size of 0, with the exception of kcore, mounts and self.

/root: 管理者ディレクトリ

Home directory of the System Administrator, 'root'. This may be somewhat confusing, ('/root under root') but historically, '/' was root's home directory (hence the name of the Administrator account). To keep things tidier, 'root' eventually got its own home directory. Why not '/home/root'? Because '/home' is often located on a different partition or even on another system and would thus be inaccessible to 'root' when - for whatever reason - only '/' is mounted.

/run: 一時的な実行時データ

The /run mountpoint is supposed to be a tmpfs mounted during early boot, available and writable to for all tools at any time during bootup. systemd, udev or mdadm that are required early in the boot process require this directory, because /var can be implemented as a separate file system to be mounted at a later stage in the start-up process. It replaces /var/run/, which becomes a symlink of /run.

/sbin: システムバイナリ (廃止)

Traditionally UNIX discriminates between 'normal' executables and those used for system maintenance and/or administrative tasks. The latter were supposed to reside either here or - the less important ones - in /usr/sbin. Programs executed after /usr is known to be mounted (when there are no problems) are generally placed into /usr/sbin. In practice, programs in /sbin require /usr to be mounted as all the necessary libraries are in /usr/lib. As of June 2013, /sbin and /usr/sbin were merged into /usr/bin. The filesystem package provides symlinks from /sbin and /usr/sbin to /usr/bin, and all packages should be updated to explicitly install to /usr/bin.

/srv: サービスデータ

Site-specific data which is served by the system. The main purpose of specifying this is so that users may find the location of the data files for a particular service, and so that services which require a single tree for read-only data, writable data and scripts (such as CGI scripts) can be reasonably placed. Data of interest to a specific user shall be placed in that user's home directory.

/sys: 仮想ファイルシステム

Virtual file system provided by the Linux kernel. By using virtual files, sysfs exports information about various kernel subsystems, hardware devices and associated device drivers from the kernel's device model to user space. In addition to providing information about various devices and kernel subsystems, exported virtual files are also used for their configuring.

/tmp: 一時的なファイル

This directory contains files that are required temporarily. Many programs use this to create lock files and for temporary storage of data. Do not remove files from this directory unless you know exactly what you are doing! Many of these files are important for currently running programs and deleting them may result in a system crash. On most systems, old files in this directory are cleared out at boot or at daily intervals.

/usr: 共有可能な、読み取り専用データ

While root is the primary filesystem, /usr is the secondary hierarchy, for user data, containing the majority of (multi-)user utilities and applications. /usr is shareable, read-only data. This means that /usr shall be shareable between various hosts and must not be written to, except by the package manager (installation, update, upgrade). Any information that is host-specific or varies with time is stored elsewhere.

Aside from /home, /usr usually contains by far the largest share of data on a system. Hence, this is one of the most important directories in the system as it contains all the user binaries, their documentation, libraries, header files, etc. X and its supporting libraries can be found here. User programs like telnet, ftp, etc., are also placed here. In the original UNIX implementations, /usr (for user), was where the home directories of the system's users were placed (that is to say, /usr/username was then the directory now known as /home/username). Over time, /usr has become where userspace programs and data (as opposed to 'kernelspace' programs and data) reside. The name has not changed, but its meaning has narrowed and lengthened from everything user related to user usable programs and data. As such, the backronym 'User System Resources' was created.

/usr/bin: バイナリ

コマンドバイナリ。このディレクトリにはシステム上のバイナリ (アプリケーション) のほとんどが含まれます。このディレクトリ内の実行ファイルは様々です。例えば vim や gcc、gnome-session などがここに置かれます。昔は、このディレクトリには root 権限を必要としない、そしてシングルユーザーモードで必要ないバイナリだけを置くことになっていました。しかしながら、この決まりごとは既に強制ではなくなっており、Arch の開発陣は 全てのバイナリをこのディレクトリに移動することを計画 全てのバイナリをこのディレクトリに移動しています。

/usr/include: ヘッダーファイル

ユーザー空間のソースコードをコンパイルするのに必要なヘッダーファイル。

/usr/lib: ライブラリ

ノート: The /lib directory becomes a symlink to /usr/lib. Here is the news. If you encounter error during this update. Please see DeveloperWiki:usrlib for solution.

Contains application private data (kernel modules, systemd services, udev rules, etc) and shared library images (the C programming code library). Libraries are collections of frequently used program routines and are readily identifiable through their filename extension of *.so. They are essential for basic system functionality. Kernel modules (drivers) are in the subdirectory /lib/modules/<kernel-version>.

/usr/sbin: システムバイナリ (廃止)

Non-essential system binaries of use to the system administrator. As of June 2013, /usr/sbin was merged into /usr/bin. The filesystem package provides symlinks from /usr/sbin to /usr/bin, and all packages should now explicitly install to /usr/bin.

/usr/share: アーキテクチャに依存しないデータ

This directory contains 'shareable', architecture-independent files (docs, icons, fonts etc). Note, however, that /usr/share is generally not intended to be shared by different operating systems or by different releases of the same operating system. Any program or package which contains or requires data that do not need to be modified should store these data in /usr/share (or /usr/local/share, if manually installed - see below). It is recommended that a subdirectory be used in /usr/share for this purpose.

/usr/src: ソースコード

'linux'のサブディレクトリは、Linuxのカーネルのソースとヘッダファイルを格納しています。

/usr/local: ローカル階層

Optional tertiary hierarchy for local data. The original idea behind /usr/local was to have a separate ('local') '/usr' directory on every machine besides /usr itself, which might be mounted read-only from somewhere else. It copies the structure of /usr. These days, /usr/local is widely regarded as a good place in which to keep self-compiled or third-party programs. This directory is empty by default in Arch Linux. It may be used for manually compiled software installations if desired. pacman installs to /usr, therefore, manually compiled/installed software installed to /usr/local may peacefully co-exist with pacman-tracked system software.

/var: 可変ファイル

Variable files, such as logs, spool files, and temporary e-mail files. On Arch, the ABS tree and pacman cache also reside here. Why not put the variable and transient data into /usr/? Because there might be circumstances when /usr/ is mounted as read-only, e.g. if it is on a CD or on another computer. '/var/' contains variable data, i.e. files and directories the system must be able to write to during operation, whereas /usr/ shall only contain static data. Some directories can be put onto separate partitions or systems, e.g. for easier backups, due to network topology or security concerns. Other directories have to be on the root partition, because they are vital for the boot process. 'Mountable' directories are: '/home', '/mnt', '/tmp' and '/var'. Essential for booting are: '/bin', '/boot', '/dev', '/etc', '/lib', '/proc', '/sbin' and '/usr'.

/var/abs

The ABS tree. A ports-like package build system hierarchy containing build scripts within subdirectories corresponding to all installable Arch software.

/var/cache/pacman/pkg

pacman のパッケージキャッシュ。

/var/lib: 状態情報

Persistent data modified by programs as they run (e.g. databases, packaging system metadata etc.).

/var/log: ログファイル

ログファイル。

/var/mail: ユーザーのメール

ユーザのメールボックスに推奨されていない場所です。

/var/spool: キュー

Spool for tasks waiting to be processed (e.g. print queues and unread mail).

/var/spool/mail

Shareable directory for users' mailboxes.

/var/tmp: 保持される可能性がある一時的なファイル

Temporary files to be preserved between reboots.

参照