The Unix file system (UFS) is a family of
file systems supported by many
Unix
Unix (, ; trademarked as UNIX) is a family of multitasking, multi-user computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, a ...
and
Unix-like
A Unix-like (sometimes referred to as UN*X, *nix or *NIX) operating system is one that behaves in a manner similar to a Unix system, although not necessarily conforming to or being certified to any version of the Single UNIX Specification. A Uni ...
operating systems. It is a distant descendant of the original filesystem used by
Version 7 Unix
Version 7 Unix, also called Seventh Edition Unix, Version 7 or just V7, was an important early release of the Unix operating system. V7, released in 1979, was the last Bell Laboratories release to see widespread distribution before the commerc ...
.
Design
A UFS volume is composed of the following parts:
* A few blocks at the beginning of the partition reserved for
boot blocks (which must be initialized separately from the filesystem)
* A superblock, containing a
magic number identifying this as a UFS filesystem, and some other vital numbers describing this filesystem's geometry and statistics and behavioral tuning parameters
* A collection of cylinder groups. Each cylinder group has the following components:
** A backup copy of the superblock
** A cylinder group header, with statistics, free lists, etc., about this cylinder group, similar to those in the superblock
** A number of
inode
An inode (index node) is a data structure in a Unix-style file system that describes a file-system object such as a file or a directory. Each inode stores the attributes and disk block locations of the object's data. File-system object attribu ...
s, each containing file attributes
** A number of
data blocks
Inodes are numbered sequentially, starting at 0. Inode 0 is reserved for unallocated directory entries, inode 1 was the inode of the bad block file in historical UNIX versions, followed by the inode for the
root directory
In a Computing, computer file system, and primarily used in the Unix and Unix-like operating systems, the root directory is the first or top-most Directory (computing), directory in a hierarchy. It can be likened to the trunk of a Tree (data st ...
, which is always inode 2 and the inode for the lost+found directory which is inode 3.
Directory files contain only the list of filenames in the directory and the inode associated with each file. All file
metadata
Metadata (or metainformation) is "data that provides information about other data", but not the content of the data itself, such as the text of a message or the image itself. There are many distinct types of metadata, including:
* Descriptive ...
is kept in the inode.
History and evolution
Early Unix filesystems were referred to simply as ''FS''. FS only included the boot block, superblock, a clump of
inode
An inode (index node) is a data structure in a Unix-style file system that describes a file-system object such as a file or a directory. Each inode stores the attributes and disk block locations of the object's data. File-system object attribu ...
s, and the data blocks. This worked well for the small disks early Unixes were designed for, but as technology advanced and disks grew larger, moving the head back and forth between the clump of inodes and the data blocks they referred to caused
thrashing.
Marshall Kirk McKusick
Marshall Kirk McKusick (born January 19, 1954) is an American computer scientist, known for his extensive work on BSD UNIX, from the 1980s to FreeBSD in the present day. He served on the board of the USENIX Association from 1986 to 1992 and aga ...
, then a
Berkeley graduate student, optimized the V7 FS layout to create
BSD 4.2's FFS (Fast File System) by inventing cylinder groups, which break the disk up into smaller chunks, with each group having its own inodes and data blocks.
The intent of BSD FFS is to try to localize associated data blocks and metadata in the same cylinder group and, ideally, all of the contents of a directory (both data and metadata for all the files) in the same or nearby cylinder group, thus reducing
fragmentation caused by scattering a directory's contents over a whole disk.
Some of the performance parameters in the superblock included number of tracks and sectors, disk rotation speed, head speed, and alignment of the sectors between tracks. In a fully optimized system, the head could be moved between close tracks to read scattered sectors from alternating tracks while waiting for the platter to spin around.
As disks grew larger and larger, sector-level optimization became obsolete (especially with disks that used linear sector numbering and variable sectors per track). With larger disks and larger files, fragmented reads became more of a problem. To combat this, BSD originally increased the filesystem block size from one sector to 1 K in 4.0 BSD; and, in FFS, increased the filesystem block size from 1 K to 8 K. This has several effects. The chance of a file's sectors being contiguous is much greater. The amount of overhead to list the file's blocks is reduced, while the number of bytes representable by any given number of blocks is increased.
Larger disk sizes are also possible, since the maximum number of blocks is limited by a fixed bit-width block number. However, with larger block sizes, disks with many small files will waste space, since each file must occupy at least one block. Because of this, BSD added ''block-level fragmentation'', also called
block suballocation, tail merging, or tail packing, where the last partial block of data from several files may be stored in a single "fragment" block instead of multiple mostly empty blocks.
The work on Berkeley FFS was widely adopted by other Unix vendors, and the family of filesystems derived from it are collectively known as UFS.
Implementations
Vendors of some proprietary Unix systems, such as
SunOS
SunOS is a Unix-branded operating system developed by Sun Microsystems for their workstation and server computer systems from 1982 until the mid-1990s. The ''SunOS'' name is usually only used to refer to versions 1.0 to 4.1.4, which were based ...
/
Solaris
Solaris is the Latin word for sun.
It may refer to:
Arts and entertainment Literature, television and film
* ''Solaris'' (novel), a 1961 science fiction novel by Stanisław Lem
** ''Solaris'' (1968 film), directed by Boris Nirenburg
** ''Sol ...
,
System V Release 4,
HP-UX
HP-UX (from "Hewlett Packard Unix") is a proprietary software, proprietary implementation of the Unix operating system developed by Hewlett Packard Enterprise; current versions support HPE Integrity Servers, based on Intel's Itanium architect ...
, and
Tru64 UNIX
Tru64 UNIX is a discontinued 64-bit UNIX operating system for the DEC Alpha, Alpha instruction set architecture (ISA), currently owned by Hewlett-Packard (HP). Previously, Tru64 UNIX was a product of Compaq, and before that, Digital Equipment Corp ...
, and open Unix derived systems like
illumos
Illumos (stylized as "illumos") is a partly free and open-source Unix operating system. It has been developed since 2010 and is based on OpenSolaris, after the discontinuation of that product by Oracle. It comprises a kernel, device driver ...
, have adopted UFS. Most of them adapted UFS to their own uses, adding proprietary extensions that may not be recognized by other vendors' versions of Unix. Many have continued to use the original block size and data field widths as the original UFS, so some degree of read compatibility remains across platforms. Compatibility between implementations as a whole is spotty at best.
As of
Solaris 7,
Sun Microsystems
Sun Microsystems, Inc., often known as Sun for short, was an American technology company that existed from 1982 to 2010 which developed and sold computers, computer components, software, and information technology services. Sun contributed sig ...
included UFS Logging, which brought
filesystem journaling to UFS, which is still available in current versions of Solaris and illumos. Solaris UFS also has extensions for large files and large disks and other features.
In 4.4BSD and
BSD
The Berkeley Software Distribution (BSD), also known as Berkeley Unix or BSD Unix, is a discontinued Unix operating system developed and distributed by the Computer Systems Research Group (CSRG) at the University of California, Berkeley, beginni ...
Unix systems derived from it, such as
FreeBSD
FreeBSD is a free-software Unix-like operating system descended from the Berkeley Software Distribution (BSD). The first version was released in 1993 developed from 386BSD, one of the first fully functional and free Unix clones on affordable ...
,
NetBSD
NetBSD is a free and open-source Unix-like operating system based on the Berkeley Software Distribution (BSD). It was the first open-source BSD descendant officially released after 386BSD was fork (software development), forked. It continues to ...
,
OpenBSD
OpenBSD is a security-focused operating system, security-focused, free software, Unix-like operating system based on the Berkeley Software Distribution (BSD). Theo de Raadt created OpenBSD in 1995 by fork (software development), forking NetBSD ...
, and
DragonFly BSD
DragonFly BSD is a free and open-source Unix-like operating system forked from FreeBSD 4.8. Matthew Dillon, an Amiga developer in the late 1980s and early 1990s and FreeBSD developer between 1994 and 2003, began working on DragonFly BSD in ...
, the implementation of UFS1 and UFS2 is split into two layers: an upper layer that provides the directory structure and supports metadata (permissions, ownership, etc.) in the inode structure, and lower layers that provide data containers implemented as inodes. This was done to support both the traditional FFS and the
LFS log-structured file system with shared code for common functions. The upper layer is called "UFS", and the lower layers are called "FFS" and "LFS". In some of those systems, the term "FFS" is used for the combination of the FFS lower layer and the UFS upper layer, and the term "LFS" is used for the combination of the LFS lower layer and the UFS upper layer.
Kirk McKusick implemented block reallocation, a technique that reorders the blocks in the file system just before the writes are done to reduce fragmentation and control file system aging. He also implemented
soft updates
Soft updates is an approach to maintaining file system metadata integrity in the event of a crash or power outage. Soft updates work by tracking and enforcing dependencies among updates to file system metadata. Soft updates are an alternative t ...
, a mechanism that maintains the file system consistency without limiting the performance in the way the traditional sync mode did. This has the side effect of reducing the requirement of file system checking after a crash or power failure. To overcome the remaining issues after a failure, a background fsck utility was introduced.
In UFS2, Kirk McKusick and
Poul-Henning Kamp
Poul-Henning Kamp () is a Danish computer software developer known for work on various projects including FreeBSD and Varnish cache, Varnish. He currently resides in Slagelse, Denmark.
Involvement in the FreeBSD project
Poul-Henning Kamp has bee ...
extended the FreeBSD FFS and UFS layers to add 64-bit block pointers (allowing volumes to grow up to 8
zebibytes), variable-sized blocks (similar to
extents), extended flag fields, additional 'birthtime' stamps, extended attribute support and POSIX1.e ACLs. UFS2 became the supported UFS version starting with FreeBSD 5.0. FreeBSD also introduced soft updates and the ability to make file system
snapshots for both UFS1 and UFS2. These have since been ported to NetBSD, but eventually soft updates (called soft dependencies in NetBSD) was removed from NetBSD 6.0 in favor of the less complex file system journaling mechanism called
WAPBL (also referred as logging), which was added to FFS in NetBSD 5.0. OpenBSD supported soft updates from version 2.9 until support was dropped in version 7.4, and it has had UFS2 (FFS2) support (no ACLs) since version 4.2. OpenBSD has now made UFS2 the default UFS version and will be included with the 6.7 release. Since FreeBSD 7.0, UFS also supports
filesystem journaling using the gjournal
GEOM provider. FreeBSD 9.0 adds support for lightweight journaling on top of soft updates (SU+J), which greatly reduces the need for background fsck, and NFSv4 ACLs.
FreeBSD, NetBSD, OpenBSD, and DragonFly BSD also include the
Dirhash system, developed by Ian Dowse. This system maintains an in-memory hash table to speed up directory lookups. Dirhash alleviates a number of performance problems associated with large directories in UFS.
Linux
Linux ( ) is a family of open source Unix-like operating systems based on the Linux kernel, an kernel (operating system), operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically package manager, pac ...
includes a UFS implementation for binary compatibility at the read level with other Unixes, but since there is no standard implementation for the vendor extensions to UFS, Linux does not have full support for writing to UFS. The native Linux
ext2
ext2, or second extended file system, is a file system for the Linux kernel (operating system), kernel. It was initially designed by French software developer Rémy Card as a replacement for the extended file system (ext). Having been designed ...
filesystem was inspired by UFS1 but does not support fragments and there are no plans to implement soft updates. (In some 4.4BSD-derived systems, the UFS layer can use an ext2 layer as a container layer, just as it can use FFS and LFS.)
NeXTStep
NeXTSTEP is a discontinued object-oriented, multitasking operating system based on the Mach kernel and the UNIX-derived BSD. It was developed by NeXT, founded by Steve Jobs, in the late 1980s and early 1990s and was initially used for its ...
, which was BSD-derived, also used a version of UFS. In
Apple
An apple is a round, edible fruit produced by an apple tree (''Malus'' spp.). Fruit trees of the orchard or domestic apple (''Malus domestica''), the most widely grown in the genus, are agriculture, cultivated worldwide. The tree originated ...
's
Mac OS X
macOS, previously OS X and originally Mac OS X, is a Unix, Unix-based operating system developed and marketed by Apple Inc., Apple since 2001. It is the current operating system for Apple's Mac (computer), Mac computers. With ...
, it was available as an alternative to
HFS+
HFS Plus or HFS+ (also known as Mac OS Extended or HFS Extended) is a journaling file system developed by Apple Inc. It replaced the Hierarchical File System (HFS) as the primary file system of Apple computers with the 1998 release of Mac OS 8. ...
, their proprietary filesystem. However, as of
Mac OS X Leopard
Mac OS X Leopard (version 10.5) is the sixth software versioning, major release of macOS, Apple Inc., Apple's desktop and server operating system for Macintosh computers. Leopard was released on October 26, 2007, as the successor of Mac OS X Ti ...
, it was no longer possible to install Mac OS X on a UFS-formatted volume. In addition, one cannot upgrade older versions of Mac OS X installed on UFS-formatted volumes to Leopard; upgrading requires reformatting the startup volume. There was a 4 GB file limit for disks formatted as UFS in Mac OS X. As of
Mac OS X Lion
OS X Lion, also known as Mac OS X Lion, (version 10.7) is the eighth major release of macOS, Apple's desktop and server operating system for Mac computers.
A preview of OS X 10.7 Lion was publicly shown at the "Back to the Mac" Apple Speci ...
, UFS support was completely dropped.
See also
*
Comparison of file systems
The following tables compare general and technical information for a number of file systems.
General information
Metadata
All widely used file systems record a last modified time stamp (also known as "mtime"). It is not included i ...
References
Citations
Bibliography
*
*
*
*
*
*
*
External links
*
*
The Solaris UFS File System see als
USF(sic)/UFS2 formatLocality and The Fast File System{{Filesystem
Berkeley Software Distribution
Disk file systems
Unix file system technology