Initial import from FreeBSD RELENG_4:
[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. 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 .\"
40 .Dd July 8, 1993
41 .Dt VNCONFIG 8
42 .Os
43 .Sh NAME
44 .Nm vnconfig
45 .Nd configure and enable vnode disks
46 .Sh SYNOPSIS
47 .Nm
48 .Op Fl cdeguvTZ
49 .Oo Fl s Ar option Ns
50 .Op , Ns Ar option Ns Ar ... Oc
51 .Oo Fl r Ar option Ns
52 .Op , Ns Ar option Ns Ar ... Oc
53 .Op Fl S Ar value
54 .Ar special_file Op Ar regular_file
55 .Op Ar feature
56 .Nm
57 .Fl a
58 .Op Fl cdeguv
59 .Op Fl s Ar option
60 .Op Fl r Ar option
61 .Op Fl f Ar config_file
62 .Sh DESCRIPTION
63 The
64 .Nm
65 command configures and enables vnode pseudo disk devices.
66 The first form of the command will associate the special file
67 .Ar special_file
68 with the regular file
69 .Ar regular_file
70 allowing the latter to be accessed as though it were a disk.
71 Hence a regular file within the filesystem can be used for swapping
72 or can contain a filesystem that is mounted in the name space.  If you
73 want to use swap backing store for your device instead of a file, you
74 can leave regular_file out and specify the size of the block device
75 with the -S option.
76 .Pp
77 Options indicate an action to be performed:
78 .Bl -tag -width indent
79 .It Fl a
80 Read a command file and performs the
81 specified actions for each device/file pair.
82 .It Fl c
83 Configure the device.
84 If successful, references to
85 .Ar special_file
86 will access the contents of
87 .Ar regular_file .
88 .It Fl d
89 Disable (if possible) the specified feature.
90 .It Fl e
91 Configure the device and enables any
92 .Ar feature
93 that was specified.
94 If no feature was specified,
95 .Fl e
96 is the same as
97 .Fl c .
98 .It Fl f Ar config_file
99 Use
100 .Ar config_file
101 as an alternate config file.
102 .It Fl g
103 Fiddle global options.
104 .It Fl r Ar flag
105 Reset
106 .Ar flag .
107 The list of allowed flags and their meanings are:
108 .Bl -tag -width "follow"
109 .It Ar labels
110 use disk/slice labels.
111 .It Ar reserve
112 Pre-reserve the blocks underlying the file or swap backing store.  Currently only
113 works for swap backing store.  This option also disables on-the-fly freeing of
114 the underlying backing store (for example, when you remove a large file).
115 Use this option if you wish to avoid long-term fragmentation of the backing
116 store.  Also note that when this option is used, the initial contents of the
117 backing store may contain garbage rather then zeros.  It may even be possible to
118 recover the prior contents of a swap-backed VN across a reboot if the VN device
119 is configured before any swap is allocated by the system.
120 .It Ar follow
121 debug flow in the
122 .Xr vn 4
123 driver.
124 .It Ar debug
125 debug data in the
126 .Xr vn 4
127 driver.
128 .It Ar io
129 debug I/O in the
130 .Xr vn 4
131 driver.
132 .It Ar all
133 turn on all flags.
134 .It Ar none
135 turn off all flags.
136 .El
137 .It Fl s Ar flag
138 Set
139 .Ar flag .
140 The list of allowed flags and their meanings are the same as for the
141 .Fl r
142 option.
143 .It Fl S Xo
144 .Sm off
145 .Ar value
146 .Es \&{ \&}
147 .En Cm k , m , g , t
148 .Sm on
149 .Xc
150 If no regular file is specified, VN will use swap for backing store.
151 This option specifies the size of the device.  For example, '23m' for
152 23 megabytes.  The VN device will round the size up to a machine page boundary.
153 Filesystems up to 7.9 terabytes are supported.  When specified along with
154 a regular file, this option overrides the regular file's size insofar as
155 VN is concerned.
156 .It Fl T
157 When a regular file is specified, VN will ftruncate() the file to 0 first.
158 Normally you should also specify the -S option to set the size of the file.
159 This option also creates the file if it did not previously exist.
160 This option is only meaningful if the -S option has been specified.
161 .It Fl Z
162 When a regular file is specified, VN will zero the contents of the file to
163 ensure that all blocks have been allocated by the filesystem.  This option is
164 only meaningful if the -S option has been specified.
165 .It Fl u
166 Disable and ``unconfigure'' the device.
167 .It Fl v
168 Print messages to stdout describing actions taken.
169 .El
170 .Pp
171 If no action option is given,
172 .Fl c
173 is assumed.
174 .Pp
175 The
176 .Ar feature
177 argument specifies a feature that can be enabled via the
178 .Fl e
179 option:
180 .Bl -tag -width indent
181 .It Dv swap
182 Swapping is enabled on the special file.
183 See
184 .Xr swapon 2 .
185 .It Dv mountro Ns = Ns Pa mount_point
186 The special file is mounted read-only on
187 .Ar mount_point .
188 See
189 .Xr mount 2 .
190 .It Dv mountrw Ns = Ns Pa mount_point
191 The special file is mounted read-write on
192 .Ar mount_point .
193 See
194 .Xr mount 2 .
195 .It Dv mount Ns = Ns Pa mount_point
196 Same as ``mountrw=''.
197 .El
198 .Pp
199 A configuration file contains one line per device/file pair in the form:
200 .Bd -literal
201         special_file    regular_file    [ feature ]
202 .Ed
203 .Pp
204 where fields are separated by white space.
205 The previously described action options serve to configure, enable,
206 disable or unconfigure all devices in the configuration file.
207 .Sh FILES
208 .Bl -tag -width /etc/vntab -compact
209 .It Pa /etc/vntab
210 default configuration file for
211 .Fl a
212 option
213 .El
214 .Sh EXAMPLES
215 .Pp
216 .Dl vnconfig vn0c /tmp/diskimage
217 .Pp
218 Configures the vnode disk
219 .Pa vn0c .
220 .Pp
221 .Dl vnconfig -e vn0c /var/swapfile swap
222 .Pp
223 Configures
224 .Pa vn0c
225 and enables swapping on it.
226 .Pp
227 .Dl vnconfig -c -v /dev/vn0 cdimage.iso
228 .Dl mount -t cd9660 -o ro /dev/vn0 /mnt
229 .Pp
230 Mount an ISO9660 CD image file.
231 .Pp
232 .Dl umount /mnt
233 .Dl vnconfig -u vn0c
234 .Pp
235 Unmount the CD image file.
236 .Pp
237 .Dl vnconfig -d vn0c myfilesystem mount=/mnt
238 .Pp
239 Unmounts (disables)
240 .Pa vn0c .
241 .Pp
242 .Dl vnconfig -ae
243 .Pp
244 Configures and enables all devices specified in
245 .Pa /etc/vntab .
246 .Pp
247 .Dl vnconfig -s labels -c vn0 somebackingfile
248 .Dl disklabel -r -w vn0 auto
249 .Dl disklabel -e vn0
250 .Pp
251 Is an example of how to configure a file-backed VN disk with a disk label
252 and to initialize and then edit the label.  Once you create the label, you
253 can partition your VN disk and, for example, create a filesystem on one of
254 the partitions.  If you are using a file as backing store, it may be possible
255 to recover your VN disk after a crash by vnconfig'ing the same file again
256 and using the VN configuration already stored in the file rather then
257 relabeling and recreating the filesystem.  It is even possible to fsck the
258 VN partitions that previously contained filesystems.
259 .Pp
260 .Dl vnconfig -e -s labels,reserve -S 400m vn1
261 .Dl disklabel -r -w vn1 auto
262 .Dl newfs /dev/vn1c
263 .Dl mount /dev/vn1c /usr/obj
264 .Pp
265 Is an example of a swap-backed VN disk configuration.  This example assumes
266 that you have at least 400 megabytes of swap free (and hopefully much more).
267 The swap space is pre-reserved in order to maintain maximum performance.
268 We then label the disk, newfs it, and mount it as /usr/obj.  Swap-backed VN
269 devices are recoverable after a crash if you (A) use the reserve flag, and if
270 (B) the same swap is reserved as was the last time, meaning that such
271 vnconfig's would have to be run in your rc.local.  In general, though, you
272 only use swap-backed VN devices to hold information you don't mind losing
273 on every reboot.
274 .Sh SEE ALSO
275 .Xr mount 2 ,
276 .Xr swapon 2 ,
277 .Xr unmount 2 ,
278 .Xr vn 4