A primer on Linux filesystem

shashank Jain
5 min readAug 11, 2018

In this blog we try to understand the linux file system mechanism, overview of some of the data structures involved and focus majorly on block device based file systems.

Linux philosophy is to treat everything as a file. As an example Socket, Pipe, Block Devices are all represented as files.

The filesystems in Linux act as a container to abstract the underlying storage in case of Block devices. For non block devices like Sockets, pipes there are file systems in memory which have operations which can be invoked using the standard file system API.

Linux abstracts all file systems by a layer called the Virtual File system (VFS). All file systems register with the VFS. VFS has the following important data structures

1. File — This represents the open file and captures the information like offset etc. The userspace has a handle to an opened file via a structure called file descriptor. This is the handle used to interface with the filesystem.

2. Inode — This is mapped 1:1 to the file. The Inode is one of the most critical structures and also holds the meta-data about the file. As an example on which data blocks the file data is stored, what access permissions are there on the file. This all info is part of Inode. Inodes are also stored on disk by the specific filesystem, but there is a representation in memory which is part of VFS layer. The filesystem is responsible to enumerate the VFS Inode structure.

--

--