open(2), read(2), and write(2), remaining unaware of which underlying filesystem serves their files.
The VFS source lives in fs/, with per-filesystem implementations in subdirectories such as fs/ext4/, fs/btrfs/, fs/xfs/, and fs/proc/.
VFS abstraction
The VFS is described inDocumentation/filesystems/vfs.rst:
The Virtual File System (also known as the Virtual Filesystem Switch) is the software layer in the kernel that provides the filesystem interface to userspace programs. It also provides an abstraction within the kernel which allows different filesystem implementations to coexist.Four primary objects implement the VFS abstraction:
struct super_block
Represents a mounted filesystem instance. Holds filesystem-wide metadata (block size, flags, root dentry) and a pointer to
super_operations which implement sync_fs, statfs, evict_inode, etc.struct inode
Represents a filesystem object (file, directory, symlink, device node). Lives on disk for persistent filesystems or in memory for virtual ones. Pointed to by dentries.
struct dentry
A directory entry — the mapping from a filename component to an inode. The dentry cache (dcache) holds recently used dentries in memory for fast path resolution. Dentries are never written to disk.
struct file
The kernel-side representation of an open file descriptor. Created on
open(2) and destroyed on the final close(2). Points to a dentry and holds the current file offset and open flags.Key operations structures
Each VFS object type has an associated operations structure that filesystems populate to implement their behaviour.- inode_operations
- file_operations
- super_operations
Controls how inodes are looked up and manipulated:
Filesystem mounting
Mounting connects a filesystem instance to a point in the directory hierarchy. The VFS mount API (fs/namespace.c) was substantially revised in Linux 5.2 to introduce a more flexible fsopen/fsmount/move_mount interface alongside the classic mount(2) syscall.
Superblock creation
mount() calls the filesystem’s mount() or init_fs_context() method, which reads on-disk superblock data and populates struct super_block.Root dentry
The filesystem returns a root dentry. The kernel attaches it to the mount point in the current namespace’s mount tree.
Major filesystem implementations
ext4
ext4
The most widely deployed Linux filesystem. ext4 evolved from ext2/ext3, adding extents (replacing block maps), delayed allocation, journalling (via JBD2), online defragmentation, and large volume/file support.
- Journal modes:
journal(safest),ordered(default),writeback(fastest) - Extents: a contiguous range of blocks described by
(start_block, length), replacing per-block indirect maps - Checksums: metadata checksums protect journal, bitmaps, inodes, and directories
btrfs
btrfs
A copy-on-write (CoW) B-tree filesystem with built-in RAID, snapshots, checksums, and online filesystem growth and balance operations.
- CoW semantics: writes never overwrite existing data; old blocks remain until all references are gone
- Subvolumes: independently mountable filesystem sub-trees
- Snapshots: writable or read-only CoW clones of a subvolume, O(1) creation
- Checksums: all data and metadata are checksummed (CRC32C, xxHash, SHA256, Blake2b)
- RAID: built-in RAID 0/1/10/5/6 without dm-raid
XFS
XFS
A high-performance, scalable filesystem originally developed by SGI. XFS excels at large files and parallel I/O workloads.
- Allocation groups: independent parallel allocation units for scalable concurrency
- Extent-based: maps logical ranges to physical extents
- Journalling: write-ahead log for metadata; supports external log devices
- Delayed allocation: batches allocation decisions to reduce fragmentation
- Online repair:
xfs_repaircan repair a live mounted filesystem
Virtual and pseudo filesystems
tmpfs and ramfs
tmpfs and ramfs are in-memory filesystems. ramfs has no size limit and no swap backing. tmpfs enforces a configurable size limit and can page contents to swap.
tmpfs powers shm_open(3) and memfd_create(2) for shared memory, and is the backing store for /dev/shm.
proc filesystem
procfs (fs/proc/) exports kernel data structures as a filesystem tree under /proc. It is a pseudo-filesystem — no data is ever written to disk.
sysfs
sysfs (fs/sysfs/) exposes the kernel’s device model under /sys. Every bus, device, driver, and class has a directory. Attributes are files that represent individual properties.
FUSE
FUSE (Filesystem in Userspace,fs/fuse/) allows filesystem implementations to run entirely in user space. The kernel FUSE driver forwards VFS operations to a user-space daemon via a /dev/fuse character device.
- SSHFS — mount remote filesystems over SSH
- GVfs — GNOME virtual filesystem (FTP, MTP, Google Drive)
- libfuse-based implementations (EncFS, CephFS FUSE client, etc.)
Directory Entry Cache
The dentry cache (dcache) (fs/dcache.c) is a central performance component of the VFS. It caches recently resolved path components as struct dentry objects in a hash table, avoiding repeated lookup() calls into the filesystem.
stat() calls for missing files cheap. Under memory pressure, the kernel reclaims dentries starting from the least-recently-used end of the LRU.