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.\" Copyright (c) 2000 5.\" Poul-Henning Kamp All rights reserved. 6.\" 7.\" This code is derived from software contributed to Berkeley by 8.\" the Systems Programming Group of the University of Utah Computer 9.\" Science Department. 10.\" 11.\" Redistribution and use in source and binary forms, with or without 12.\" modification, are permitted provided that the following conditions 13.\" are met: 14.\" 1. Redistributions of source code must retain the above copyright 15.\" notice, this list of conditions and the following disclaimer. 16.\" 2. Redistributions in binary form must reproduce the above copyright 17.\" notice, this list of conditions and the following disclaimer in the 18.\" documentation and/or other materials provided with the distribution. 19.\" 3. Neither the name of the University nor the names of its contributors 20.\" may be used to endorse or promote products derived from this software 21.\" without specific prior written permission. 22.\" 23.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 24.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 27.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33.\" SUCH DAMAGE. 34.\" 35.\" @(#)vnconfig.8 8.1 (Berkeley) 6/5/93 36.\" from: src/usr.sbin/vnconfig/vnconfig.8,v 1.19 2000/12/27 15:30:29 37.\" 38.Dd November 6, 2020 39.Dt MDCONFIG 8 40.Os 41.Sh NAME 42.Nm mdconfig 43.Nd create and control memory disks 44.Sh SYNOPSIS 45.Nm 46.Fl a 47.Fl t Ar type 48.Op Fl n 49.Oo Fl o Oo Cm no Oc Ns Ar option Oc ... 50.Op Fl f Ar file 51.Op Fl s Ar size 52.Op Fl S Ar sectorsize 53.Op Fl u Ar unit 54.Op Fl x Ar sectors/track 55.Op Fl y Ar heads/cylinder 56.Op Fl L Ar label 57.Nm 58.Fl d 59.Fl u Ar unit 60.Op Fl o Oo Cm no Oc Ns Ar force 61.Nm 62.Fl r 63.Fl u Ar unit 64.Fl s Ar size 65.Op Fl o Oo Cm no Oc Ns Ar force 66.Nm 67.Fl l 68.Op Fl n 69.Op Fl v 70.Op Fl f Ar file 71.Op Fl u Ar unit 72.Nm 73.Ar file 74.Sh DESCRIPTION 75The 76.Nm 77utility creates and controls 78.Xr md 4 79devices. 80.Pp 81Options indicate an action to be performed: 82.Bl -tag -width indent 83.It Fl a 84Attach a memory disk. 85This will configure and attach a memory disk with the 86parameters specified and attach it to the system. 87If the 88.Fl u Ar unit 89option is not provided, the newly created device name will be printed on stdout. 90.It Fl d 91Detach a memory disk from the system and release all resources. 92.It Fl r 93Resize a memory disk. 94.It Fl t Ar type 95Select the type of the memory disk. 96.Bl -tag -width "malloc" 97.It Cm malloc 98Storage for this type of memory disk is allocated with 99.Xr malloc 9 . 100This limits the size to the malloc bucket limit in the kernel. 101If the 102.Fl o Cm reserve 103option is not set, creating and filling a large 104malloc-backed memory disk is a very easy way to 105panic the system. 106.It Cm vnode 107A file specified with 108.Fl f Ar file 109becomes the backing store for this memory disk. 110.It Cm swap 111Storage for this type of memory disk is allocated from buffer 112memory. 113Pages get pushed out to swap when the system is under memory 114pressure, otherwise they stay in the operating memory. 115Using 116.Cm swap 117backing is generally preferred instead of using 118.Cm malloc 119backing. 120.It Cm null 121Bitsink; all writes do nothing, all reads return zeroes. 122.El 123.It Fl f Ar file 124Filename to use for the vnode type memory disk. 125The 126.Fl a 127and 128.Fl t Cm vnode 129options are implied if not specified. 130.It Fl l 131List configured devices. 132If given with 133.Fl u , 134display details about that particular device. 135If given with 136.Fl f Ar file , 137display 138.Xr md 4 139device names of which 140.Ar file 141is used as the backing store. 142If both of 143.Fl u 144and 145.Fl f 146options are specified, 147display devices which match the two conditions. 148If the 149.Fl v 150option is specified, show all details. 151.It Fl n 152When printing 153.Xr md 4 154device names, print only the unit number without the 155.Xr md 4 156prefix. 157.It Fl s Ar size 158Size of the memory disk. 159.Ar Size 160is the number of 512 byte sectors unless suffixed with a 161.Cm b , k , m , g , t , 162or 163.Cm p 164which 165denotes byte, kilobyte, megabyte, gigabyte, terabyte and petabyte respectively. 166When used without the 167.Fl r 168option, the 169.Fl a 170and 171.Fl t Cm swap 172options are implied if not specified. 173.It Fl S Ar sectorsize 174Sectorsize to use for the memory disk, in bytes. 175.It Fl x Ar sectors/track 176See the description of the 177.Fl y 178option below. 179.It Fl y Ar heads/cylinder 180For 181.Cm malloc 182or 183.Cm vnode 184backed devices, the 185.Fl x 186and 187.Fl y 188options can be used to specify a synthetic geometry. 189This is useful for constructing bootable images for later download to 190other devices. 191.It Fl L Ar label 192Associate a label (arbitrary string) with the new memory disk. 193The label can then be inspected with 194.Bd -literal -offset indent 195.Nm Fl l v 196.Ed 197.It Fl o Oo Cm no Oc Ns Ar option 198Set or reset options. 199.Bl -tag -width indent 200.It Oo Cm no Oc Ns Cm async 201For 202.Cm vnode 203backed devices: avoid 204.Dv IO_SYNC 205for increased performance but 206at the risk of deadlocking the entire kernel. 207.It Oo Cm no Oc Ns Cm cache 208For 209.Cm vnode 210backed devices: enable/disable caching of data in system caches. 211The default is to not cache. 212.Pp 213Accesses via the device are converted to accesses via the vnode. 214The caching policy for the vnode is used initially. 215This is normally to cache. 216This caching policy is retained if the 217.Cm cache 218option is used. 219Otherwise, caching is limited 220by releasing data from caches soon after each access. 221The release has the same semantics as the 222.Dv POSIX_FADV_DONTNEED 223feature of 224.Xr posix_fadvise 2 . 225The result is that with normal (non-zfs) caching, 226buffers are released from the buffer cache soon after they are constructed, 227but their data is kept in the page cache at lower priority. 228.Pp 229The 230.Cm cache 231option tends to waste memory by giving unwanted double caching, 232but it saves time if there is memory to spare. 233.It Oo Cm no Oc Ns Cm reserve 234Allocate and reserve all needed storage from the start, rather than as needed. 235.It Oo Cm no Oc Ns Cm cluster 236Enable clustering on this disk. 237.It Oo Cm no Oc Ns Cm compress 238Enable/disable compression features to reduce memory usage. 239.It Oo Cm no Oc Ns Cm force 240Disable/enable extra sanity checks to prevent the user from doing something 241that might adversely affect the system. 242This can be used with the 243.Fl d 244flag to forcibly destroy an 245.Xr md 4 246disk that is still in use. 247.It Oo Cm no Oc Ns Cm readonly 248Enable/disable readonly mode. 249.It Oo Cm no Oc Ns Cm verify 250For 251.Cm vnode 252backed devices: enable/disable requesting verification of the 253file used for backing store. 254The type of verification depends on which security features are available. 255One example of verification is testing file integrity with 256checksums or cryptographic signatures. 257.El 258.It Fl u Ar unit 259Request a specific unit number or device name for the 260.Xr md 4 261device instead of automatic allocation. 262If a device name is specified, it must start with 263.Dq md 264followed by the unit number. 265.El 266.Pp 267The last form, 268.Nm 269.Ar file , 270is provided for convenience as an abbreviation of 271.Nm 272.Fl a 273.Fl t Cm vnode 274.Fl f Ar file . 275.Sh EXAMPLES 276Create a disk with 277.Pa /tmp/boot.flp 278as backing storage. 279The name of the allocated unit will be printed on stdout, such as 280.Dq Li md0 : 281.Bd -literal -offset indent 282mdconfig /tmp/boot.flp 283.Ed 284.Pp 285Create a 1 gigabyte swap backed memory disk named 286.Dq Li md3 : 287.Bd -literal -offset indent 288mdconfig -s 1g -u md3 289.Ed 290.Pp 291Detach and free all resources used by 292.Pa /dev/md3 : 293.Bd -literal -offset indent 294mdconfig -du md3 295.Ed 296.Pp 297Show detailed information on current memory disks: 298.Bd -literal -offset indent 299mdconfig -lv 300.Ed 301.Pp 302Resize the 303.Dq Li md3 304memory disk to 2 gigabytes: 305.Bd -literal -offset indent 306mdconfig -rs 2g -u md3 307.Ed 308.Pp 309Create a 1 gigabyte swap backed disk, initialize an 310.Xr ffs 7 311file system on it, and mount it on 312.Pa /tmp : 313.Bd -literal -offset indent 314mdconfig -s 1g -u md10 315newfs -U /dev/md10 316mount /dev/md10 /tmp 317chmod 1777 /tmp 318.Ed 319.Pp 320Create a memory disk out of an ISO 9660 CD image file, 321using the first available 322.Xr md 4 323device, and then mount it: 324.Bd -literal -offset indent 325mount -t cd9660 /dev/`mdconfig -f cdimage.iso` /mnt 326.Ed 327.Pp 328Create a file-backed device from a hard disk image that begins 329with 512K of raw header information. 330.Xr gnop 8 331is used to skip over the header information, positioning 332.Pa md1.nop 333to the start of the filesystem in the image. 334.Bd -literal -offset indent 335mdconfig -u md1 -f diskimage.img 336gnop create -o 512K md1 337mount /dev/md1.nop /mnt 338.Ed 339.Sh SEE ALSO 340.Xr open 2 , 341.Xr md 4 , 342.Xr ffs 7 , 343.Xr gpart 8 , 344.Xr mdmfs 8 , 345.Xr malloc 9 346.Sh HISTORY 347The 348.Nm 349utility first appeared in 350.Fx 5.0 351as a cleaner replacement for the vn kernel module 352and the vnconfig utility combo. 353.Sh AUTHORS 354The 355.Nm 356utility was written by 357.An Poul-Henning Kamp Aq Mt phk@FreeBSD.org . 358