Difference between revisions of "Linux Filesystem Organization"

From wiki.emacinc.com
Jump to: navigation, search
m (About the Linux Filesystem: Fixed grammar.)
 
(11 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{todo|Finish this|Mike Dean|project=oe 4,oe 5,md,InProgress}}
+
{{todo|SEOKWREV (12.20.13-13:05->KY+)(12.20.13-15:40->MG+)(03.06.14-14:45->BS-);(04.10.14-14:20->BS+)|Mike Dean|project=oe 4,oe 5,md,ky,mg,bs,SEOKWREV}}
  
 +
{{#seo:
 +
|title=Linux Filesystem Organization
 +
|titlemode=append
 +
|keywords=Linux Filesystem,Cache Files,Configuration Files
 +
|description=This document covers parts of the standard and gives information about the customizations made to it by EMAC OE to accommodate embedded hardware.
 +
}}
 
==About the Linux Filesystem==
 
==About the Linux Filesystem==
  
Line 31: Line 37:
 
===Cache Files:===
 
===Cache Files:===
  
Files an application caches, such as downloaded package files, should be stored in <code>/var/cache/</code>.  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.
+
Files cached by an application, such as downloaded package files, should be stored in <code>/var/cache/</code>.  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:===
 
===Application State Information:===
Line 39: Line 45:
 
===Process IDs:===
 
===Process IDs:===
  
Daemons often need to store their process IDs in a location where utilities for starting and stopping them can find them.  In Linux, these are located in <code>/var/run/</code>.  This directory is automatically cleared at boot on any normal Linux system.  On EMAC OE, this directory is stored on a RAM disk.
+
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 <code>/var/run/</code>.  This directory is automatically cleared at boot on any normal Linux system.  On EMAC OE, this directory is stored on a RAM disk.
  
 
===Executables:===
 
===Executables:===
  
There are two different directories commonly used for installing custom written software.  The directories listed here are given according to the Free Desktop Standard, which is a standard by which most Linux systems conform.
+
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:

Latest revision as of 13:18, 10 April 2014

TODO: {{#todo:SEOKWREV (12.20.13-13:05->KY+)(12.20.13-15:40->MG+)(03.06.14-14:45->BS-);(04.10.14-14:20->BS+)|Mike Dean|oe 4,oe 5,md,ky,mg,bs,SEOKWREV}}

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