Unix File System
Orbis OS , and others |
---|
The Unix file system (UFS) is a family of file systems supported by many Unix and Unix-like operating systems. It is a distant descendant of the original filesystem used by 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(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 inodes, 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, 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
History and evolution
Early Unix filesystems were referred to simply as FS. FS only included the boot block, superblock, a clump of
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.[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
As of
In 4.4BSD and
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, 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
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 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 filesystem was inspired by UFS1 but does not support fragments and there are no plans to implement soft updates.[citation needed] (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.)
See also
References
Citations
- ^ a b c "[base] Contents of /Head/Sys/Ufs/Ufs/Dinode.h".
- ^ "Open Sources: Voices from the Open Source Revolution". 29 March 1999.
- S2CID 222285164. Retrieved 2013-04-08.
- ^ Allen, Hervey (2005-06-20). "UFS2 and Soft Updates make for a powerful combination" (PDF). Introduction to FreeBSD, PacNOG I Workshop, Additional Topics. Network Startup Resource Center. p. 23. Retrieved 2013-04-08.
- ^ "UFS Logging". Oracle Documentation. Retrieved 2022-09-27.
- ^ "OpenBSD 2.9 Release". OpenBSD. 2001-06-01. Retrieved 2013-04-08.
- ^ "OpenBSD 4.2 Release". OpenBSD. 2007-11-01. Retrieved 2013-04-08.
- ^ "Make FFS2 the default filesystem". OpenBSD. 2020-04-05. Retrieved 2020-04-07.
- Apple, Inc. 2012-06-12. Retrieved 2013-04-08.
- Apple, Inc. 2011-08-05. Retrieved 2013-12-24.
Bibliography
- William N. Joy, Samuel J. Leffler and Robert S. Fabry. A Fast File System for UNIX (PDF) (Technical report). Computer Systems Research Group, Computer Science Division, Department of Electrical Engineering and Computer Science, University of California, Berkeley. Retrieved 2013-04-08.)
{{cite tech report}}
: CS1 maint: multiple names: authors list (link - Marshall Kirk McKusick, William N. Joy, Samuel J. Leffler and Robert S. Fabry (August 1984). "A Fast File System for UNIX" (PDF). ACM Transactions on Computer Systems. 2 (3): 181–197. S2CID 222285164. Retrieved 2013-04-08.)
{{cite journal}}
: CS1 maint: multiple names: authors list (link - 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. ISBN 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" (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". 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". 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 (PDF) (2 ed.). Sun Microsystems Press/Prentice Hall. ISBN 0-13-148209-2.
External links
- Jeroen C. van Gelderen (2003-04-23). "Little UFS2 FAQ". FreeBSD. Retrieved 2013-04-08.
- "Filesystems HOWTO: Other filesystems". The Linux Documentation Project. 2007-01-27.
- The Solaris UFS File System, see also [1]
- USF(sic)/UFS2 format
- Locality and The Fast File System