xref: /illumos-gate/usr/src/man/man4fs/ufs.4fs (revision bbf215553c7233fbab8a0afdf1fac74c44781867)
1*bbf21555SRichard Lowe.\"
2*bbf21555SRichard Lowe.\" Copyright (c) 2009, Sun Microsystems, Inc. All Rights Reserved
3*bbf21555SRichard Lowe.\" Copyright 1989 AT&T
4*bbf21555SRichard Lowe.\" Copyright 2021 Oxide Computer Company
5*bbf21555SRichard Lowe.\"
6*bbf21555SRichard Lowe.\" The contents of this file are subject to the terms of the
7*bbf21555SRichard Lowe.\" Common Development and Distribution License (the "License").
8*bbf21555SRichard Lowe.\" You may not use this file except in compliance with the License.
9*bbf21555SRichard Lowe.\"
10*bbf21555SRichard Lowe.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11*bbf21555SRichard Lowe.\" or http://www.opensolaris.org/os/licensing.
12*bbf21555SRichard Lowe.\" See the License for the specific language governing permissions
13*bbf21555SRichard Lowe.\" and limitations under the License.
14*bbf21555SRichard Lowe.\"
15*bbf21555SRichard Lowe.\" When distributing Covered Code, include this CDDL HEADER in each
16*bbf21555SRichard Lowe.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17*bbf21555SRichard Lowe.\" If applicable, add the following below this CDDL HEADER, with the
18*bbf21555SRichard Lowe.\" fields enclosed by brackets "[]" replaced with your own identifying
19*bbf21555SRichard Lowe.\" information: Portions Copyright [yyyy] [name of copyright owner]
20*bbf21555SRichard Lowe.\"
21*bbf21555SRichard Lowe.Dd November 29, 2021
22*bbf21555SRichard Lowe.Dt UFS 4FS
23*bbf21555SRichard Lowe.Os
24*bbf21555SRichard Lowe.Sh NAME
25*bbf21555SRichard Lowe.Nm ufs
26*bbf21555SRichard Lowe.Nd UFS file system
27*bbf21555SRichard Lowe.Sh SYNOPSIS
28*bbf21555SRichard Lowe.In sys/param.h
29*bbf21555SRichard Lowe.In sys/types.h
30*bbf21555SRichard Lowe.In sys/fs/ufs_fs.h
31*bbf21555SRichard Lowe.In sys/fs/ufs_inode.h
32*bbf21555SRichard Lowe.Sh DESCRIPTION
33*bbf21555SRichard Lowe.Nm
34*bbf21555SRichard Loweis one of the primary default disk-based file systems for illumos.
35*bbf21555SRichard LoweThe UFS file system is hierarchical, starting with its root directory
36*bbf21555SRichard Lowe.Pq Pa /
37*bbf21555SRichard Loweand continuing downward through a number of directories.
38*bbf21555SRichard LoweThe root of a UFS file system is
39*bbf21555SRichard Lowe.Sy inode 2 .
40*bbf21555SRichard LoweA UFS file system's root contents replace the contents of the directory upon
41*bbf21555SRichard Lowewhich it is mounted.
42*bbf21555SRichard Lowe.Pp
43*bbf21555SRichard LoweSubsequent sections of this manpage provide details of the UFS file systems.
44*bbf21555SRichard Lowe.Ss State Flags Pq Fa fs_state , Fa fs_clean
45*bbf21555SRichard LoweUFS uses state flags to identify the state of the file system.
46*bbf21555SRichard Lowe.Fa fs_state
47*bbf21555SRichard Loweis
48*bbf21555SRichard Lowe.Dv FSOKAY -
49*bbf21555SRichard Lowe.Fa fs_time .
50*bbf21555SRichard Lowe.Fa fs_time
51*bbf21555SRichard Loweis the timestamp that indicates when the last system write occurred.
52*bbf21555SRichard Lowe.Fa fs_state
53*bbf21555SRichard Loweis updated whenever
54*bbf21555SRichard Lowe.Fa fs_clean
55*bbf21555SRichard Lowechanges.
56*bbf21555SRichard LoweSome
57*bbf21555SRichard Lowe.Fa fs_clean
58*bbf21555SRichard Lowevalues are:
59*bbf21555SRichard Lowe.Bl -tag -width Ds
60*bbf21555SRichard Lowe.It Dv FSCLEAN
61*bbf21555SRichard LoweIndicates an undamaged, cleanly unmounted file system.
62*bbf21555SRichard Lowe.It Dv FSACTIVE
63*bbf21555SRichard LoweIndicates a mounted file system that has modified data in memory.
64*bbf21555SRichard LoweA mounted file system with this state flag indicates that user data or metadata
65*bbf21555SRichard Lowewould be lost if power to the system is interrupted.
66*bbf21555SRichard Lowe.It Dv FSSTABLE
67*bbf21555SRichard LoweIndicates an idle mounted file system.
68*bbf21555SRichard LoweA mounted file system with this state flag indicates that neither user data nor
69*bbf21555SRichard Lowemetadata would be lost if power to the system is interrupted.
70*bbf21555SRichard Lowe.It Dv FSBAD
71*bbf21555SRichard LoweIndicates that this file system contains inconsistent file system data.
72*bbf21555SRichard Lowe.It Dv FSLOG
73*bbf21555SRichard LoweIndicates that the file system has logging enabled.
74*bbf21555SRichard LoweA file system with this flag set is either mounted or unmounted.
75*bbf21555SRichard LoweIf a file system has logging enabled, the only flags that it can have are
76*bbf21555SRichard Lowe.Dv FSLOG
77*bbf21555SRichard Loweor
78*bbf21555SRichard Lowe.Dv FSBAD .
79*bbf21555SRichard LoweA non-logging file system can have
80*bbf21555SRichard Lowe.Dv FSACTIVE ,
81*bbf21555SRichard Lowe.Dv FSSTABLE ,
82*bbf21555SRichard Loweor
83*bbf21555SRichard Lowe.Dv FSCLEAN .
84*bbf21555SRichard Lowe.Pp
85*bbf21555SRichard LoweIt is not necessary to run the
86*bbf21555SRichard Lowe.Sy fsck
87*bbf21555SRichard Lowecommand on unmounted file systems with a state of
88*bbf21555SRichard Lowe.Dv FSCLEAN ,
89*bbf21555SRichard Lowe.Dv FSSTABLE ,
90*bbf21555SRichard Loweor
91*bbf21555SRichard Lowe.Dv FSLOG .
92*bbf21555SRichard Lowe.Xr mount 2
93*bbf21555SRichard Lowereturns
94*bbf21555SRichard Lowe.Dv ENOSPC
95*bbf21555SRichard Loweif an attempt is made to mount a UFS file system with a state of
96*bbf21555SRichard Lowe.Dv FSACTIVE
97*bbf21555SRichard Lowefor read/write access.
98*bbf21555SRichard Lowe.Pp
99*bbf21555SRichard LoweAs an additional safeguard,
100*bbf21555SRichard Lowe.Fa fs_clean
101*bbf21555SRichard Loweshould be trusted only if
102*bbf21555SRichard Lowe.Fa fs_state
103*bbf21555SRichard Lowecontains a value equal to
104*bbf21555SRichard Lowe.Dv FSOKAY -
105*bbf21555SRichard Lowe.Fa fs_time ,
106*bbf21555SRichard Lowewhere
107*bbf21555SRichard Lowe.Dv FSOKAY
108*bbf21555SRichard Loweis a constant integer defined in the
109*bbf21555SRichard Lowe.Pa /usr/include/sys/fs/ufs_fs.h
110*bbf21555SRichard Lowefile.
111*bbf21555SRichard LoweOtherwise,
112*bbf21555SRichard Lowe.Fa fs_clean
113*bbf21555SRichard Loweis treated as though it contains the value of
114*bbf21555SRichard Lowe.Dv FSACTIVE .
115*bbf21555SRichard Lowe.El
116*bbf21555SRichard Lowe.Ss Extended Fundamental Types (EFT)
117*bbf21555SRichard LoweExtended Fundamental Types
118*bbf21555SRichard Lowe.Pq EFT
119*bbf21555SRichard Loweprovide 32-bit user ID
120*bbf21555SRichard Lowe.Pq UID ,
121*bbf21555SRichard Lowegroup ID
122*bbf21555SRichard Lowe.Pq GID ,
123*bbf21555SRichard Loweand device numbers.
124*bbf21555SRichard Lowe.Pp
125*bbf21555SRichard LoweIf a UID or GID contains an extended value, the short variable
126*bbf21555SRichard Lowe.Po
127*bbf21555SRichard Lowe.Fa ic_suid ,
128*bbf21555SRichard Lowe.Fa ic_sgid
129*bbf21555SRichard Lowe.Pc
130*bbf21555SRichard Lowecontains the value 65535 and the corresponding UID or GID is in
131*bbf21555SRichard Lowe.Fa ic_uid
132*bbf21555SRichard Loweor
133*bbf21555SRichard Lowe.Fa ic_gid .
134*bbf21555SRichard LoweBecause numbers for block and character devices are stored in the first direct
135*bbf21555SRichard Loweblock pointer of the inode
136*bbf21555SRichard Lowe.Pq Fa ic_db[0]
137*bbf21555SRichard Loweand the disk block addresses are already 32 bit values, no special encoding
138*bbf21555SRichard Loweexists for device numbers
139*bbf21555SRichard Lowe.Pq unlike UID or GID fields .
140*bbf21555SRichard Lowe.Ss Multiterabyte File System
141*bbf21555SRichard LoweA multiterabyte file system enables creation of a UFS file system up to
142*bbf21555SRichard Loweapproximately 16 terabytes of usable space, minus approximately one percent
143*bbf21555SRichard Loweoverhead.
144*bbf21555SRichard LoweA sparse file can have a logical size of one terabyte.
145*bbf21555SRichard LoweHowever, the actual amount of data that can be stored in a file is approximately
146*bbf21555SRichard Loweone percent less than one terabyte because of file system overhead.
147*bbf21555SRichard Lowe.Pp
148*bbf21555SRichard LoweOn-disk format changes for a multiterabyte UFS file system include:
149*bbf21555SRichard Lowe.Bl -bullet -offset indent
150*bbf21555SRichard Lowe.It
151*bbf21555SRichard LoweThe magic number in the superblock changes from
152*bbf21555SRichard Lowe.Dv FS_MAGIC
153*bbf21555SRichard Loweto
154*bbf21555SRichard Lowe.Dv MTB_UFS_MAGIC .
155*bbf21555SRichard LoweFor more information, see the
156*bbf21555SRichard Lowe.Pa /usr/include/sys/fs/ufs_fs.h
157*bbf21555SRichard Lowefile.
158*bbf21555SRichard Lowe.It
159*bbf21555SRichard LoweThe
160*bbf21555SRichard Lowe.Fa fs_logbno
161*bbf21555SRichard Loweunit is a sector for UFS that is less than 1 terabyte in
162*bbf21555SRichard Lowesize and fragments for a multiterabyte UFS file system.
163*bbf21555SRichard Lowe.El
164*bbf21555SRichard Lowe.Ss UFS Logging
165*bbf21555SRichard LoweUFS logging bundles the multiple metadata changes that comprise a complete UFS
166*bbf21555SRichard Loweoperation into a transaction.
167*bbf21555SRichard LoweSets of transactions are recorded in an on-disk log and are applied to the
168*bbf21555SRichard Loweactual UFS file system's metadata.
169*bbf21555SRichard Lowe.Pp
170*bbf21555SRichard LoweUFS logging provides two advantages:
171*bbf21555SRichard Lowe.Bl -enum
172*bbf21555SRichard Lowe.It
173*bbf21555SRichard LoweA file system that is consistent with the transaction log eliminates the
174*bbf21555SRichard Loweneed to run
175*bbf21555SRichard Lowe.Sy fsck
176*bbf21555SRichard Loweafter a system crash or an unclean shutdown.
177*bbf21555SRichard Lowe.It
178*bbf21555SRichard LoweUFS logging often provides a significant performance improvement.
179*bbf21555SRichard LoweThis is because a file system with logging enabled converts multiple updates to
180*bbf21555SRichard Lowethe same data into single updates, thereby reducing the number of overhead disk
181*bbf21555SRichard Loweoperations.
182*bbf21555SRichard Lowe.El
183*bbf21555SRichard Lowe.Pp
184*bbf21555SRichard LoweThe UFS log is allocated from free blocks on the file system and is sized at
185*bbf21555SRichard Loweapproximately 1 Mbyte per 1 Gbyte of file system, up to 256 Mbytes.
186*bbf21555SRichard LoweThe log size may be larger (up to a maximum of 512 Mbytes), depending upon the
187*bbf21555SRichard Lowenumber of cylinder groups present in the file system.
188*bbf21555SRichard LoweThe log is continually flushed as it fills up.
189*bbf21555SRichard LoweThe log is also flushed when the file system is unmounted or as a result of a
190*bbf21555SRichard Lowe.Xr lockfs 8
191*bbf21555SRichard Lowecommand.
192*bbf21555SRichard Lowe.Ss Mounting UFS File Systems
193*bbf21555SRichard LoweYou can mount a UFS file system in various ways using syntax similar to the
194*bbf21555SRichard Lowefollowing:
195*bbf21555SRichard Lowe.Bl -enum
196*bbf21555SRichard Lowe.It
197*bbf21555SRichard LoweUse
198*bbf21555SRichard Lowe.Xr mount 8
199*bbf21555SRichard Lowefrom the command line:
200*bbf21555SRichard Lowe.Bd -literal -offset indent
201*bbf21555SRichard Lowe# mount -F ufs /dev/dsk/c0t0d0s7 /export/home
202*bbf21555SRichard Lowe.Ed
203*bbf21555SRichard Lowe.It
204*bbf21555SRichard LoweInclude an entry in the
205*bbf21555SRichard Lowe.Pa /etc/vfstab
206*bbf21555SRichard Lowefile to mount the file system at boot time:
207*bbf21555SRichard Lowe.Bd -literal -offset indent
208*bbf21555SRichard Lowe/dev/dsk/c0t0d0s7 /dev/rdsk/c0t0d0s7 /export/home  ufs   2   yes  -
209*bbf21555SRichard Lowe.Ed
210*bbf21555SRichard Lowe.El
211*bbf21555SRichard Lowe.Pp
212*bbf21555SRichard LoweFor more information on mounting UFS file systems, see
213*bbf21555SRichard Lowe.Xr mount_ufs 8 .
214*bbf21555SRichard Lowe.Sh INTERFACE STABILITY
215*bbf21555SRichard Lowe.Sy Uncomitted
216*bbf21555SRichard Lowe.Sh SEE ALSO
217*bbf21555SRichard Lowe.Xr mount 2 ,
218*bbf21555SRichard Lowe.Xr attributes 7 ,
219*bbf21555SRichard Lowe.Xr df 8 ,
220*bbf21555SRichard Lowe.Xr fsck 8 ,
221*bbf21555SRichard Lowe.Xr fsck_ufs 8 ,
222*bbf21555SRichard Lowe.Xr fstyp 8 ,
223*bbf21555SRichard Lowe.Xr lockfs 8 ,
224*bbf21555SRichard Lowe.Xr mkfs_ufs 8 ,
225*bbf21555SRichard Lowe.Xr newfs 8 ,
226*bbf21555SRichard Lowe.Xr tunefs 8 ,
227*bbf21555SRichard Lowe.Xr ufsdump 8 ,
228*bbf21555SRichard Lowe.Xr ufsrestore 8
229*bbf21555SRichard Lowe.Sh NOTES
230*bbf21555SRichard LoweFor information about internal UFS structures, see
231*bbf21555SRichard Lowe.Xr newfs 8
232*bbf21555SRichard Loweand
233*bbf21555SRichard Lowe.Xr mkfs_ufs 8 .
234*bbf21555SRichard LoweFor information about dumping and restoring file systems, see
235*bbf21555SRichard Lowe.Xr ufsdump 8 ,
236*bbf21555SRichard Lowe.Xr ufsrestore 8 ,
237*bbf21555SRichard Loweand
238*bbf21555SRichard Lowe.Pa /usr/include/protocols/dumprestore.h .
239*bbf21555SRichard LoweIf you experience difficulty in allocating space on the ufs filesystem, it may
240*bbf21555SRichard Lowebe due to fragmentation.
241*bbf21555SRichard LoweFragmentation can occur when you do not have sufficient free blocks to satisfy
242*bbf21555SRichard Lowean allocation request even though
243*bbf21555SRichard Lowe.Xr df 8
244*bbf21555SRichard Loweindicates that enough free space is available.
245*bbf21555SRichard Lowe(This may occur because df only uses the available fragment count to calculate
246*bbf21555SRichard Loweavailable space, but the file system requires contiguous sets of fragments for
247*bbf21555SRichard Lowemost allocations).
248*bbf21555SRichard LoweIf you suspect that you have exhausted contiguous fragments on your file system,
249*bbf21555SRichard Loweyou can use the
250*bbf21555SRichard Lowe.Xr fstyp 8
251*bbf21555SRichard Loweutility with the
252*bbf21555SRichard Lowe.Fl v
253*bbf21555SRichard Loweoption.
254*bbf21555SRichard LoweIn the fstyp output, look at the
255*bbf21555SRichard Lowe.Em nbfree
256*bbf21555SRichard Lowe.Pq number of blocks free
257*bbf21555SRichard Loweand
258*bbf21555SRichard Lowe.Fa nffree
259*bbf21555SRichard Lowe.Pq (number of fragments free)
260*bbf21555SRichard Lowefields.
261*bbf21555SRichard LoweOn unmounted filesystems, you can use
262*bbf21555SRichard Lowe.Xr fsck 8
263*bbf21555SRichard Loweand observe the last line of output, which reports, among other items, the
264*bbf21555SRichard Lowenumber of fragments and the degree of fragmentation.
265*bbf21555SRichard LoweTo correct a fragmentation problem, run
266*bbf21555SRichard Lowe.Xr ufsdump 8
267*bbf21555SRichard Loweand
268*bbf21555SRichard Lowe.Xr ufsrestore 8
269*bbf21555SRichard Loweon the ufs filesystem.
270