file system3

Anatomy of a File System

At the most general level, most people know what a file system is: A storage utility that stores the data of a server or computer. We know that all our of files, directories and services have to live somewhere, but where do they live; or, perhaps, the real question is how?

We know that computers read only the 1s and 0s of its data and that this data must be stored in a way that a computer can understand. This means that file systems are organized bodies of data — for the system, the organization exists through inodes; for users, this is the hierarchy of directories and files from which users can work.

inodes

Inodes are a data structure, or a way for computers to efficiently organize data. An inode represents a file system object, and stores the attributes and disk block locations of data. This includes the metadata for an object, as well as the permissions and ownership of that object.

Each inode has an individual number. Numbers cannot repeat or be reused in the system, and even when moving an object within the system, the number cannot change. It can, however, be viewed with the ls -i command, the -i signifying that the system should output the inode number to each file.

The File System Hierarchical Structure

Linux file systems start at the topmost, or root, directory and then go deeper, each sub-directory serving its purpose:

File System Types

Common file system types for Linux systems include:

  • ext2 — The second “extended file system” (the first, ext, is no longer in use). Data is stored in files, with a maximum file size of 2TiB and maximum volume size of 4TiB. File names can be up to 255 bytes.
  • ext3 — The third extended file system, an update of ext2. This system uses journaling, and like ext2 supports a maximum file size of 2 TiB and a 255-byte file name limit. However, the maximum volume size is 32 TiB.
  • ext4 — The fourth extended file system. As with ext3, it uses journaling and has a 255-byte file name limit. Supports up to 16 TiB file size, with a 1 EiB volume size limit (although 16 TiB is recommended).
  • Reiser — Reiser file systems are similar to ext3, but uses a different internal structure to the above systems. Reiser allows for journaling and uses checksums to verify journal files. The maximum volume size is 16 TiB, with a maximum file size of 1EiB. On Linux, the file name is limited to 255 bytes. A newer version of Reiser, called Reiser4 exists, but is currently not incorporated into mainline Linux systems.

Journaling

Many of the file systems above use something called journaling. Journaling allows for a more reliable file system since non-journaled systems risk corruption during power outages or any issues that can arise which interrupt a save.

Journaling systems write changes to logs, which exist in a dedicated area of the system. Then, after the save occurs the system then checks the logs and writes any changes to the main file system; this entails that, while corruption can still happen, it is less likely, and your systems are always consistent.

Journaling can occur two ways, data-mode journaling, and ordered-mode journaling. Deciding between the two is a question of data integrity versus speed. Data-mode journaling, which logs both data and metadata, provides the greatest protection against data loss but takes longer and uses more resources than the alternative, ordered-mode journaling, which logs only metadata.

Partitioning

A final concept in file systems is partitioning. Partitioning is a way of taking the larger file system and “sectioning” it off into different data groups; this allows for additional data security, and should data in one partition be corrupted by errors the chance for those errors to affect other partitions is limited.

Elle K

Elle is a technical writer and Linux aficionado at Linux Academy.

5 thoughts on “Anatomy of a File System

    1. It is possible to view this image in larger size right here, in the text. The first one is small, but you can click on the second image and it becomes largest 🙂

  1. Could I make a couple of observations, but before that I just have to say that I love the site, already paying for all courses, this site rocks. Now in regards to the points I wanted to mention, they are:

    1. /media & /mnt both are for internal and external storage, but /media is for the system to automatically mount them, while the /mnt, which might look deprecated but can be in fact be used by sysadmins to mount devices manually. So /media is the new media storage for both, internal and external devices, while /mnt is the old one.

    2. inodes can be seem by either ls -i or the stat command. This is very important because in a Google interview I had, they actually said that stat was the only one. So students should know that BOTH CAN be used.

    3. BTRFS and ZFS could possibly be mentioned since ReiserFS is not so much updated as this 2 guys and this 2 file systems are growing in popularity in their respective areas.

    The rest of the article is just awesome. Currently the best one.

    1. I am a new student to all of this, so thank you for providing this explanation. It really helps when you are trying to learn the ins and outs of this topic.

Leave a Reply

Your email address will not be published. Required fields are marked *