File system
Adapted from Wikipedia · Adventurer experience
A file system is a way that a computer organizes and finds files. It helps the computer keep track of all the information stored on it, like how a library organizes books. Without a file system, the computer would have a hard time managing its files.
In computing, a file system works with the operating system to give applications a way to store and retrieve data. There are two main types: local file systems that work on a single computer, and distributed file systems that let networked computers share files with each other.
File systems can work with many kinds of storage devices, such as hard disk drives (HDDs), solid-state drives (SSDs), magnetic tapes, and optical discs. Some file systems even use the computer's main memory as temporary storage. This makes it very fast but only works while the computer is running.
Etymology
Before computers were invented, around the year 1900, people used the words "file system" to describe how they organized and stored paper documents. By 1961, the term "file system" began to be used for organizing files on computers, while still keeping its meaning for paper documents. By 1964, the term was commonly used for computer file systems.
Architecture
A local file system is like layers that work together. The top layer helps programs open, close, read, and write files. It also keeps files safe.
The middle layer, called the virtual file system, lets the computer use many kinds of file systems together. The bottom layer talks to the storage device, like a hard drive, to save and read information. It uses special tools to control the device.
Attributes
File names
A file name, or filename, helps identify a file so that programs and users can find it easily.
A file name must be unique in its folder so that a program can refer to only one file with that name. If a file system has folders, then the same file name can exist in different folders.
Most file systems limit how long a file name can be.
Some file systems treat file names as the same regardless of uppercase and lowercase letters (like MYFILE and myfile being the same), while others treat them as different.
Most modern file systems allow file names to include many different characters. Some characters might be restricted because they have special meanings in the file system.
Directories
File systems usually let you organize files into directories, also called folders, grouping files together.
This can be done by linking the file name to an index in a list or a special structure.
Directory structures can be simple lists or allow folders inside folders, called subfolders.
The first file system to support folders inside folders was used in the Multics operating system. Many systems today, like those from Unix, Apple, Microsoft Windows, and OpenVMS, support folders inside folders.
Metadata
Besides the actual data in a file, a file system also keeps track of metadata, which includes information such as:
- the file’s name
- its size
- when it was created, last opened, or changed
- who can access it
- permissions for who can read or change it
- whether the file can only be read or also changed
- what kind of file it is
A file system keeps this metadata separate from the file’s content.
Most file systems store the names of all files in a folder in one place. Some metadata is stored with the file name, and other parts are stored separately.
Most file systems also store metadata that is not tied to any specific file, like information about free space or damaged parts of the storage.
Storage space organization
A local file system keeps track of which parts of the storage belong to which file and which parts are free.
When a new file is created, the file system sets aside space for it to store data. Some file systems let you decide how much space to set aside at first and add more as the file grows.
When a file is deleted, the file system marks that space as free so it can be used for another file.
A local file system organizes storage space to be reliable and efficient. It usually allocates space in small pieces, called blocks. For example, early systems used blocks that were 256 bytes each.
The size of these blocks is usually decided when the storage is set up.
Fragmentation
As files are created, changed, and deleted, the way files are stored on the storage device can become scattered, a process called fragmentation.
A file becomes fragmented if the space needed for it cannot all be found in one continuous area. Free space also becomes fragmented when files are deleted.
Fragmentation is not visible to users, and the system still works normally. However, it can slow down performance on some devices, like hard disk drives. Devices like solid-state drives are not affected by fragmentation.
Access control
A file system often includes ways to control who can read or change files.
This helps prevent some users from accessing certain files.
Access control can also limit what programs can do with files.
Storage quota
Some operating systems let administrators set limits on how much storage space a user can use.
Data integrity
A file system works to keep data safe during normal use and in unexpected situations, such as:
- a program stopping suddenly
- the computer crashing
- problems with the storage device
- losing connection to remote systems
- the operating system stopping
- restarting the computer
- power failures
The file system can fix things like updating information about files or handling data that didn’t finish saving.
Recording
A file system might keep a record of events to help fix problems or see how the system is working.
Data access
Byte stream access
Many file systems let programs read and write files as a stream of bytes.
A program gives a space in memory, and the file system reads the file’s data into that space. When saving, the program gives data to the file system, which writes it to the storage.
Record access
Some file systems let programs work with files as organized groups of data, called records, instead of just a mix of bytes.
If each record has the same length, it’s quick to find the nth record. Each record can also have a special identifier, called a key, which helps programs find and change records without knowing where they are stored.
Utilities
File systems can be managed by tools that let users create, change, and remove file systems. These tools can also adjust how much space is used.
Tools for folders let users create, rename, and delete them, and change their settings.
Tools for files let users create, list, copy, move, and delete files, and change their settings.
File system API
Programs and tools use special commands, called file system APIs, to tell the file system what to do. This includes moving data, changing file settings, managing folders, controlling access, and removing files.
Multiple file systems within a single system
Often, a storage device is used for just one file system.
Another way is to split the disk into parts, each with its own file system with different settings.
Some file systems, like ZFS and APFS, can share space and support multiple file systems with different settings without needing to set aside fixed space for each.
Another method, common in cloud systems, is to keep extra file systems inside another file system as if they were files. This helps protect other files if one file system gets damaged and makes it easy to manage different setups.
Types
Storage media
Disk file systems
A disk file system helps computers find and read data quickly. Many people or programs can use the same data at the same time, even if it is stored in different places on the disk. Examples include FAT, exFAT, NTFS, and many others.
Optical discs
Formats like ISO 9660 and Universal Disk Format (UDF) are used for CDs, DVDs, and Blu-ray discs. Mount Rainier is an extension to UDF that makes it easier to write to DVDs.
Flash file systems
A flash file system is made for devices that use flash memory, which works differently from regular disks.
Tape file systems
Tape file systems store files on magnetic tapes. Tapes are slower to access than disks, so these file systems are made to work better with how tapes work, like spreading file information across the tape.
Tape formatting
Formatting a tape can take a long time, so tapes are often pre-formatted. Users just need to label the tape before using it.
Minimal file system / audio-cassette storage
In the 1970s, some early computers used audio cassettes for storage. Users would press “RECORD” to save data and “PLAY” to read it back. The system used sounds to mark where data started and ended.
Database file systems
Some file systems use databases to manage files. Files are grouped by things like type, topic, or author instead of just folders. IBM’s DB2 for i is an example of this kind of system.
Transactional file systems
Some programs need to make many changes to files at once. If even one change fails, the whole set of changes should be undone so the system keeps working. Transactional file systems help make this possible.
Network file systems
A network file system lets computers access files over a network, as if they were stored locally. Examples include clients for NFS, AFS, and SMB.
Shared disk file systems
A shared disk file system lets multiple computers access the same external storage at the same time without causing problems. Examples include GFS2, GPFS, and others.
Special file systems
Some file systems let you interact with parts of the operating system through files. For example, in Unix-like systems, you can find files that represent devices or system information.
Directory hierarchy support
Flat file systems
In a flat file system, there are no folders. All files are stored directly on the disk. This works well for small numbers of files but can get messy as more files are added. Early systems like DOS/360 and some small computers used flat file systems.
Hierarchical file systems
Most modern file systems use a hierarchical structure, where files are organized into folders that can contain other folders. This makes it easier to organize large numbers of files. The classic Mac OS originally used a flat file system but switched to a hierarchical system in later versions.
Implementations
An operating system (OS) usually works with one or more file systems. The OS helps users to access files. It often has a command line interface, like a Unix shell, Windows Command Prompt and PowerShell, or OpenVMS DCL. An OS also often has a file browser in a graphical user interface such as Finder on macOS, File Explorer on Windows, GNOME Files in GNOME, or Dolphin in KDE Plasma.
Unix and Unix-like operating systems
Unix-like operating systems create a virtual file system. This makes all files on all connected storage devices seem to be in one big structure. In these systems, there is one root directory, and every file is located under it somewhere. Unix-like systems can use a RAM disk or network shared resource as its root directory.
Unix-like systems give each device a name, but files on that device aren’t accessed that way. To access files on another device, the OS needs to be told where in the directory tree those files should appear. This process is called mounting a file system. For example, to access files on a CD-ROM, you must tell the OS to take the file system from that CD-ROM and make it appear under a specific directory. The directory given to the OS is called the mount point — for example, /media. The /media directory is used on many Unix systems for mounting removable media like CDs, DVDs, USB drives, or floppy disks. It may be empty or contain subfolders for mounting individual devices. Usually, only the administrator (the root user) can authorize mounting file systems.
Unix-like systems often include tools that help with mounting and add new features. Some of these are called "auto-mounting" because they do this automatically.
- In many cases, file systems other than the root need to be available as soon as the OS has booted. All Unix-like systems therefore provide a way to mount file systems at boot time. System administrators define these file systems in the configuration file fstab (vfstab in Solaris_), which also shows options and mount points.
- In some cases, there’s no need to mount certain file systems at boot time, though you might want to use them later. Some tools for Unix-like systems let you mount predefined file systems when needed.
- Removable media let you move programs and data between machines without a physical connection. Examples include USB flash drives, CD-ROMs, and DVDs. Tools have been created to detect when a medium is present and then mount it without any user action.
- Newer Unix-like systems have introduced a concept called supermounting. For example, a floppy disk that has been supermounted can be physically removed. Normally, the disk should be synchronized and then unmounted before removal. If synchronization has happened, a different disk can be inserted. The system automatically notices the change and updates the mount point to show the new medium.
- An automounter will automatically mount a file system when someone tries to access the directory where it should be mounted. This is often used for file systems on network servers.
Linux
Linux supports many file systems, but common choices for the system disk include the ext* family (ext2, ext3 and ext4), XFS, JFS, and btrfs. For raw flash without extra layers, there are UBIFS, JFFS2 and YAFFS, among others. SquashFS is a common compressed read-only file system.
Solaris
Solaris used to use (non-journaled or non-logging) UFS for bootable and extra file systems. Solaris later added support for other file systems and improvements, including Veritas Software Corp. (journaling) VxFS, Sun Microsystems (clustering) QFS, Sun Microsystems (journaling) UFS, and Sun Microsystems (open source, poolable, compressible, and error-correcting) ZFS.
Solaris added kernel extensions to allow bootable Veritas VxFS operation. Logging or journaling was added to UFS in Sun's Solaris 7. Later releases of Solaris 10, Solaris Express, OpenSolaris, and other open source versions supported bootable ZFS.
Logical Volume Management lets you spread a file system across multiple devices for redundancy, capacity, and/or speed. Older Solaris systems may use Solaris Volume Manager (formerly Solstice DiskSuite). Modern Solaris systems use virtual storage pools in ZFS.
macOS
macOS (formerly Mac OS X) uses the Apple File System (APFS), which replaced an older system called HFS Plus in 2017. HFS Plus stores lots of extra information and usually does not allow different cases (like “File” and “file”) but adds Unix permissions. Later versions added journaling to prevent file system damage and made improvements to file handling.
File names can be up to 255 characters. HFS Plus uses Unicode for file names. On macOS, the filetype can come from the type code stored in the file’s extra information or the filename extension.
HFS Plus has three kinds of links: Unix-style hard links, Unix-style symbolic links, and aliases. Aliases keep working even if the file is moved or renamed, but they are handled by macOS and not by the file system itself.
macOS 10.13 High Sierra, announced in 2017, uses the Apple File System on solid-state drives.
macOS also supports the UFS file system from BSD Unix via NeXTSTEP. But as of Mac OS X Leopard, macOS can’t be installed on UFS, and older systems can’t update to newer versions. As of Mac OS X Lion, UFS support was removed completely.
Newer macOS versions can read and write to older FAT file systems common on Windows. They can also read newer NTFS file systems. To write to NTFS on older macOS versions, special software is needed. Mac OS X 10.6 (Snow Leopard) and later allow writing to NTFS after changing a setting (special software can automate this).
macOS has supported reading and writing the exFAT file system since Mac OS X Snow Leopard version 10.6.5.
OS/2
OS/2 1.2 introduced the High Performance File System (HPFS). HPFS supports mixed case file names, long file names (255 characters), better use of disk space, keeping related items close together, less data fragmentation, extent-based space allocation, a B+ tree structure for directories, and places the root directory in the middle of the disk for faster access. A journaled filesystem (JFS) was added in 1999.
PC-BSD
PC-BSD is a desktop version of FreeBSD, which uses FreeBSD’s ZFS support, like FreeNAS. The new installer for PC-BSD can set up / (root) on ZFS and RAID-Z pool installs and disk encryption using Geli easily through a GUI. The current PC-BSD 9.0+ 'Isotope Edition' uses ZFS filesystem version 5 and ZFS storage pool version 28.
Plan 9
Plan 9 from Bell Labs treats everything as a file and accesses all objects like files. Networking, graphics, debugging, authentication, and other services are accessed through file operations. The 9P protocol removes the difference between local and remote files. File systems in Plan 9 use private, per-process namespaces, so each process can see file systems differently.
The Inferno operating system shares these ideas with Plan 9.
Microsoft Windows
Windows uses the FAT, NTFS, exFAT, Live File System and ReFS file systems (ReFS works only in Windows Server 2012, Windows Server 2016, Windows 8, Windows 8.1, and Windows 10; Windows can’t start from it).
Windows uses a drive letter to distinguish one disk or part from another. For example, the path C:\WINDOWS shows a folder called WINDOWS on the part shown as letter C. Drive C: is usually the main hard disk drive part, where Windows is installed and starts. This tradition comes from old times, where letters A and B were for floppy disks. This started with MS-DOS, based on older systems.
FAT
Main article: File Allocation Table
The FAT file systems work with almost all personal computer operating systems, including all versions of Windows and MS-DOS/PC DOS, OS/2, and DR-DOS. FAT file systems are good for moving files between different computers and devices.
FAT started with an old 8-bit version and grew to FAT12, FAT16 and FAT32. Features added include subdirectories, codepage support, extended attributes, and long filenames. Some companies added optional support for tracking deletions and security for files and folders, but Windows doesn’t support most of these.
FAT12 and FAT16 had limits on the number of entries in the root directory and on the size of FAT-formatted disks or partitions.
FAT32 fixes some limits from FAT12 and FAT16, except for a file size limit close to 4 GB, but it’s still limited compared to NTFS.
FAT12, FAT16 and FAT32 limit file names to eight characters and extensions to three characters (like .exe). This is called the 8.3 filename limit. VFAT, added in Windows 95 and Windows NT 3.5, allowed long file names (LFN) in a way that works with older systems.
NTFS
Main article: NTFS
NTFS, introduced with Windows NT in 1993, allows permission control. Other features include hard links, multiple file streams, indexing, tracking usage, sparse files, encryption, compression, and special directories for linking to other file systems, network links, and more.
exFAT
Main article: exFAT
exFAT has benefits over NTFS for file system overhead.
exFAT isn’t compatible with older FAT systems like FAT12, FAT16 or FAT32. It works with newer Windows systems like Windows XP, Windows Server 2003, Windows Vista, Windows 2008, Windows 7, Windows 8, Windows 8.1, Windows 10 and Windows 11.
exFAT works with macOS starting from version 10.6.5 (Snow Leopard). Support in other systems is limited because using exFAT needs a license. exFAT is the only file system fully supported on both macOS and Windows that can hold files larger than 4 GB.
OpenVMS
MVS
Main article: MVS § MVS filesystem
Before VSAM, OS/360 used a hybrid file system. It was made to work well with removable disk packs, so all file information for one disk (volume in IBM terms) is stored on that disk in a flat system file called the Volume Table of Contents (VTOC). The VTOC holds all file details. Later, a hierarchical directory structure was added with the System Catalog, which links files (datasets) to volumes. If a user asks for a file on an offline volume and has permission, the system tries to mount the volume. Cataloged and uncataloged files can be accessed using VTOC information if the volume ID is given. The VTOC was later indexed for faster access.
Conversational Monitor System
Main article: CMS file system
The IBM Conversational Monitor System (CMS) in VM/370 uses a separate flat file system for each virtual disk (minidisk). File data and control info are mixed. The key is a record called the Master File Directory (MFD), always in the fourth block on the disk. CMS originally used 800-byte blocks, but later versions used up to 4K blocks. Getting a data record needs two steps, where the file’s directory entry (called a File Status Table (FST) entry) points to blocks with lists of record addresses.
AS/400 file system
Data on the AS/400 and later systems is stored in a single-level store with many types of objects. Files and folders are part of this, along with support for an integrated relational database.
Other file systems
- RSRE FLEX file system - written in ALGOL 68
- The file system of the Michigan Terminal System (MTS) has special features: (i) it provides "line files" where each line has its own length and number, and lines can be added, changed, or removed without reading the whole file; (ii) files can be shared with programs and users; and (iii) it has a strong system for protecting files.
- TempleOS uses RedSea, a file system made by Terry A. Davis.
Limitations
File systems can only store a certain amount of data. This limit is set when the file system is first made, based on the size of the storage device at that time. Storage devices get bigger very fast—almost doubling in size each year. Because of this, older file systems can’t handle the bigger storage we use today.
As storage grows, file systems need to get more complicated to manage all that data. File systems made in the 1980s for small devices wouldn’t work well with today’s huge storage systems. And modern file systems might be too complicated for very old devices.
Sometimes we need to change the file system we use. We might need more space, better speed, or to work with a different operating system. There are two ways to change a file system: we can change it directly on the device, or we can move all the data to a new file system. Moving data often needs extra space.
Different file systems have different rules. For example, they may have different limits on how long file names can be or how many folders deep a file’s path can go. Moving files with very long names or deep paths between different file systems can sometimes cause problems, depending on the tool used to copy the files.
Related articles
This article is a child-friendly adaptation of the Wikipedia article on File system, available under CC BY-SA 4.0.
Images from Wikimedia Commons. Tap any image to view credits and license.
Safekipedia