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. All advertising materials mentioning features or use of this software 20.\" must display the following acknowledgement: 21.\" This product includes software developed by the University of 22.\" California, Berkeley and its contributors. 23.\" 4. Neither the name of the University nor the names of its contributors 24.\" may be used to endorse or promote products derived from this software 25.\" without specific prior written permission. 26.\" 27.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 28.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 29.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 30.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 31.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 32.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 33.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 34.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 35.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 36.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 37.\" SUCH DAMAGE. 38.\" 39.\" @(#)vnconfig.8 8.1 (Berkeley) 6/5/93 40.\" from: src/usr.sbin/vnconfig/vnconfig.8,v 1.19 2000/12/27 15:30:29 41.\" 42.\" $FreeBSD$ 43.\" 44.Dd March 21, 2012 45.Dt MDCONFIG 8 46.Os 47.Sh NAME 48.Nm mdconfig 49.Nd configure and enable memory disks 50.Sh SYNOPSIS 51.Nm 52.Fl a 53.Fl t Ar type 54.Op Fl n 55.Oo Fl o Oo Cm no Oc Ns Ar option Oc ... 56.Op Fl f Ar file 57.Op Fl s Ar size 58.Op Fl S Ar sectorsize 59.Op Fl u Ar unit 60.Op Fl x Ar sectors/track 61.Op Fl y Ar heads/cylinder 62.Nm 63.Fl d 64.Fl u Ar unit 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 u Ar unit 71.Nm 72.Ar file 73.Sh DESCRIPTION 74The 75.Nm 76utility configures and enables 77.Xr md 4 78devices. 79.Pp 80Options indicate an action to be performed: 81.Bl -tag -width indent 82.It Fl a 83Attach a memory disk. 84This will configure and attach a memory disk with the 85parameters specified and attach it to the system. 86.It Fl d 87Detach a memory disk from the system and release all resources. 88.It Fl t Ar type 89Select the type of the memory disk. 90.Bl -tag -width "malloc" 91.It Cm malloc 92Storage for this type of memory disk is allocated with 93.Xr malloc 9 . 94This limits the size to the malloc bucket limit in the kernel. 95If the 96.Fl o Cm reserve 97option is not set, creating and filling a large 98malloc-backed memory disk is a very easy way to 99panic a system. 100.It Cm vnode 101A file specified with 102.Fl f Ar file 103becomes the backing store for this memory disk. 104.It Cm swap 105Storage for this type of memory disk is allocated from buffer 106memory. 107Pages get pushed out to swap when the system is under memory 108pressure, otherwise they stay in the operating memory. 109Using 110.Cm swap 111backing is generally preferred instead of using 112.Cm malloc 113backing. 114.El 115.It Fl f Ar file 116Filename to use for the vnode type memory disk. 117The 118.Fl a 119and 120.Fl t Ar vnode 121options are implied if not specified. 122.It Fl l 123List configured devices. 124If given with 125.Fl u , 126display details about that particular device. 127If the 128.Fl v 129option is specified, show all details. 130.It Fl n 131When printing 132.Xr md 4 133device names, print only the unit number without the 134.Xr md 4 135prefix. 136.It Fl s Ar size 137Size of the memory disk. 138.Ar Size 139is the number of 512 byte sectors unless suffixed with a 140.Cm b , k , m , g , 141or 142.Cm t 143which 144denotes byte, kilobyte, megabyte, gigabyte and terabyte respectively. 145The 146.Fl a 147and 148.Fl t Ar swap 149options are implied if not specified. 150.It Fl S Ar sectorsize 151Sectorsize to use for malloc backed device. 152.It Fl x Ar sectors/track 153See the description of the 154.Fl y 155option below. 156.It Fl y Ar heads/cylinder 157For 158.Cm malloc 159or 160.Cm vnode 161backed devices, the 162.Fl x 163and 164.Fl y 165options can be used to specify a synthetic geometry. 166This is useful for constructing bootable images for later download to 167other devices. 168.It Fl o Oo Cm no Oc Ns Ar option 169Set or reset options. 170.Bl -tag -width indent 171.It Oo Cm no Oc Ns Cm async 172For 173.Cm vnode 174backed devices: avoid 175.Dv IO_SYNC 176for increased performance but 177at the risk of deadlocking the entire kernel. 178.It Oo Cm no Oc Ns Cm reserve 179Allocate and reserve all needed storage from the start, rather than as needed. 180.It Oo Cm no Oc Ns Cm cluster 181Enable clustering on this disk. 182.It Oo Cm no Oc Ns Cm compress 183Enable/disable compression features to reduce memory usage. 184.It Oo Cm no Oc Ns Cm force 185Disable/enable extra sanity checks to prevent the user from doing something 186that might adversely affect the system. 187.It Oo Cm no Oc Ns Cm readonly 188Enable/disable readonly mode. 189.El 190.It Fl u Ar unit 191Request a specific unit number for the 192.Xr md 4 193device instead of automatic allocation. 194.El 195.Pp 196The last form, 197.Nm 198.Ar file , 199is provided for convenience as an abbreviation of 200.Nm 201.Fl a 202.Fl t Ar vnode 203.Fl f Ar file . 204.Sh EXAMPLES 205Create a 4 megabyte 206.Xr malloc 9 207backed memory disk. 208The name of the allocated unit will be printed on stdout, such as 209.Dq Li md3 : 210.Pp 211.Dl mdconfig -a -t malloc -s 4m 212.Pp 213Create a disk named 214.Pa /dev/md4 215with 216.Pa /tmp/boot.flp 217as backing storage: 218.Pp 219.Dl mdconfig -a -t vnode -f /tmp/boot.flp -u 4 220.Pp 221Detach and free all resources used by 222.Pa /dev/md4 : 223.Pp 224.Dl mdconfig -d -u 4 225.Pp 226Create a 128MByte swap backed disk, initialize an 227.Xr ffs 7 228file system on it, and mount it on 229.Pa /tmp : 230.Bd -literal -offset indent 231mdconfig -a -t swap -s 128M -u 10 232newfs -U /dev/md10 233mount /dev/md10 /tmp 234chmod 1777 /tmp 235.Ed 236.Pp 237Create a 5MB file-backed disk 238.Po Fl a 239and 240.Fl t Ar vnode 241are implied 242.Pc : 243.Bd -literal -offset indent 244dd if=/dev/zero of=somebackingfile bs=1k count=5k 245mdconfig -f somebackingfile -u 0 246bsdlabel -w md0 auto 247newfs md0c 248mount /dev/md0c /mnt 249.Ed 250.Pp 251Create an 252.Xr md 4 253device out of an ISO 9660 CD image file 254.Po Fl a 255and 256.Fl t Ar vnode 257are implied 258.Pc , using the first available 259.Xr md 4 260device, and then mount the new memory disk: 261.Bd -literal -offset indent 262mount -t cd9660 /dev/`mdconfig -f cdimage.iso` /mnt 263.Ed 264.Sh SEE ALSO 265.Xr md 4 , 266.Xr ffs 7 , 267.Xr bsdlabel 8 , 268.Xr fdisk 8 , 269.Xr mdmfs 8 , 270.Xr malloc 9 271.Sh HISTORY 272The 273.Nm 274utility first appeared in 275.Fx 5.0 276as a cleaner replacement for the 277.Xr vn 4 278and 279.Xr vnconfig 8 280combo. 281.Sh AUTHORS 282The 283.Nm 284utility was written by 285.An Poul-Henning Kamp 286.Aq phk@FreeBSD.org . 287