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 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 were 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. 255Lines starting with 256.Sq # 257are ignored. 258The previously described action options serve to configure, enable, 259disable or unconfigure all devices in the configuration file. 260.Sh FILES 261.Bl -tag -width /etc/vntab -compact 262.It Pa /etc/vntab 263default configuration file for 264.Fl a 265option 266.El 267.Sh EXAMPLES 268.Dl vnconfig vn /tmp/diskimage 269.Pp 270Configures an autocloned vnode disk, 271the name of the resulting device is printed, e.g.\& 272.Pa vn4 . 273.Pp 274.Dl vnconfig vn0 /tmp/diskimage 275.Pp 276Configures the vnode disk 277.Pa vn0 . 278.Pp 279.Dl vnconfig -e vn0 /var/swapfile swap 280.Pp 281Configures 282.Pa vn0 283and 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 288Mount an ISO9660 CD image file. 289.Pp 290.Dl umount /mnt 291.Dl vnconfig -u vn0 292.Pp 293Unmount the CD image file. 294.Pp 295.Dl vnconfig -d vn0 myfilesystem mount=/mnt 296.Pp 297Unmounts (disables) 298.Pa vn0 . 299.Pp 300.Dl vnconfig -ae 301.Pp 302Configures 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 309Is an example of how to configure a file-backed 310.Nm vn 311disk with a disk label 312and to initialize and then edit the label. 313Once you create the label, you 314can partition your 315.Nm vn 316disk and, for example, create a filesystem on one of the partitions. 317If you are using a file as backing store, it may be possible 318to recover your 319.Nm vn 320disk after a crash by 321.Nm Ns 'ing 322the same file again and using the 323.Nm vn 324configuration already stored in the file rather than 325relabeling and recreating the filesystem. 326It is even possible to 327.Xr fsck 8 328the 329.Nm vn 330partitions 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 337Is an example of a swap-backed 338.Nm vn 339disk configuration. 340This example assumes 341that you have at least 400 megabytes of swap free (and hopefully much more). 342The swap space is pre-reserved in order to maintain maximum performance. 343We then label the disk, newfs it, and mount it as 344.Pa /usr/obj . 345Swap-backed 346.Nm vn 347devices are recoverable after a crash if you (A) use the 348.Cm reserve 349option, and if 350(B) the same swap is reserved as was the last time, meaning that such 351.Nm Ns 's 352would have to be run in your 353.Xr rc.local 8 . 354In general, though, you only use swap-backed 355.Nm vn 356devices 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 362