1ufs(7FS) File Systems ufs(7FS)
2
3
4
6 ufs - UFS file system
7
9 #include <sys/param.h>
10
11
12 #include <sys/types.h>
13
14
15 #include <sys/fs/ufs_fs.h>
16
17
18 #include <sys/fs/ufs_inode.h>
19
20
22 UFS is the default disk-based file system for the Solaris environment.
23 The UFS file system is hierarchical, starting with its root directory
24 (/) and continuing downward through a number of directories. The root
25 of a UFS file system is inode 2. A UFS file system's root contents
26 replace the contents of the directory upon which it is mounted.
27
28
29 Subsequent sections of this manpage provide details of the UFS file
30 systems.
31
32 State Flags (fs_state and fs_clean)
33 UFS uses state flags to identify the state of the file system. fs_state
34 is FSOKAY - fs_time. fs_time is the timestamp that indicates when the
35 last system write occurred. fs_state is updated whenever fs_clean
36 changes. Some fs_clean values are:
37
38 FSCLEAN Indicates an undamaged, cleanly unmounted file system.
39
40
41 FSACTIVE Indicates a mounted file system that has modified data in
42 memory. A mounted file system with this state flag indi‐
43 cates that user data or metadata would be lost if power to
44 the system is interrupted.
45
46
47 FSSTABLE Indicates an idle mounted file system. A mounted file sys‐
48 tem with this state flag indicates that neither user data
49 nor metadata would be lost if power to the system is inter‐
50 rupted.
51
52
53 FSBAD Indicates that this file system contains inconsistent file
54 system data.
55
56
57 FSLOG Indicates that the file system has logging enabled. A file
58 system with this flag set is either mounted or unmounted.
59 If a file system has logging enabled, the only flags that
60 it can have are FSLOG or FSBAD. A non-logging file system
61 can have FSACTIVE, FSSTABLE, or FSCLEAN.
62
63
64
65 It is not necessary to run the fsck command on unmounted file systems
66 with a state of FSCLEAN, FSSTABLE, or FSLOG. mount(2) returns ENOSPC if
67 an attempt is made to mount a UFS file system with a state of FSACTIVE
68 for read/write access.
69
70
71 As an additional safeguard, fs_clean should be trusted only if fs_state
72 contains a value equal to FSOKAY - fs_time, where FSOKAY is a constant
73 integer defined in the /usr/include/sys/fs/ufs_fs.h file. Otherwise,
74 fs_clean is treated as though it contains the value of FSACTIVE.
75
76 Extended Fundamental Types (EFT)
77 Extended Fundamental Types (EFT) provide 32-bit user ID (UID), group ID
78 (GID), and device numbers.
79
80
81 If a UID or GID contains an extended value, the short variable
82 (ic_suid, ic_sgid) contains the value 65535 and the corresponding UID
83 or GID is in ic_uid or ic_gid. Because numbers for block and character
84 devices are stored in the first direct block pointer of the inode
85 (ic_db[0]) and the disk block addresses are already 32 bit values, no
86 special encoding exists for device numbers (unlike UID or GID fields).
87
88 Multiterabyte File System
89 A multiterabyte file system enables creation of a UFS file system up to
90 approximately 16 terabytes of usable space, minus approximately one
91 percent overhead. A sparse file can have a logical size of one ter‐
92 abyte. However, the actual amount of data that can be stored in a file
93 is approximately one percent less than one terabyte because of file
94 system overhead.
95
96
97 On-disk format changes for a multiterabyte UFS file system include:
98
99 o The magic number in the superblock changes from FS_MAGIC to
100 MTB_UFS_MAGIC. For more information, see the
101 /usr/include/sys/fs/ufs_fs file.
102
103 o The fs_logbno unit is a sector for UFS that is less than 1
104 terabyte in size and fragments for a multiterabyte UFS file
105 system.
106
107 UFS Logging
108 UFS logging bundles the multiple metadata changes that comprise a com‐
109 plete UFS operation into a transaction. Sets of transactions are
110 recorded in an on-disk log and are applied to the actual UFS file sys‐
111 tem's metadata.
112
113
114 UFS logging provides two advantages:
115
116 1. A file system that is consistent with the transaction log
117 eliminates the need to run fsck after a system crash or an
118 unclean shutdown.
119
120 2. UFS logging often provides a significant performance
121 improvement. This is because a file system with logging
122 enabled converts multiple updates to the same data into sin‐
123 gle updates, thereby reducing the number of overhead disk
124 operations.
125
126
127 The UFS log is allocated from free blocks on the file system and is
128 sized at approximately 1 Mbyte per 1 Gbyte of file system, up to 256
129 Mbytes. The log size may be larger (up to a maximum of 512 Mbytes),
130 depending upon the number of cylinder groups present in the file sys‐
131 tem. The log is continually flushed as it fills up. The log is also
132 flushed when the file system is unmounted or as a result of a
133 lockfs(1M) command.
134
135 Mounting UFS File Systems
136 You can mount a UFS file system in various ways using syntax similar to
137 the following:
138
139 1. Use mount from the command line:
140
141 # mount -F ufs /dev/dsk/c0t0d0s7 /export/home
142
143
144
145 2. Include an entry in the /etc/vfstab file to mount the file
146 system at boot time:
147
148 /dev/dsk/c0t0d0s7 /dev/rdsk/c0t0d0s7 /export/home ufs 2 yes -
149
150
151
152
153 For more information on mounting UFS file systems, see mount_ufs(1M).
154
156 See attributes(5) for a description of the following attributes:
157
158
159
160
161 ┌─────────────────────────────┬─────────────────────────────┐
162 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
163 ├─────────────────────────────┼─────────────────────────────┤
164 │Interface Stability │Uncommitted │
165 └─────────────────────────────┴─────────────────────────────┘
166
168 df(1M), fsck(1M), fsck_ufs(1M), fstyp(1M), lockfs(1M), mkfs_ufs(1M),
169 newfs(1M), ufsdump(1M), ufsrestore(1M), tunefs(1M), mount(2),
170 attributes(5)
171
172
173 Writing Device Drivers
174
176 For information about internal UFS structures, see newfs(1M) and
177 mkfs_ufs(1M). For information about the ufsdump and ufsrestore com‐
178 mands, see ufsdump(1M), ufsrestore(1M), and /usr/include/proto‐
179 cols/dumprestore.h.
180
181
182 If you experience difficulty in allocating space on the ufs filesystem,
183 it may be due to framentation. Fragmentation can occur when you do not
184 have sufficient free blocks to satisfy an allocation request even
185 though df(1M) indicates that enough free space is available. (This may
186 occur because df only uses the available fragment count to calculate
187 available space, but the file system requires contiguous sets of frag‐
188 ments for most allocations). If you suspect that you have exhausted
189 contiguous fragments on your file system, you can use the fstyp(1M)
190 utility with the -v option. In the fstyp output, look at the nbfree
191 (number of blocks free) and nffree (number of fragments free)
192 fields. On unmounted filesystems, you can use fsck(1M) and observe the
193 last line of output, which reports, among other items, the number of
194 fragments and the degree of fragmentation. To correct a fragmentation
195 problem, run ufsdump(1M) and ufsrestore(1M) on the ufs filesystem.
196
197
198
199SunOS 5.11 18 Jun 2009 ufs(7FS)