# Unix File System

> Mediated Wiki article. Canonical URL: https://mediated.wiki/source/Unix_File_System
> Markdown URL: https://mediated.wiki/source/Unix_File_System.md
> Source: https://en.wikipedia.org/wiki/Unix_File_System
> Source revision: 1350778367
> License: Creative Commons Attribution-ShareAlike 4.0 International (https://creativecommons.org/licenses/by-sa/4.0/)

File system used by many Unix and Unix-like operating systems

This article is about the file system implementation in some Unix and BSD operating systems. For general Unix file system principles, see [Unix filesystem](/source/Unix_filesystem).

UFS Developer(s) CSRG Full name UNIX file system Introduced with 4.2BSD Structures Directory contents tables Limits Max volume size 273 bytes (8 ZiB) Max file size 273 bytes (8 ZiB) Max filename length 255 bytes Features Dates recorded UFS1 and UFS2: last access time (atime), last modified time (mtime), last inode change time (ctime), UFS2: inode creation time (birthtime)[1] Date range UFS1: December 14, 1901–January 18, 2038, UFS2: 64-bit signed integer offset from epoch[1] Date resolution UFS1 and UFS2: Nanosecond[1] Other Supported operating systems A/UX, DragonFly BSD, FreeBSD, FreeNAS, NAS4Free, HP-UX, NetBSD, NeXTSTEP, Linux, OpenBSD, illumos, Solaris, SunOS, Tru64 UNIX, UNIX System V, Orbis OS, and others

The **Unix file system** (**UFS**) is a family of [file systems](/source/File_system) supported by many [Unix](/source/Unix) and [Unix-like](/source/Unix-like) operating systems. It is a distant descendant of the original filesystem used by [Version 7 Unix](/source/Version_7_Unix).

## Design

A UFS volume is composed of the following parts:

- A few blocks at the beginning of the partition reserved for [boot blocks](/source/Bootstrapping_(computing)) (which must be initialized separately from the filesystem)

- A superblock, containing a [magic number](/source/Magic_number_(programming)) 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 [inodes](/source/Inode), each containing file attributes - A number of [data blocks](/source/Block_(data_storage))

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](/source/Root_directory), 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](/source/Metadata_(computing)) 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 [inodes](/source/Inode), 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](/source/Hard_disk_drive_performance_characteristics#Seek_time). [Marshall Kirk McKusick](/source/Marshall_Kirk_McKusick), then a [Berkeley](/source/University_of_California%2C_Berkeley) graduate student, optimized the V7 FS layout to create [BSD 4.2](/source/4.2BSD)'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.[2][3]

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](/source/File_system_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](/source/Block_suballocation), where the last partial block of data from several files may be stored in a single "fragment" block instead of multiple mostly empty blocks.[4]

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](/source/SunOS) / [Solaris](/source/Solaris_(operating_system)), [System V Release 4](/source/System_V_Release_4), [HP-UX](/source/HP-UX), and [Tru64 UNIX](/source/Tru64_UNIX), and open Unix derived systems like [illumos](/source/Illumos), have adopted UFS.[*[citation needed](https://en.wikipedia.org/wiki/Wikipedia:Citation_needed)*]

As of [Solaris 7](/source/Solaris_7), [Sun Microsystems](/source/Sun_Microsystems) included UFS Logging, which brought [filesystem journaling](/source/Journaling_file_system) to UFS, which is still available in current versions of Solaris and illumos.[5] Solaris UFS also has extensions for large files and large disks and other features.

In 4.4BSD and [BSD](/source/Berkeley_Software_Distribution) Unix systems derived from it, such as [FreeBSD](/source/FreeBSD), [NetBSD](/source/NetBSD), [OpenBSD](/source/OpenBSD), and [DragonFly BSD](/source/DragonFly_BSD), 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](/source/Log-structured_File_System_(BSD)) 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.

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](/source/Soft_updates), 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, McKusick and [Poul-Henning Kamp](/source/Poul-Henning_Kamp) extended the FreeBSD FFS and UFS layers to add 64-bit block pointers (allowing volumes to grow up to 8 [zebibytes](/source/Zebibyte)), variable-sized blocks (similar to [extents](/source/Extent_(file_systems))), 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](/source/Snapshot_(computer_storage)) 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](/source/WAPBL) (also referred as logging), which was added to FFS in NetBSD 5.0. OpenBSD supported soft updates from version 2.9[6] until support was dropped in version 7.4,[7] and it has had UFS2 (FFS2) support (no ACLs) since version 4.2.[8] OpenBSD made UFS2 the default UFS version with the 6.7 release.[9] Since FreeBSD 7.0, UFS also supports [filesystem journaling](/source/Journaling_file_system) using the gjournal [GEOM](/source/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](/source/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.[*[citation needed](https://en.wikipedia.org/wiki/Wikipedia:Citation_needed)*]

[NeXTStep](/source/NeXTStep), which was BSD-derived, also used a version of UFS. In [Apple](/source/Apple_Inc.)'s [Mac OS X](/source/MacOS), it was available as an alternative to [HFS+](/source/HFS_Plus), their proprietary filesystem. However, as of [Mac OS X Leopard](/source/Mac_OS_X_Leopard), 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.[10] There was a 4 GB file limit for disks formatted as UFS in Mac OS X. As of [Mac OS X Lion](/source/Mac_OS_X_Lion), UFS support was completely dropped.[11]

## See also

- [Comparison of file systems](/source/Comparison_of_file_systems)

## References

### Citations

1. ^ [***a***](#cite_ref-dinode_1-0) [***b***](#cite_ref-dinode_1-1) [***c***](#cite_ref-dinode_1-2) ["\[base\] Contents of /Head/Sys/Ufs/Ufs/Dinode.h"](https://svnweb.freebsd.org/base/head/sys/ufs/ufs/dinode.h?revision=313780&view=markup).

1. **[^](#cite_ref-2)** ["Open Sources: Voices from the Open Source Revolution"](https://www.oreilly.com/openbook/opensources/book/kirkmck.html). 29 March 1999.

1. **[^](#cite_ref-3)** McKusick, K M; Joy, W; Leffler, S; Fabry, R (August 1984). ["A Fast File System for UNIX"](https://www.cs.cornell.edu/Courses/cs614/2003SP/papers/KJL84.pdf) (PDF). *ACM Transactions on Computer Systems*. **2** (3): 181–197. [doi](/source/Doi_(identifier)):[10.1145/989.990](https://doi.org/10.1145%2F989.990). [S2CID](/source/S2CID_(identifier)) [222285164](https://api.semanticscholar.org/CorpusID:222285164). Retrieved 2013-04-08.

1. **[^](#cite_ref-4)** Allen, Hervey (2005-06-20). ["UFS2 and Soft Updates make for a powerful combination"](http://ws.edu.isoc.org/workshops/2005/ccTLD-Nairobi/day1/freebsd/intro-freebsd-additional-topics-1up.pdf) (PDF). *Introduction to FreeBSD, PacNOG I Workshop, Additional Topics*. Network Startup Resource Center. p. 23. Retrieved 2013-04-08.

1. **[^](#cite_ref-5)** ["UFS Logging"](https://docs.oracle.com/cd/E19253-01/817-5093/fsoverview-43/index.html). *Oracle Documentation*. Retrieved 2022-09-27.

1. **[^](#cite_ref-6)** ["OpenBSD 2.9 Release"](http://www.openbsd.org/29.html). [OpenBSD](/source/OpenBSD). 2001-06-01. Retrieved 2013-04-08.

1. **[^](#cite_ref-7)** ["Soft updates disabled for future VFS work"](https://undeadly.org/cgi?action=article;sid=20230706044554). [OpenBSD Journal](/source/OpenBSD_Journal). 2023-07-05. Retrieved 2024-03-09.

1. **[^](#cite_ref-8)** ["OpenBSD 4.2 Release"](http://www.openbsd.org/42.html). OpenBSD. 2007-11-01. Retrieved 2013-04-08.

1. **[^](#cite_ref-9)** ["Make FFS2 the default filesystem"](https://marc.info/?l=openbsd-cvs&m=158609976014693&w=2). OpenBSD. 2020-04-05. Retrieved 2020-04-07.

1. **[^](#cite_ref-10)** ["Mac OS X 10.5 Leopard: Installing on a UFS-formatted volume"](https://web.archive.org/web/20200328123218/https://support.apple.com/en-us/HT2316). *Apple Support*. 2012-06-12. Archived from [the original](https://support.apple.com/en-us/HT2316) on 2020-03-28.

1. **[^](#cite_ref-11)** ["Lion won't mount any disk images with the built-in utility or Disk Utility"](https://discussions.apple.com/message/15668353). *Apple Support Communities*. [Apple, Inc](/source/Apple%2C_Inc). 2011-08-05. Retrieved 2013-12-24.

### Bibliography

- [Marshall Kirk McKusick](/source/Marshall_Kirk_McKusick), [William N. Joy](/source/William_N._Joy), Samuel J. Leffler and Robert S. Fabry. [*A Fast File System for UNIX*](https://www.cs.berkeley.edu/~brewer/cs262/FFS.pdf) (PDF) (Technical report). Computer Systems Research Group, Computer Science Division, Department of Electrical Engineering and Computer Science, [University of California, Berkeley](/source/University_of_California%2C_Berkeley). Retrieved 2013-04-08.{{[cite tech report](https://en.wikipedia.org/wiki/Template:Cite_tech_report)}}: CS1 maint: multiple names: authors list ([link](https://en.wikipedia.org/wiki/Category:CS1_maint:_multiple_names:_authors_list))

- Marshall Kirk McKusick, William N. Joy, Samuel J. Leffler and Robert S. Fabry (August 1984). ["A Fast File System for UNIX"](https://www.cs.cornell.edu/Courses/cs614/2003SP/papers/KJL84.pdf) (PDF). *ACM Transactions on Computer Systems*. **2** (3): 181–197. [doi](/source/Doi_(identifier)):[10.1145/989.990](https://doi.org/10.1145%2F989.990). [S2CID](/source/S2CID_(identifier)) [222285164](https://api.semanticscholar.org/CorpusID:222285164). Retrieved 2013-04-08.{{[cite journal](https://en.wikipedia.org/wiki/Template:Cite_journal)}}: CS1 maint: multiple names: authors list ([link](https://en.wikipedia.org/wiki/Category:CS1_maint:_multiple_names:_authors_list))

- Marshall Kirk McKusick; Keith Bostic; Michael J. Karels & John S. Quarterman (1996). "Local Filesystems; Local Filestores". *The Design and Implementation of the 4.4BSD Operating System*. [Addison-Wesley](/source/Addison-Wesley). [ISBN](/source/ISBN_(identifier)) [0-201-54979-4](https://en.wikipedia.org/wiki/Special:BookSources/0-201-54979-4).

- Marshall Kirk McKusick & Gregory R. Ganger (June 1999). ["Soft Updates: A Technique for Eliminating Most Synchronous Writes in the Fast Filesystem"](http://static.usenix.org/publications/library/proceedings/usenix99/full_papers/mckusick/mckusick.pdf) (PDF). *Proceedings of the FREENIX Track: 1999 USENIX Annual Technical Conference*. pp. 1–18. Retrieved 2013-04-08.

- Marshall Kirk McKusick (February 2002). ["Running "fsck" in the Background"](http://static.usenix.org/publications/library/proceedings/bsdcon02/mckusick/mckusick_html/index.html). *Proceedings of the BSDCon 2002*. pp. 55–64. Retrieved 2013-04-08.

- Marshall Kirk McKusick (September 2003). ["Enhancements to the Fast Filesystem To Support Multi-Terabyte Storage Systems"](https://www.usenix.org/legacy/events/bsdcon03/tech/full_papers/mckusick/mckusick_html/). *Proceedings of the BSDCon 2003*. Retrieved 2019-02-07.

- Richard McDougall; Jim Mauro (2006). "15: The UFS File System". [*Solaris Internals: Solaris 10 and OpenSolaris Kernel Architecture*](http://ptgmedia.pearsoncmg.com/images/0131482092/samplechapter/mcdougall_ch15.pdf) (PDF) (2 ed.). Sun Microsystems Press/Prentice Hall. [ISBN](/source/ISBN_(identifier)) [0-13-148209-2](https://en.wikipedia.org/wiki/Special:BookSources/0-13-148209-2).

## External links

- Jeroen C. van Gelderen (2003-04-23). ["Little UFS2 FAQ"](https://web.archive.org/web/20260206222305/https://lists.freebsd.org/pipermail/freebsd-current/2003-April/001444.html). [FreeBSD](/source/FreeBSD). Archived from [the original](https://lists.freebsd.org/pipermail/freebsd-current/2003-April/001444.html) on 2026-02-06. Retrieved 2013-04-08.

- ["Filesystems HOWTO: Other filesystems"](http://www.tldp.org/HOWTO/Filesystems-HOWTO-9.html#ss9.29). [The Linux Documentation Project](/source/The_Linux_Documentation_Project). 2007-01-27.

- [The Solaris UFS File System](https://www.informit.com/articles/article.aspx?p=605371&seqNum=2), [archived](https://web.archive.org/web/20250424055707/https://www.informit.com/articles/article.aspx?p=605371&seqNum=2). see also [\[1\]](http://ptgmedia.pearsoncmg.com/images/0131482092/samplechapter/mcdougall_ch15.pdf)

- [USF(sic)/UFS2 format](http://alter.org.ua/docs/fbsd/ufs/#sb)

- [Locality and The Fast File System](http://pages.cs.wisc.edu/~remzi/OSTEP/file-ffs.pdf)

v t e File systems Comparison of file systems distributed Unix filesystem Disk and non-rotating ADFS AdvFS Amiga FFS Amiga OFS APFS AthFS bcachefs BFS Be File System Boot File System Byte File System (z/VM) Btrfs CVFS CXFS DFS EFS Encrypting File System Extent File System Episode ext ext2 ext3 ext4 FAT exFAT Files-11 Fossil GPFS HAMMER HAMMER2 HFS (Classic Mac OS) HFS (MVS) HFS+ HPFS HTFS JFS LFS MFS Macintosh File System TiVo Media File System MINIX NetWare File System Next3 NILFS NILFS2 NSS NTFS OneFS OpenZFS PFS QFS QNX4FS ReFS ReiserFS Reiser4 Reliance Reliance Nitro RFS SFS Shared File System (VM) Smart File System SNFS Soup (Apple) Tux3 UBIFS UFS/UFS2 soft updates WAPBL VxFS WAFL Xiafs XFS Xsan zFS (z/OS) ZFS (Sun) Optical disc HSF ISO 9660 ISO 13490 UDF Flash memory and SSD APFS FAT exFAT TFAT EROFS F2FS JFS NVFS host-side wear leveling CHFS JFFS JFFS2 LogFS NILFS NILFS2 YAFFS UBIFS Distributed parallel BeeGFS Ceph CXFS GFS2 Google File System OCFS2 OrangeFS PVFS QFS Xsan more... NAS 9P AFS (OpenAFS) AFP Coda DFS Google File System GPFS Lustre NCP NFS POHMELFS Hadoop SMB (CIFS) SSHFS more... Specialized Aufs AXFS Boot File System Compact Disc File System cramfs Davfs2 EROFS FTPFS FUSE Lnfs LTFS NOVA MVFS SquashFS UMSDOS OverlayFS UnionFS Pseudo configfs devfs debugfs kernfs procfs specfs sysfs tmpfs WinFS Encrypted eCryptfs EncFS EFS Rubberhose SSHFS ZFS Types Clustered Global Grid Self-certifying Flash Journaling Log-structured Object Record-oriented Semantic Steganographic Synthetic Versioning Features Case preservation Copy-on-write Data deduplication Data scrubbing Execute in place Extent File attribute Extended file attributes File change log Fork Inode Links Hard Symbolic Access control Access-control list Filesystem-level encryption Permissions Modes Sticky bit Interfaces File manager File system API Installable File System Virtual file system Lists Cryptographic Default Log-structured Layouts Master Boot Record GUID Partition Table Apple Partition Map

---
Adapted from the Wikipedia article [Unix File System](https://en.wikipedia.org/wiki/Unix_File_System) by Wikipedia contributors ([contributor history](https://en.wikipedia.org/wiki/Unix_File_System?action=history)). Available under [Creative Commons Attribution-ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/). Changes may have been made.
