RU ru   Donate Donate www/www1/www2

USF/UFS2 format

(Sorry, under construction)

UFS - Unix File System
UFS2 - Advanced version of UFS

UFS2 advantages

  • 32-bit UID/GID
  • External Attributes support (e.g. ACL)

Partition structure

A filesystem consists of a number of cylinder groups. Each cylinder group has inodes and data.

A filesystem is described by its super-block, which in turn describes the cylinder groups. The super-block is critical data and is replicated in each cylinder group to protect against catastrophic loss. This is done at `newfs' time and the critical super-block data does not change, so the copies need not be referenced further unless disaster strikes.


Depending on the architecture and the media, the superblock may reside in any one of four places. For tiny media where every block counts, it is placed at the very front of the partition. Historically, UFS1 placed it 8K from the front to leave room for the disk label and a small bootstrap. For UFS2 it got moved to 64K from the front to leave room for the disk label and a bigger bootstrap, and for really piggy systems we check at 256K from the front if the first three fail. In all cases the size of the superblock will be SBLOCKSIZE (8K). All values are given in byte-offset form, so they do not imply a sector size.

LocationMedia/FS type
8192HDD, UFS1
65536HDD, UFS2

Super-block structure

Type Size Field name Description
int 324fs_firstfield historic filesystem linked list, used for incore super blocks
int 324fs_unused_1
int 324fs_sblknooffset of super-block in filesys
int 324fs_cblknooffset of cyl-block in filesys
int 324fs_iblknooffset of inode-blocks in filesys
int 324fs_dblknooffset of first data after cg
int 324fs_old_cgoffsetcylinder group offset in cylinder
int 324fs_old_cgmaskused to calc mod fs_ntrak
int 324fs_old_timelast time written
int 324fs_old_sizenumber of blocks in fs
int 324fs_old_dsizenumber of data blocks in fs
int 324fs_ncgnumber of cylinder groups
int 324fs_bsizesize of basic blocks in fs
int 324fs_fsizesize of frag blocks in fs
int 324fs_fragnumber of frags in a block in fs
these are configuration parameters
int 324fs_minfreeminimum percentage of free blocks
int 324fs_old_rotdelaynum of ms for optimal next block
int 324fs_old_rpsdisk revolutions per second
these fields can be computed from the others
int 324 fs_bmask blkoff calc of blk offsets
int 324fs_fmaskfragoff calc of frag offsets
int 324fs_bshiftlblkno calc of logical blkno
int 324fs_fshiftnumfrags calc number of frags
these are configuration parameters
int 324fs_maxcontigmax number of contiguous blks
int 324fs_maxbpgmax number of blks per cyl group
these fields can be computed from the others
int 324fs_fragshiftblock to frag shift
int 324fs_fsbtodbfsbtodb and dbtofsb shift constant
int 324fs_sbsizeactual size of super block
int 324*2fs_spare1[2]old fs_csmask,
old fs_csshift
int 324fs_nindirvalue of NINDIR
int 324fs_inopbvalue of INOPB
int 324fs_old_nspfvalue of NSPF
yet another configuration parameter
int 324fs_optimoptimization preference, see below
int 324fs_old_npsect# sectors/track including spares
int 324fs_old_interleavehardware sector interleave
int 324fs_old_trackskewsector 0 skew, per track
int 324*2fs_id[2]unique filesystem id
sizes determined by number of cylinder groups and their sizes
int 324fs_old_csaddrblk addr of cyl grp summary area
int 324fs_cssizesize of cyl grp summary area
int 324fs_cgsizecylinder group size
int 324fs_spare2old fs_ntrak
int 324fs_old_nsectsectors per track
int 324fs_old_spcsectors per cylinder
int 324fs_old_ncylcylinders in filesystem
int 324fs_old_cpgcylinders per group
int 324fs_ipginodes per group
int 324fs_fpgblocks per group * fs_frag
this data must be re-computed after crashes
struct csum???fs_old_cstotal cylinder summary information
these fields are cleared at mount time
int 81fs_fmodsuper block modified flag
int 81fs_cleanfilesystem is clean flag
int 81fs_ronlymounted read-only flag
int 81fs_flagssee FS_ flags below
uchar512fs_fsmnt[MAXMNTLEN]name mounted on
these fields retain the current block allocation info
int 324fs_cgrotorlast cg searched
void*124fs_ocsp[NOCSPTRS](???)padding (was list of fs_cs buffers)
u_int8_t*4fs_contigdirs(???) # of contiguously allocated dirs
struct csum*4fs_csp(???) cg summary info buffer for fs_cs
int 32*4fs_maxcluster(???) max cluster in each cyl group
uint 32*4fs_active(???) used by snapshots to track fs
int 324fs_old_cpccyl per cycle in postbl
int 324fs_maxbsizemaximum blocking factor permitted
int 648*17 (136)fs_sparecon64[17]old rotation block list head
int 648fs_sblockloclocation of standard superblock
struct csum_total???fs_cstotalcylinder summary information
int 648fs_timelast time written
int 648fs_sizenumber of blocks in fs
int 648fs_dsizenumber of data blocks in fs
int 648fs_csaddrblk addr of cyl grp summary area
int 648fs_pendingblocksblocks in process of being freed
int 324fs_pendinginodesinodes in process of being freed
int 324*20fs_snapinum[FSMAXSNAP]list of snapshot inode numbers
int 324fs_avgfilesizeexpected average file size
int 324fs_avgfpdirexpected # of files per directory
int 324fs_save_cgsizesave real cg size to use fs_bsize
int 324*27 (108)fs_sparecon32[27]reserved for future constants
int 324fs_contigsumsizesize of cluster summary array
int 324fs_maxsymlinklenmax length of an internal symlink
int 324fs_old_inodefmtformat of on-disk inodes
uint 648fs_maxfilesizemaximum representable file size
int 648fs_qbmask ~fs_bmask for use with 64-bit size
int 648fs_qfmask ~fs_fmask for use with 64-bit size
int 324fs_statevalidate fs_clean field
int 324fs_old_postblformatformat of positional layout tables
int 324fs_old_nrposnumber of rotational positions
int 324*2fs_spare5[2]old fs_postbloff
old fs_rotbloff
int 324fs_magicmagic number


A dinode contains all the meta-data associated with a UFS file. This structure defines the on-disk format of a dinode. Since this structure describes an on-disk structure, all its fields are defined by types with precise widths. Dinode format differs between UFS1 and UFS2.

UFS1 DInode structure

Type Size Field name Description
int 161di_modeIFMT, permissions; see below.
<< Back designed by Alter aka Alexander A. Telyatnikov powered by Apache+PHP under FBSD © 2002-2017