UFS is the Berkeley fast file system and its descendants, used by BSD systems (FreeBSD, NetBSD, OpenBSD), Solaris and older commercial Unix. FreeBSD still uses UFS2 on some installs, but the family is mostly legacy elsewhere, and several on-disk variants differ by byte order and layout.
Overview
UFS divides the volume into cylinder groups, each with a group summary, inode bitmap and block bitmap. The superblock describes geometry and holds fragment and block sizes. UFS1 uses 32-bit block pointers; UFS2 uses 64-bit pointers and extended inodes. Byte order depends on the host that created the volume, so the implementation detects it.
History
Marshall Kirk McKusick developed the Fast File System for 4.2BSD (1983).
UFS2 appeared in FreeBSD 5.0 (2003).
Structures
Offsets are in bytes from the start of the structure named in each heading. Field names are descriptive and are not an official specification. Fixed-width integers are shown as u/i (unsigned/signed) followed by bit width and byte order.
Parse Directory
Offset
Size
Type
Field
Notes
position
4
u32 LE/BE
Inode
position + 4
2
u16 LE/BE
Record Length
Scan Inode Tables
Offset
Size
Type
Field
Notes
0x0
2
u16 LE/BE
Ode
0x2
2
i16 LE/BE
Links
Scan Slack
Offset
Size
Type
Field
Notes
position
4
u32 LE/BE
Inode
position + 4
2
u16 LE/BE
Record Length
Type And Name Length
Offset
Size
Type
Field
Notes
position + 6
2
u16 LE/BE
–
position + 6
1
u8
–
position + 7
1
u8
–
Walk Indirect
Offset
Size
Type
Field
Notes
i * width
8
i64 LE/BE
Child
i * width
4
i32 LE/BE
Child
Backup Index
Offset
Size
Type
Field
Notes
0x4
4
u32 LE/BE
–
0xC
4
u32 LE/BE
Group
Find Backup
Offset
Size
Type
Field
Notes
0x0
4
u32 LE
Little
0x0
4
u32 BE
Big
Try Parse
Offset
Size
Type
Field
Notes
0x4
4
u32 LE/BE
–
0xC
4
u32 LE/BE
–
0x14
4
u32 LE/BE
Fragments
0x60
4
u32 LE/BE
Free Offset
0x78
4
u32 LE/BE
Inode Blocks Initialized
0x84
4
u32 LE/BE
–
Parse
Offset
Size
Type
Field
Notes
0x0
2
u16 LE/BE
–
0x0
2
u16 LE/BE
Mode
0x2
2
i16 LE/BE
Links
0x4
4
u32 LE/BE
Uid
0x8
4
u32 LE/BE
Gid
0x8
8
u64 LE/BE
Size
0x10
8
u64 LE/BE
Size
0x10
4
u32 LE/BE
Accessed
0x14
4
i32 LE/BE
Accessed
0x18
8
u64 LE/BE
Blocks512
0x18
4
u32 LE/BE
Modified
0x1C
4
i32 LE/BE
Modified
0x20
8
i64 LE/BE
Accessed
0x20
4
u32 LE/BE
Changed
0x24
4
i32 LE/BE
Changed
0x28
8
i64 LE/BE
Modified
0x30
8
i64 LE/BE
Changed
0x38
8
i64 LE/BE
Created
0x40
4
i32 LE/BE
Modified
0x44
4
i32 LE/BE
Accessed
0x48
4
i32 LE/BE
Changed
0x4C
4
i32 LE/BE
Created
0x50
4
u32 LE/BE
Generation
0x58
4
u32 LE/BE
Flags
0x5C
4
u32 LE/BE
Ext Attribute Size
0x64
4
u32 LE/BE
Flags
0x68
4
u32 LE/BE
Blocks512
0x6C
4
u32 LE/BE
Generation
0x70
4
u32 LE/BE
Uid
0x74
4
u32 LE/BE
Gid
0xF4
4
u32 LE/BE
–
40 + i * 4
4
i32 LE/BE
–
88 + i * 4
4
i32 LE/BE
–
112 + i * 8
8
i64 LE/BE
–
208 + i * 8
8
i64 LE/BE
–
Parse
Offset
Size
Type
Field
Notes
0x8
4
i32 LE/BE
Sblkno
0xC
4
i32 LE/BE
Cblkno
0x10
4
i32 LE/BE
Iblkno
0x14
4
i32 LE/BE
Dblkno
0x18
4
i32 LE/BE
Old Cg Offset
0x1C
4
u32 LE/BE
Old Cg Mask
0x20
4
u32 LE/BE
Time
0x24
4
i32 LE/BE
Size
0x28
4
i32 LE/BE
Dsize
0x2C
4
i32 LE/BE
Ncg
0x30
4
i32 LE/BE
Bsize
0x34
4
i32 LE/BE
Fsize
0x38
4
i32 LE/BE
Frag
0x68
4
i32 LE/BE
Sbsize
0x74
4
i32 LE/BE
Nindir
0x78
4
i32 LE/BE
Inopb
0x90
4
u32 LE/BE
Id High
0x94
4
u32 LE/BE
Id Low
0xA0
4
i32 LE/BE
Cgsize
0xB8
4
i32 LE/BE
Ipg
0xBC
4
i32 LE/BE
Fpg
0xC0
4
i32 LE/BE
Ndir
0xC4
4
i32 LE/BE
Nbfree
0xC8
4
i32 LE/BE
Nifree
0xCC
4
i32 LE/BE
Nffree
0xD1
1
u8
Clean
0xD3
1
u8
Updated
0xD3
1
u8
Flags
0xD4
468
bytes
Mount Point
0x2A8
32
bytes
Volume Name
0x3E0
8
i64 LE/BE
Actual Location
0x3E8
8
i64 LE/BE
Primary Location
0x3F0
8
i64 LE/BE
Ndir
0x3F8
8
i64 LE/BE
Nbfree
0x400
8
i64 LE/BE
Nifree
0x408
8
i64 LE/BE
Nffree
0x430
8
i64 LE/BE
Time
0x438
8
i64 LE/BE
Size
0x440
8
i64 LE/BE
Dsize
0x518
4
u32 LE/BE
Stored Check Hash
0x51C
4
i32 LE/BE
Meta Check Hash
0x520
4
i32 LE/BE
Flags
0x528
4
i32 LE/BE
Max Symlink Length
0x52C
4
i32 LE/BE
Old Inode Format
1116 + i * 4
4
u32 LE/BE
–
Try Parse
Offset
Size
Type
Field
Notes
MagicOffset
4
u32 LE
Little
MagicOffset
4
u32 BE
Big
Other fields read
Read in
Offset
Size
Type
Field
Notes
Has Root Directory
0x0
2
u16 LE/BE
–
Constants
Ufs File System
Name
Value
Type
Notes
StrictUtf8
new(false, true)
UTF8Encoding
Ufs Byte Order
Name
Value
Type
Notes
Little
new(false)
UfsByteOrder
Big
new(true)
UfsByteOrder
Ufs Constants
Name
Value
Type
Notes
Ufs1Magic
0x00011954
uint
Ufs2Magic
0x19540119
uint
CylinderGroupMagic
0x00090255
uint
MagicOffset
1372
int
StructSize
1376
int
SuperblockSpace
8192
int
SuperblockLocations
[65536, 8192, 0, 262144]
long[]
Group0BackupLocations
[98304, 81920, 73728, 32768, 16384]
long[]
DirectBlocks
12
int
IndirectLevels
3
int
DirectoryChunk
512
int
RootInode
2
uint
WhiteoutInode
1
uint
fs_flags
Name
Value
Type
Notes
FlagUnclean
0x1
int
FlagSoftUpdates
0x2
int
FlagNeedsFsck
0x4
int
FlagJournaledSoftUpdates
0x8
int
FlagAcls
0x10
int
FlagMultiLabel
0x20
int
FlagGJournal
0x40
int
FlagUpdated
0x80
int
FlagNfs4Acls
0x100
int
FlagMetaCheckHash
0x200
int
FlagTrim
0x400
int
fs_metackhash
Name
Value
Type
Notes
CheckSuperblock
0x1
int
CheckCylinderGroup
0x2
int
CheckInode
0x4
int
Ufs Inode
Name
Value
Type
Notes
TypeMask
0xF000
int
TypeFifo
0x1000
int
TypeCharDevice
0x2000
int
TypeDirectory
0x4000
int
TypeBlockDevice
0x6000
int
TypeRegular
0x8000
int
TypeSymlink
0xA000
int
TypeSocket
0xC000
int
TypeWhiteout
0xE000
int
chflags(2)
Name
Value
Type
Notes
UfImmutable
0x2
uint
UfAppend
0x4
uint
UfSystem
0x80
uint
UfArchive
0x800
uint
UfReadOnly
0x1000
uint
UfHidden
0x8000
uint
SfImmutable
0x20000
uint
SfAppend
0x40000
uint
SfSnapshot
0x200000
uint
Struct
Name
Value
Type
Notes
TypeDirectory
4
byte
Ufs Module
Name
Value
Type
Notes
BackupSearchWindow
4 * 1024 * 1024
int
FreeBSD 13+ records where each copy was written.
Name
Value
Type
Notes
step
512
int
Implementation limits
Class
Name
Value
Notes
Ufs File System
MaxDirectoryBytes
256L * 1024 * 1024
Ufs File System
MaxBlocks
64L * 1024 * 1024
Ufs File System
MaxLostEntries
200_000
Ufs File System
MaxDirectoriesScanned
1_000_000
Ufs File System
MaxCachedGroups
256
Ufs File System
MaxSymlinkTarget
4096
Ufs Module
BackupSearchLimit
1L << 30
Entry Kind
Name
Value
Live
(next)
Unlinked
(next)
Structures and constants were extracted from the implementation. Prose sections are a summary from public sources; verify details before relying on them.