Linux File System
A file system is the method and data structures that an operating system uses to keep track of files on a disk or partition. Basically how things will be stored. Before a partition or disk can be used as a file system, it needs to be initialized, and the bookkeeping data structures need to be written to the disk. This process is called making a file system.
File System Types:
ext2: Traditional Linux file system type, which was implemented in the 2.2 kernel. ext2 have limitation to handle size of 2 TiB.
ext3: Ext3 is very similar to ext2. Ext3 is an improved file system type from ext2 in response to its shortcomings. which was, journaling. Ext3 could only handle a minimum of 2TiB and up to 16TiB.
- Journaling reduces the disk check time after a crash and it helps to reduce the total amount of data loss.
ext4: is the latest and most current version, is based upon ext3. while ext3 most notable improvement was adding journaling… Ext4 on the other hand can handle larger file sizes and a file system up to 1EiB. But, perhaps one of its most notable improvements was its overall file system design, performance, reliability and its features.
The Reiser File System is a journaling file system with so-called “balance tree” structure. It is more efficient with smaller files since it will pack as many files as it can into a disk block. Typically, a file system will just put one file per disk block. ReiserFS can handle a max file size of 8TiB. It is no longer maintained and not recommended for use.
JFS: (Journaled File System) was created by IBM. one of its most notable features was, the file system journaled as an “add-on” feature, it was implemented from the beginning. But, the file system only journals metadata. Which means that the metadata will remain consistent even if files are corrupted. today it isn’t well maintained and i would recommend using it.
XFS: Originally designed by SGI, XFS is journaling file system for computers with 64 bit processes. The advantage to use XFS is it supporting large file size up to 8 EiB. Much like JFS, where it has metadata journaling but also supports white barriers. More information can be found here. https://en.wikipedia.org/wiki/XFS
- White Barriers: “write barrier is a mechanism for enforcing a particular ordering in a sequence of writes to a storage system in a computer system.”
- A journaling file system is a file system that keeps track of changes not yet committed to the file system’s main part by recording the intentions of such changes in a data structure known as a “journal”, which is usually a circular log. In the event of a system crash or power failure, such file systems can be brought back online more quickly with a lower likelihood of becoming corrupted.
File System Hierarchy
Linux chooses to have a single hierarchical directory structure. Everything starts from the root directory, represented by /
- and then expands into sub-directories instead of having so-called ‘drives’
- Linux sorts directories descending from the root directory / according to their importance to the boot process.
/: The root directory is the top-level directory on a system
It is the directory from which all other directories, including subdirectories, and files reside
- Designated by a forward “/”
- / is the administrator
- Most Privileged account on the system
- Ability to modify Permission
- What you can do with Linux depends on the permissions and ownership of each file.
- Control is security in Linux
- usually represented by -rw-r-r– or rwx-rw-r otherwise known as octal. an octal is an eight-base form. Permission string is three digits, one digit for each of the owner, group, and other (user) (who is neither owner or group) permissions
- Starting with Owner, the Group and finally Users
- – Read: List directory contents
- – Write: Create/delete files in the directory
- – Execute: Read for directory and run program/script for file
/ (Pronounced “slash”)
- “/” is the primary directory from which you can find all other directories under.
- Contains binary executables.
- Commands used in single user mode
- Commands used by all the users of the system are located here.
- For example: ps, ls, ping, grep, cp.
- Boot loader files
- Essential Device files
/etc – Configuration Files
- Configuration files required by all programs
- also contains startup and shutdown shell commands
- shell commands that are used for start/stop individual programs
- example: /etc/resolv.conf, /etc/logrotate.conf
- Users home directories
- User’s saved files
- User’s personal settings
- libraries essential for binaries
- mount points for removable media, like USB devices and CD-ROMs
- Temp mounted file systems
- Optional application software packages
- Virtual file system providing process and kernel information as files
- home directory for root
- Run-time variable data
- Information about the running system since last boot
- Essential system binaries
- For example: iptables, reboot, fdisk, ifconfig, swapon
- Site-specific data served by this system, such as data and scripts for web servers, data offered by FTP servers, and repositories for version control systems.
- Contains information about devices, drivers, and some kernel features
- Temporary files
- Read-only user data
- Variable files
- Contains logs, spool files, and temporary e-mail files