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