xref: /dragonfly/usr.sbin/vnconfig/vnconfig.8 (revision e4adeac1)
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 September 28, 2009
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
60The
61.Nm
62command configures, enables and lists vnode pseudo disk devices.
63The first form of the command will associate the special file
64.Ar special_file
65with the regular file
66.Ar regular_file
67allowing the latter to be accessed as though it was a disk.
68Hence a regular file within the filesystem can be used for swapping
69or can contain a filesystem that is mounted in the name space.
70If you want to use swap backing store for your device instead of a file,
71you can leave
72.Ar regular_file
73out and specify the size of the block device
74with the
75.Fl S
76option.
77.Pp
78Options indicate an action to be performed:
79.Bl -tag -width indent
80.It Fl a
81Read a command file and performs the
82specified actions for each device/file pair.
83.It Fl c
84Configure the device.
85If successful, references to
86.Ar special_file
87will access the contents of
88.Ar regular_file .
89.Pp
90A
91.Nm vn
92device is autocloned if
93.Ar special_file
94is given as
95.Pa vn ,
96the name of the resulting device is printed on stdout.
97.It Fl d
98Disable (if possible) the specified feature.
99.It Fl e
100Configure the device and enables any
101.Ar feature
102that was specified.
103If no feature was specified,
104.Fl e
105is the same as
106.Fl c .
107.It Fl f Ar config_file
108Specify configuration file.
109Default is
110.Pa /etc/vntab .
111.It Fl g
112Fiddle global options.
113.It Fl l Ar special_file Ar ...
114List the
115.Nm vn
116devices and indicate which ones are in use.
117If a
118.Ar special_file
119list is given, only those devices will be described.
120.It Fl r Ar options
121Reset
122.Ar options ,
123which is a comma separated string of options.
124The list of allowed options and their meanings are:
125.Bl -tag -width "reserve"
126.It Cm reserve
127Pre-reserve the blocks underlying the file or swap backing store.
128Currently only works for swap backing store.
129This option also disables on-the-fly freeing of
130the underlying backing store (for example, when you remove a large file).
131Use this option if you wish to avoid long-term fragmentation of the backing
132store.
133Also note that when this option is used, the initial contents of the
134backing store may contain garbage rather than zeros.
135It may even be possible to
136recover the prior contents of a swap-backed
137.Nm vn
138across a reboot if the
139.Nm vn
140device
141is configured before any swap is allocated by the system.
142.It Cm follow
143Debug flow in the
144.Xr vn 4
145driver.
146.It Cm debug
147Debug data in the
148.Xr vn 4
149driver.
150.It Cm io
151Debug
152.Tn I/O
153in the
154.Xr vn 4
155driver.
156.It Cm all
157Turn on all options.
158.It Cm none
159Turn off all options.
160.El
161.It Fl s Ar options
162Set
163.Ar options ,
164which is a comma separated string of options.
165The list of allowed options and their meanings are the same as for the
166.Fl r
167option.
168.It Fl S Xo
169.Sm off
170.Ar value
171.Brq Cm k , m , g , t
172.Sm on
173.Xc
174If no regular file is specified,
175.Nm vn
176will use swap for backing store.
177This option specifies the size of the device.
178For example,
179.Sq 23m
180for
18123 megabytes.
182In the absence of a size modifier,
183.Cm m
184is implied.
185The
186.Nm vn
187device will round the size up to a machine page boundary.
188Filesystems up to 7.9 terabytes are supported.
189When specified along with
190a regular file, this option overrides the regular file's size insofar as
191.Nm vn
192is concerned.
193.It Fl T
194When a regular file is specified,
195.Nm
196will
197.Fn ftruncate
198the file to length 0 first.
199Normally you should also specify the
200.Fl S
201option to set the size of the file.
202This option also creates the file if it did not previously exist.
203This option is only meaningful if the
204.Fl S
205option has been specified.
206.It Fl Z
207When a regular file is specified,
208.Nm
209will zero the contents of the file to
210ensure that all blocks have been allocated by the filesystem.
211This option is only meaningful if the
212.Fl S
213option has been specified.
214.It Fl u
215Disable and ``unconfigure'' the device.
216.It Fl v
217Print messages to stdout describing actions taken.
218.El
219.Pp
220If no action option is given,
221.Fl c
222is assumed.
223.Pp
224The
225.Ar feature
226argument specifies a feature that can be enabled via the
227.Fl e
228option:
229.Bl -tag -width indent
230.It Cm swap
231Swapping is enabled on the special file.
232See
233.Xr swapon 2 .
234.It Cm mountro= Ns Ar mount_point
235The special file is mounted read-only on
236.Ar mount_point .
237See
238.Xr mount 2 .
239.It Cm mountrw= Ns Ar mount_point
240The special file is mounted read-write on
241.Ar mount_point .
242See
243.Xr mount 2 .
244.It Cm mount= Ns Ar mount_point
245Same as
246.Cm mountrw= Ns Ar mount_point .
247.El
248.Pp
249A 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
254where fields are separated by white space.
255The previously described action options serve to configure, enable,
256disable or unconfigure all devices in the configuration file.
257.Sh FILES
258.Bl -tag -width /etc/vntab -compact
259.It Pa /etc/vntab
260default configuration file for
261.Fl a
262option
263.El
264.Sh EXAMPLES
265.Dl vnconfig vn /tmp/diskimage
266.Pp
267Configures an autocloned vnode disk,
268the name of the resulting device is printed, e.g.\&
269.Pa vn4 .
270.Pp
271.Dl vnconfig vn0 /tmp/diskimage
272.Pp
273Configures the vnode disk
274.Pa vn0 .
275.Pp
276.Dl vnconfig -e vn0 /var/swapfile swap
277.Pp
278Configures
279.Pa vn0
280and enables swapping on it.
281.Pp
282.Dl vnconfig -c -v /dev/vn0 cdimage.iso
283.Dl mount -t cd9660 -o ro /dev/vn0 /mnt
284.Pp
285Mount an ISO9660 CD image file.
286.Pp
287.Dl umount /mnt
288.Dl vnconfig -u vn0
289.Pp
290Unmount the CD image file.
291.Pp
292.Dl vnconfig -d vn0 myfilesystem mount=/mnt
293.Pp
294Unmounts (disables)
295.Pa vn0 .
296.Pp
297.Dl vnconfig -ae
298.Pp
299Configures and enables all devices specified in
300.Pa /etc/vntab .
301.Pp
302.Dl vnconfig -c vn0 somebackingfile
303.Dl disklabel -r -w vn0s0 auto
304.Dl disklabel -e vn0s0
305.Pp
306Is an example of how to configure a file-backed
307.Nm vn
308disk with a disk label
309and to initialize and then edit the label.
310Once you create the label, you
311can partition your
312.Nm vn
313disk and, for example, create a filesystem on one of the partitions.
314If you are using a file as backing store, it may be possible
315to recover your
316.Nm vn
317disk after a crash by
318.Nm Ns 'ing
319the same file again and using the
320.Nm vn
321configuration already stored in the file rather than
322relabeling and recreating the filesystem.
323It is even possible to
324.Xr fsck 8
325the
326.Nm vn
327partitions that previously contained filesystems.
328.Pp
329.Dl vnconfig -e -s reserve -S 400m vn1
330.Dl disklabel -r -w vn1s0 auto
331.Dl newfs /dev/vn1s0
332.Dl mount /dev/vn1s0 /usr/obj
333.Pp
334Is an example of a swap-backed
335.Nm vn
336disk configuration.
337This example assumes
338that you have at least 400 megabytes of swap free (and hopefully much more).
339The swap space is pre-reserved in order to maintain maximum performance.
340We then label the disk, newfs it, and mount it as
341.Pa /usr/obj .
342Swap-backed
343.Nm vn
344devices are recoverable after a crash if you (A) use the
345.Cm reserve
346option, and if
347(B) the same swap is reserved as was the last time, meaning that such
348.Nm Ns 's
349would have to be run in your
350.Xr rc.local 8 .
351In general, though, you only use swap-backed
352.Nm vn
353devices to hold information you don't mind losing on every reboot.
354.Sh SEE ALSO
355.Xr mount 2 ,
356.Xr swapon 2 ,
357.Xr unmount 2 ,
358.Xr vn 4
359