usr.sbin/makefs: Sync with sys/vfs/hammer2
[dragonfly.git] / usr.sbin / vnconfig / vnconfig.8
1 .\" Copyright (c) 1993 University of Utah.
2 .\" Copyright (c) 1980, 1989, 1991, 1993
3 .\"     The Regents of the University of California.  All rights reserved.
4 .\"
5 .\" This code is derived from software contributed to Berkeley by
6 .\" the Systems Programming Group of the University of Utah Computer
7 .\" Science Department.
8 .\"
9 .\" Redistribution and use in source and binary forms, with or without
10 .\" modification, are permitted provided that the following conditions
11 .\" are met:
12 .\" 1. Redistributions of source code must retain the above copyright
13 .\"    notice, this list of conditions and the following disclaimer.
14 .\" 2. Redistributions in binary form must reproduce the above copyright
15 .\"    notice, this list of conditions and the following disclaimer in the
16 .\"    documentation and/or other materials provided with the distribution.
17 .\" 3. Neither the name of the University nor the names of its contributors
18 .\"    may be used to endorse or promote products derived from this software
19 .\"    without specific prior written permission.
20 .\"
21 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 .\" SUCH DAMAGE.
32 .\"
33 .\"     @(#)vnconfig.8  8.1 (Berkeley) 6/5/93
34 .\" $FreeBSD: src/usr.sbin/vnconfig/vnconfig.8,v 1.14.2.8 2003/01/04 22:35:53 keramida Exp $
35 .\"
36 .Dd January 19, 2022
37 .Dt VNCONFIG 8
38 .Os
39 .Sh NAME
40 .Nm vnconfig
41 .Nd configure and enable vnode disks
42 .Sh SYNOPSIS
43 .Nm
44 .Op Fl cdeguvTZ
45 .Op Fl s Ar options
46 .Op Fl r Ar options
47 .Op Fl S Ar value
48 .Ar special_file Op Ar regular_file
49 .Op Ar feature
50 .Nm
51 .Fl a
52 .Op Fl cdeguv
53 .Op Fl s Ar options
54 .Op Fl r Ar options
55 .Op Fl f Ar config_file
56 .Nm
57 .Fl l
58 .Op Ar special_file Ar ...
59 .Sh DESCRIPTION
60 The
61 .Nm
62 command configures, enables and lists vnode pseudo disk devices.
63 The first form of the command will associate the special file
64 .Ar special_file
65 with the regular file
66 .Ar regular_file
67 allowing the latter to be accessed as though it were a disk.
68 Hence a regular file within the filesystem can be used for swapping
69 or can contain a filesystem that is mounted in the name space.
70 If you want to use swap backing store for your device instead of a file,
71 you can leave
72 .Ar regular_file
73 out and specify the size of the block device
74 with the
75 .Fl S
76 option.
77 .Pp
78 Options indicate an action to be performed:
79 .Bl -tag -width indent
80 .It Fl a
81 Read a command file and performs the
82 specified actions for each device/file pair.
83 .It Fl c
84 Configure the device.
85 If successful, references to
86 .Ar special_file
87 will access the contents of
88 .Ar regular_file .
89 .Pp
90 A
91 .Nm vn
92 device is autocloned if
93 .Ar special_file
94 is given as
95 .Pa vn ,
96 the name of the resulting device is printed on stdout.
97 .It Fl d
98 Disable (if possible) the specified feature.
99 .It Fl e
100 Configure the device and enables any
101 .Ar feature
102 that was specified.
103 If no feature was specified,
104 .Fl e
105 is the same as
106 .Fl c .
107 .It Fl f Ar config_file
108 Specify configuration file.
109 Default is
110 .Pa /etc/vntab .
111 .It Fl g
112 Fiddle global options.
113 .It Fl l Ar special_file Ar ...
114 List the
115 .Nm vn
116 devices and indicate which ones are in use.
117 If a
118 .Ar special_file
119 list is given, only those devices will be described.
120 .It Fl r Ar options
121 Reset
122 .Ar options ,
123 which is a comma separated string of options.
124 The list of allowed options and their meanings are:
125 .Bl -tag -width "reserve"
126 .It Cm reserve
127 Pre-reserve the blocks underlying the file or swap backing store.
128 Currently only works for swap backing store.
129 This option also disables on-the-fly freeing of
130 the underlying backing store (for example, when you remove a large file).
131 Use this option if you wish to avoid long-term fragmentation of the backing
132 store.
133 Also note that when this option is used, the initial contents of the
134 backing store may contain garbage rather than zeros.
135 It may even be possible to
136 recover the prior contents of a swap-backed
137 .Nm vn
138 across a reboot if the
139 .Nm vn
140 device
141 is configured before any swap is allocated by the system.
142 .It Cm follow
143 Debug flow in the
144 .Xr vn 4
145 driver.
146 .It Cm debug
147 Debug data in the
148 .Xr vn 4
149 driver.
150 .It Cm io
151 Debug
152 .Tn I/O
153 in the
154 .Xr vn 4
155 driver.
156 .It Cm all
157 Turn on all options.
158 .It Cm none
159 Turn off all options.
160 .El
161 .It Fl s Ar options
162 Set
163 .Ar options ,
164 which is a comma separated string of options.
165 The list of allowed options and their meanings are the same as for the
166 .Fl r
167 option.
168 .It Fl S Xo
169 .Sm off
170 .Ar value
171 .Brq Cm k , m , g , t
172 .Sm on
173 .Xc
174 If no regular file is specified,
175 .Nm vn
176 will use swap for backing store.
177 This option specifies the size of the device.
178 For example,
179 .Sq 23m
180 for
181 23 megabytes.
182 In the absence of a size modifier,
183 .Cm m
184 is implied.
185 The
186 .Nm vn
187 device will round the size up to a machine page boundary.
188 Filesystems up to 7.9 terabytes are supported.
189 When specified along with
190 a regular file, this option overrides the regular file's size insofar as
191 .Nm vn
192 is concerned.
193 .It Fl T
194 When a regular file is specified,
195 .Nm
196 will
197 .Fn ftruncate
198 the file to length 0 first.
199 Normally you should also specify the
200 .Fl S
201 option to set the size of the file.
202 This option also creates the file if it did not previously exist.
203 This option is only meaningful if the
204 .Fl S
205 option has been specified.
206 .It Fl Z
207 When a regular file is specified,
208 .Nm
209 will zero the contents of the file to
210 ensure that all blocks have been allocated by the filesystem.
211 This option is only meaningful if the
212 .Fl S
213 option has been specified.
214 .It Fl u
215 Disable and ``unconfigure'' the device.
216 .It Fl v
217 Print messages to stdout describing actions taken.
218 .El
219 .Pp
220 If no action option is given,
221 .Fl c
222 is assumed.
223 .Pp
224 The
225 .Ar feature
226 argument specifies a feature that can be enabled via the
227 .Fl e
228 option:
229 .Bl -tag -width indent
230 .It Cm swap
231 Swapping is enabled on the special file.
232 See
233 .Xr swapon 2 .
234 .It Cm mountro= Ns Ar mount_point
235 The special file is mounted read-only on
236 .Ar mount_point .
237 See
238 .Xr mount 2 .
239 .It Cm mountrw= Ns Ar mount_point
240 The special file is mounted read-write on
241 .Ar mount_point .
242 See
243 .Xr mount 2 .
244 .It Cm mount= Ns Ar mount_point
245 Same as
246 .Cm mountrw= Ns Ar mount_point .
247 .El
248 .Pp
249 A configuration file contains one line per device/file pair in the form:
250 .Bd -literal
251         special_file    regular_file    [feature]
252 .Ed
253 .Pp
254 where fields are separated by white space.
255 Lines starting with
256 .Sq #
257 are ignored.
258 The previously described action options serve to configure, enable,
259 disable or unconfigure all devices in the configuration file.
260 .Sh FILES
261 .Bl -tag -width /etc/vntab -compact
262 .It Pa /etc/vntab
263 default configuration file for
264 .Fl a
265 option
266 .El
267 .Sh EXAMPLES
268 .Dl vnconfig vn /tmp/diskimage
269 .Pp
270 Configures an autocloned vnode disk,
271 the name of the resulting device is printed, e.g.\&
272 .Pa vn4 .
273 .Pp
274 .Dl vnconfig vn0 /tmp/diskimage
275 .Pp
276 Configures the vnode disk
277 .Pa vn0 .
278 .Pp
279 .Dl vnconfig -e vn0 /var/swapfile swap
280 .Pp
281 Configures
282 .Pa vn0
283 and enables swapping on it.
284 .Pp
285 .Dl vnconfig -c -v /dev/vn0 cdimage.iso
286 .Dl mount -t cd9660 -o ro /dev/vn0 /mnt
287 .Pp
288 Mount an ISO9660 CD image file.
289 .Pp
290 .Dl umount /mnt
291 .Dl vnconfig -u vn0
292 .Pp
293 Unmount the CD image file.
294 .Pp
295 .Dl vnconfig -d vn0 myfilesystem mount=/mnt
296 .Pp
297 Unmounts (disables)
298 .Pa vn0 .
299 .Pp
300 .Dl vnconfig -ae
301 .Pp
302 Configures and enables all devices specified in
303 .Pa /etc/vntab .
304 .Pp
305 .Dl vnconfig -c vn0 somebackingfile
306 .Dl disklabel -r -w vn0s0 auto
307 .Dl disklabel -e vn0s0
308 .Pp
309 Is an example of how to configure a file-backed
310 .Nm vn
311 disk with a disk label
312 and to initialize and then edit the label.
313 Once you create the label, you
314 can partition your
315 .Nm vn
316 disk and, for example, create a filesystem on one of the partitions.
317 If you are using a file as backing store, it may be possible
318 to recover your
319 .Nm vn
320 disk after a crash by
321 .Nm Ns 'ing
322 the same file again and using the
323 .Nm vn
324 configuration already stored in the file rather than
325 relabeling and recreating the filesystem.
326 It is even possible to
327 .Xr fsck 8
328 the
329 .Nm vn
330 partitions that previously contained filesystems.
331 .Pp
332 .Dl vnconfig -e -s reserve -S 400m vn1
333 .Dl disklabel -r -w vn1s0 auto
334 .Dl newfs /dev/vn1s0
335 .Dl mount /dev/vn1s0 /usr/obj
336 .Pp
337 Is an example of a swap-backed
338 .Nm vn
339 disk configuration.
340 This example assumes
341 that you have at least 400 megabytes of swap free (and hopefully much more).
342 The swap space is pre-reserved in order to maintain maximum performance.
343 We then label the disk, newfs it, and mount it as
344 .Pa /usr/obj .
345 Swap-backed
346 .Nm vn
347 devices are recoverable after a crash if you (A) use the
348 .Cm reserve
349 option, and if
350 (B) the same swap is reserved as was the last time, meaning that such
351 .Nm Ns 's
352 would have to be run in your
353 .Xr rc.local 8 .
354 In general, though, you only use swap-backed
355 .Nm vn
356 devices to hold information you don't mind losing on every reboot.
357 .Sh SEE ALSO
358 .Xr mount 2 ,
359 .Xr swapon 2 ,
360 .Xr unmount 2 ,
361 .Xr vn 4