Difference between revisions of "Linux Filesystem Organization"

From wiki.emacinc.com
Jump to: navigation, search
m (Fixed.)
Line 43: Line 43:
 
===Executables:===
 
===Executables:===
  
There are two different directories commonly used for installing custom written software.  The directories listed here are given according to the Filesystem Hierarchy Standard.
+
There are two different directories commonly used for installing custom written software.  The directories listed here are given according to the Filesystem Hierarchy Standard, which is a standard to which most Linux systems conform.
  
 
This first directory is the standard location for executables which were written for a specific, individual machine:
 
This first directory is the standard location for executables which were written for a specific, individual machine:

Revision as of 10:58, 31 December 2013

TODO: {{#todo:Complete (12.20.13-13:05->KY+)(12.20.13-15:40->MG+)|Mike Dean|oe 4,oe 5,md,ky,mg,Complete}}

About the Linux Filesystem

The Linux filesystem organization has evolved over many years from the organization of Unix filesystems into a structure which supports all common cases and most corner cases. Much time and effort has been put into keeping the filesystem organization as simple as possible without sacrificing performance or navigability, or leaving needs unmet.

In order to prevent confusion and promote portability, a standard was created for the organization of the Linux filesystem. To ensure future portability of software created today, promote maintainability of software, and ensure proper utilization of available storage on an embedded machine, this standard should be followed as much as possible. This document covers parts of the standard and gives information about the customizations made to it by EMAC OE to accommodate embedded hardware. A link is provided to the standards document which covers the organization of the Linux filesystem at the end of this document.

Directories for Storing Files on a Machine

RAM Disk

The standard ramdisk on an EMAC OE machine, used for storing temporary files of any kind, is located in:

/var/volatile/

Note that this directory should not be used directly unless none of the directories listed below fits the file type.

Temporary Files:

The /tmp/ directory is the standard location to which temporary files should be written. In EMAC OE, the /tmp/ directory is symbolically linked to a directory within the /var/volatile/ RAM disk.

Lock Files:

The /var/lock directory contains lock files for concurrency between processes. Applications will often create an application-specific directory within this directory for their own use.

Log Files:

The /var/log directory is for log files. The system logger on EMAC OE, by default, does not actually log to this directory because the log messages are cached in RAM by Busybox. For logging, an application can choose to either use the system logging facilities, or write to a file within this directory.

Cache Files:

Files cached by an application, such as downloaded package files, should be stored in /var/cache/. In general, this should only be for data the application can download or generate again. This directory is, by default, stored on a RAM disk.

Application State Information:

Files which store application state data should be stored in /var/lib/. These are files which preserve state between invocations. On EMAC OE, this directory is stored on a RAM disk by default.

Process IDs:

Daemons often need to store their process IDs in a location where utilities for starting and stopping a daemon can find them. In Linux, these are located in /var/run/. This directory is automatically cleared at boot on any normal Linux system. On EMAC OE, this directory is stored on a RAM disk.

Executables:

There are two different directories commonly used for installing custom written software. The directories listed here are given according to the Filesystem Hierarchy Standard, which is a standard to which most Linux systems conform.

This first directory is the standard location for executables which were written for a specific, individual machine:

/usr/local/bin

The next directory is intended to be used for non-free (Company developed and owned) software:

/opt/CompanyName/bin

Since the CompanyName is specific to the company which produced the software, this directory will often also contain some other standard subdirectories:

/opt/CompanyName/etc/
/opt/CompanyName/usr/
/opt/CompanyName/lib/
/opt/CompanyName/var/

Configuration Files:

Configuration files should either go in:

/etc/

Or, if a directory in /opt/ was created, in:

/opt/CompanyName/etc/

Initialization Scripts:

Scripts which are used to automatically start a program on boot and, if needed, stop it on shutdown, should be located here:

/etc/init.d/

More Information

The Linux Foundation maintains the standards documents for the FHS, the Filesystem Hierarchy Standard, which dictates the directory layout for Linux and Unix systems. This document can be found on their website here: http://refspecs.linuxfoundation.org/fhs.shtml