Unlocking Linux File Systems: From VFS to Ext4 and System Calls
This article explains Linux's file system architecture, covering basic directory structures, absolute and relative paths, symbolic links, the Virtual File System layer, core system calls such as creat, open, read, write, lseek, locking mechanisms, and the design of ext2, ext4, /proc, and NFS file systems.
Linux File System Basics
In Linux the most visible component is the file system. The design follows the principle "Small is Beautiful" and provides a powerful yet elegant interface built on a few simple system calls.
Standard Directory Layout
/bin– essential binaries for all users /boot – boot loader files /dev – device files /etc – configuration files and scripts /home – user home directories /lib – shared libraries for binaries /lost+found – recovery directory (root only) /media – mount points for removable media /mnt – generic mount points /opt – optional application installations /proc – virtual process information /root – root user's home directory /sbin – essential system binaries /tmp – temporary files (cleared on reboot) /usr – majority of user‑level applications /var – variable data such as logs and databases
Linux distinguishes absolute paths (starting from /) and relative paths (based on the current working directory). Symbolic links allow one user to reference another user's directory without typing a long absolute path.
File System System Calls
Key system calls include: creat(name, mode) – creates a new file and returns a file descriptor (fd) open(file, …) – opens an existing file close(fd) – closes a file descriptor read(fd, buffer, nbytes) – reads data write(fd, buffer, nbytes) – writes data lseek(fd, offset, whence) – moves the file pointer stat(name, &buf) and fstat(fd, &buf) – retrieve file metadata pipe(&fd[0]) – creates a pipe of pseudo‑files fcntl(fd, …) – performs locking and other control operations
fd = creat("aaa", mode);"Someone once asked Ken Thompson if he would rewrite UNIX; he replied he would change creat to create ."
File descriptors are non‑negative integers that uniquely identify open files. The kernel maintains a global file table, an open‑file description table (which stores the current file offset), and per‑process tables that map descriptors to entries.
"A file descriptor is simply a number that represents an open file in the operating system."
Virtual File System (VFS)
VFS abstracts the details of various concrete file systems (ext2, ext3, ext4, nfs, fuse, etc.) so that user programs interact with a uniform API. VFS defines four core objects:
Superblock – global file‑system metadata
Dentry – directory entry, part of a path
Inode – representation of a file
File – an open file associated with a process
Directory entries are cached in the dentry_cache to speed up lookups. Locks are implemented via POSIX advisory locking, supporting shared and exclusive modes.
Ext2 File System
Ext2 replaced the original MINIX‑1 file system and introduced longer file names and larger file sizes. Its on‑disk layout includes a boot block, a superblock, group descriptors, inode tables, block bitmaps, and data blocks. Directories consist of fixed‑size entries (inode, record length, type, name) stored linearly on disk.
Ext4 File System
Ext4 builds on ext3 by adding a journaling layer (JBD) that records metadata and optionally data changes as atomic transactions. This improves robustness after crashes and allows larger file and file‑system sizes.
/proc Virtual File System
The /proc pseudo‑file system presents process information as files. Each running process has a directory named by its PID containing files such as cmdline, environ, and status. The contents are generated on demand and do not occupy disk space.
Network File System (NFS)
NFS enables clients to mount remote directories over a network, making them appear as part of the local directory tree. The server exports directories via /etc/exports. Clients request file handles, which encode the file‑system type, device, inode, and security information. NFS uses standard UNIX permission bits (rwx) and can operate over heterogeneous platforms.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
