Sie sind auf Seite 1von 3

Quick Introduction to Linux Filesystem & FHS

October 17, 2007 Dhaval Vadgama It is very important to understand the filesystem when, it comes to understanding an OS.These conceptual knowledge of filesystem could make things easier when it comes to system restoration. If we look at the any modern OSs filesystem ,It consist of File, Directory and typical File Hierarchy Structure (FHS) File: A file on computer is data item stored in disk drive or any other device capable of storing the data item. This data item can be simple a text file full of information or can be much more higher class of information in form such as images ,mp3 files, database record file , system logs etc Directory: A directory on computer is place where you have collection of related file or files of same type for e.g. for keeping all your mp3 files in one place its idle to keep them in directory named mp3.Hence,Directory provides an individual with capability of organizing files and program in an efficiently. So, this is what filesystem consist of but, what is filesystem? Simple, filesystem is collection of User data & Meta Data User Data: User data is the actual data stored by user containing information useful to user in electronic form. Meta Data: Meta data is the data used by OS. It holds the information about filesystem structure such as inode, superblock etc. For us, userdata is of not much interest , what we should know as system administrator is meta data, having a knowledge of meta data enables us to analyze the certain situations more closely where, filesystem has crashed. Lets explore, inode & Super block which lies at core of the filesystem. inode: inode or i-node is shorthand for Index Nodes.For Linux, inode is a data structure on filesystem that stores basic information about file,directory and other filesystem objects. The minimum POSIX standards with which inode should compile are as follow. Length of file in bytes Device ID, It contains identification number of the device containing file User ID of file, that is to know who created file Group ID of file,thats is to know to which group file belongs to and with what permission. An inode number. It is a number that identifies file with in filesystem ( remember everything boiles down to number with computers ) The file mode. This is to identify which user,group can perform the foperations on given file Time stamps , to know when inode itself was changed (change time aka ctime),The file modification (modification time aka mtime) and, last accessed time (aka atime). A reference count telling how many hard/soft links points to inode Super block: Super block contains magic number which identifies it as Linux File System and some other vital numbers describing file system geometry and other tuning parameters A magic number is a special constant used for some special purpose.It is called the magic because its value or presence is inexplicable without some additional knowledge.

Just to remind you, it is just a small introduction to filesystem , filesystem does have many more things to consider and, each filesystem have some specialized features which make it unique. Let, move on to the Linux File Hierarchy System (LFHS) which is also known as, File Hierarchy Standard (FSH) due to its use in various OS The only function of FHS is to provide with standard directory structure so that, important system configuration directories name & Location remain same across the different flavors of Linux and other OS that follows the FHS standard. FHS is currenty maintain by the Free Standard Group (FSG), a nonprofit organization Below Image shows LFHS layout

We will wrap up now, with a brief intro to all these directories. /bin: This directory contains the commands which can be used by both system administrator & users. /boot: This directory contains everything required for boot process for e.g. kernel and initrd. /dev: This directory holds all special files and device files such as /dev/null, /dev/mouse, /dev/cdrom, /dev/cdrecorder etc. /etc: This directory keeps all system configuration files on local host. A configuration file is file used to control program behavior. It must be static file and not executable binary file. /etc/opt/: This is place to keep host specific configuration file of 3rd party software installed under /opt /etc/X11/: This is place to keep all X11 host-specific configuration. This directory is necessary to allow local control if /usr is mounted read only. /etc/sgml/: configuration files for sgml are stored here but,they can be anywhere else in system. /etc/xml/: configuration files for xml should be stored here but,they can be any where else in system. /home: Users home directory used by users to save there work and other files. However location of /home can vary from host-to-host so no program should relay on this location. /lib: This directory stores all shared library files which required for system while booting and then to execute binary commands. /media: This directory is default mount point for removable media such as cdrom drive. /mnt: This directory provides location for mounting any file system temporarily and should be un-mounted once mounted file system is no longer required. /opt: This directory provides space to install any 3rd party software. /proc: This is virtual file system where in all system and kernel process status are stored mostly in text file format. /root: This is home directory of root user (i.e. Administrator) its location may be something else as per developer or local preference. /sbin: This directory keeps all utilities and command useful for system restore, maintenance,

booting, etc. which can be used only by the root or users with administrative privileges. /srv: Site-specific data which is served by the system /temp: Place for keeping temporary files used by programs for read-write hence it must be available to all programs. /usr: /usr is the second major section of the file system. /usr is shareable, read-only data. i.e. /usr should be shareable between various FHS-compliant hosts and must not be written to. /usr/bin/: Just like /bin directory, this directory also contains the commands which can be used by both system administrator & users. /usr/include/: This directory contains shared include files used by compilers /usr/lib/: Just like /lib directory, this directory stores all shared library files which required for system while booting and then to execute binary commands. /usr/sbin/: Just like /sbin directory, this directory keeps all utilities and command useful for system restore, maintenance, booting, etc. which can be used only by the root or users with administrative privileges. /usr/share/: This is place to keep read-only architecture independent data or any program that contain data which need not be changed ever are kept here. /usr/src/: If you choose to install the source code during installation this is where entire source code of your Linux OS will be placed. /urs/X11R7/: This directory is reserved for the X Window System, version 11 release 7, and related files /usr/local/: This directory is use by the system administrator when installing software locally. It needs to be safe from being overwritten when the system software is updated. It may be used for programs and data that are shareable amongst a group of hosts, but not found in /usr. /var: /var contains variable data files. This includes spool directories and files, administrative and logging data, and transient and temporary files This is all you need to know for now about about fileystem and filesystem hierarchy.To learn more about filesystem grab any book that explains Operating system concepts and, you can visit here for more details on FHS. Please note that these FHS standards are optional, one may follow only as much as required and scrap other things. Thus, you will find things differ from one OS to another and, even from one flavor of Linux to another.

Das könnte Ihnen auch gefallen