Virtual file system

Also known as: VFS

On this page 7

A virtual file system (VFS) is the kernel abstraction layer that presents one uniform set of file operations to applications while delegating the actual work to whichever concrete file system holds the data. In OS storage design, the VFS is the reason a program can call the same open, read, write and close functions whether a file lives on an ext4 partition, a FAT32 USB stick, an ISO 9660 disc image or a network share.

The concept appeared in SunOS in the mid-1980s to let local UFS and remote NFS coexist, and today every major desktop kernel in operating systems such as Linux, macOS and Windows contains an equivalent layer, even where it is not called by that name.

How a virtual file system routes file operations

A VFS works by translating generic system calls into file system specific methods. When a process calls open(), the kernel resolves the path through the VFS, finds the mounted file system responsible for each path component and then invokes that driver’s own implementation through a table of function pointers.

In the Linux kernel, the VFS is built around four core objects. Each driver fills these structures with its own methods, so the generic code never needs to know the on-disk format of the underlying volume.

ObjectRepresentsTypical operations
SuperblockOne mounted file system instanceMount, unmount, sync, statfs
InodeA single file or directory and its metadataCreate, lookup, link, set attributes
DentryOne path component linking a name to an inodePath lookup, caching, revalidation
FileAn open file as seen by one processRead, write, seek, mmap, ioctl
Core objects of the Linux virtual file system

Between the system call and the driver, the VFS also maintains shared caches. The dentry cache speeds up repeated path lookups, the inode cache keeps recently used metadata in memory, and the page cache stores file contents so that most reads never touch the disk. Because these caches are generic, every file system benefits from them without implementing its own.

Mount points and the unified namespace

The VFS joins separate volumes into one directory tree through mounting. A mount point is an ordinary directory whose contents are replaced, for path resolution purposes, by the root of another file system. Unix-like systems therefore expose a single namespace starting at /, while Windows traditionally combines drive letters with optional folder mount points on NTFS volumes.

Not every mounted file system stores data on a disk. Pseudo file systems generate their contents on demand and use the VFS purely as an interface, which is why kernel state can be read with ordinary tools such as cat.

CategoryExamplesWhere the data lives
Disk-basedext4, NTFS, APFS, exFATPartitions on local block devices
NetworkNFS, SMB/CIFSA remote server reached over the network
Memory-basedtmpfs, ramfsRAM and swap only, lost at reboot
Pseudoprocfs, sysfs, devtmpfsGenerated by the kernel on each access
User spaceFUSE drivers such as sshfsHandled by a process outside the kernel
Kinds of file systems that plug into a VFS

The FUSE interface deserves particular mention. It forwards VFS requests from the kernel to a user space daemon, so developers can write a file system for cloud storage or archives without kernel code, at the cost of extra context switches and lower throughput.

Virtual file system implementations across desktop operating systems

Each desktop platform implements the same architectural idea with different interfaces. The name VFS is most closely associated with Unix heritage, but Windows uses a comparable layered design built on drivers and I/O request packets.

PlatformAbstraction layerExtension mechanism
LinuxVFS with superblock, inode, dentry and file objectsKernel modules or FUSE
macOSBSD-derived VFS with vnodesFile system kernel extensions, FSKit, macFUSE
FreeBSDVnode interface descended from SunOSKernel modules or FUSE
WindowsI/O manager with file system driversFilter drivers, minifilters, ProjFS, WinFsp
Equivalent abstraction layers on major platforms

On Windows, file system minifilters can intercept requests before or after the file system driver handles them. Antivirus scanners, backup agents and cloud sync clients use this layering to inspect or redirect operations, which is functionally similar to stacking on a Unix VFS.

How the VFS relates to file systems, volumes and partitions

The VFS is not a file system in its own right and stores nothing on disk. A file system such as exFAT or a journaling file system defines the on-disk layout, a disk volume is the formatted container that holds it, and a partition is the region of the disk recorded in the partition table. The VFS sits above all of them and only sees mounted file systems.

This separation explains several everyday behaviors. Features such as file attributes, sparse files or copy-on-write cloning appear only when the concrete file system supports them, and the VFS reports an error such as EOPNOTSUPP when it does not. The interface is shared, but the capabilities remain driver specific.

Limitations and common misconceptions

A uniform interface hides differences, and hidden differences cause subtle bugs. Practitioners regularly encounter the following problems when software assumes that every mounted file system behaves alike.

SymptomUnderlying causePractical remedy
Permissions ignored on a USB driveFAT32 and exFAT store no Unix ownershipSet ownership with mount options such as uid and umask
Files differ only by letter case and collideCase sensitivity varies between file systemsAvoid case-only names in portable projects
Data lost after a crash despite a successful writeWrites sit in the page cache until flushedCall fsync for critical data
Slow access to a FUSE mountEach request crosses into user spaceIncrease caching or use a kernel driver
File watching misses changes on a network shareRemote changes bypass local notificationPoll periodically or use server-side events
Typical problems caused by the abstraction
  • The VFS does not add security by itself; permission checks call into each file system, and quality varies between drivers.
  • A virtual file system is not a disk image; a disk image is a file containing a complete volume, which the VFS can mount through a loop device.
  • The term also has a second, looser use in applications such as game engines and archive managers, where a user space library presents packaged files as a directory tree.

Explained without jargon

Think of a virtual file system as a universal adapter for files. A computer may hold data on an internal drive, a USB stick, a DVD and a server across the office, and each of those stores files in its own way. Programs should not have to learn every one of those methods.

The virtual file system sits in the middle. A program simply asks to open or save a file, and the operating system works out which storage holds it and how to talk to it. The program sees one consistent set of folders, no matter where the data really lives.

A typical use case

A software developer on a Linux laptop keeps source code on the internal ext4 partition, receives test data on an exFAT USB drive and edits configuration files on a company server mounted through SMB. A build script copies files between all three locations with the standard cp command and never checks which file system it is using.

One day the build fails because two files named Config.h and config.h were copied to the USB drive, where exFAT treats them as the same name. The developer recognizes that the VFS unifies the interface but not the rules of each file system, renames the files and adds a check for case-only conflicts. The result is a build that works reliably across every mounted volume.