xref: /freebsd/sbin/mdconfig/mdconfig.8 (revision 39beb93c)
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 June 21, 2008
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/cyl
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.Sh DESCRIPTION
72The
73.Nm
74utility configures and enables
75.Xr md 4
76devices.
77.Pp
78Options indicate an action to be performed:
79.Bl -tag -width indent
80.It Fl a
81Attach a memory disk.
82This will configure and attach a memory disk with the
83parameters specified and attach it to the system.
84.It Fl d
85Detach a memory disk from the system and release all resources.
86.It Fl t Ar type
87Select the type of the memory disk.
88.Bl -tag -width "preload"
89.It Cm malloc
90Storage for this type of memory disk is allocated with
91.Xr malloc 9 .
92This limits the size to the malloc bucket limit in the kernel.
93If the
94.Fl o Cm reserve
95option is not set, creating and filling a large
96malloc-backed memory disk is a very easy way to
97panic a system.
98.It Cm vnode
99A file specified with
100.Fl f Ar file
101becomes the backing store for this memory disk.
102.It Cm swap
103Storage for this type of memory disk is allocated from buffer
104memory.
105Pages get pushed out to the swap when the system is under memory
106pressure, otherwise they stay in the operating memory.
107Using
108.Cm swap
109backing is generally preferable over
110.Cm malloc
111backing.
112.El
113.It Fl f Ar file
114Filename to use for the vnode type memory disk. Options
115.Fl a
116and
117.Fl t Ar vnode
118are implied if not specified.
119.It Fl l
120List configured devices.
121If given with
122.Fl u ,
123display details about that particular device.
124If
125.Fl v
126option specified, show all details.
127.It Fl n
128When printing md device names, print only the unit number without the
129md prefix.
130.It Fl s Ar size
131Size of the memory disk.
132.Ar Size
133is the number of 512 byte sectors unless suffixed with a
134.Cm b , k , m , g ,
135or
136.Cm t
137which
138denotes byte, kilobyte, megabyte, gigabyte and terabyte respectively. Options
139.Fl a
140and
141.Fl t Ar swap
142are implied if not specified.
143.It Fl S Ar sectorsize
144Sectorsize to use for malloc backed device.
145.It Fl x Ar sectors/track
146See the description of the
147.Fl y
148option below.
149.It Fl y Ar heads/cylinder
150For
151.Cm malloc
152or
153.Cm vnode
154backed devices, the
155.Fl x
156and
157.Fl y
158options can be used to specify a synthetic geometry.
159This is useful for constructing bootable images for later download to
160other devices.
161.It Fl o Oo Cm no Oc Ns Ar option
162Set or reset options.
163.Bl -tag -width indent
164.It Oo Cm no Oc Ns Cm async
165For
166.Cm vnode
167backed devices: avoid
168.Dv IO_SYNC
169for increased performance but
170at the risk of deadlocking the entire kernel.
171.It Oo Cm no Oc Ns Cm reserve
172Allocate and reserve all needed storage from the start, rather than as needed.
173.It Oo Cm no Oc Ns Cm cluster
174Enable clustering on this disk.
175.It Oo Cm no Oc Ns Cm compress
176Enable/Disable compression features to reduce memory usage.
177.It Oo Cm no Oc Ns Cm force
178Disable/Enable extra sanity checks to prevent the user from doing something
179that might adversely affect the system.
180.It Oo Cm no Oc Ns Cm readonly
181Enable/Disable readonly mode.
182.El
183.It Fl u Ar unit
184Request a specific unit number for the
185.Xr md 4
186device instead of automatic allocation.
187.El
188.Sh EXAMPLES
189To create a 4 megabyte
190.Xr malloc 9
191backed memory disk.
192The name of the allocated unit will be output on stdout like
193.Dq Li md3 :
194.Pp
195.Dl mdconfig -a -t malloc -s 4m
196.Pp
197To create a disk named
198.Pa /dev/md4
199with
200.Pa /tmp/boot.flp
201as backing storage:
202.Pp
203.Dl mdconfig -a -t vnode -f /tmp/boot.flp -u 4
204.Pp
205To detach and free all resources used by
206.Pa /dev/md4 :
207.Pp
208.Dl mdconfig -d -u 4
209.Pp
210To create a 128MByte swap backed disk, initialize an
211.Xr ffs 7
212file system on it, and mount it on
213.Pa /tmp :
214.Bd -literal -offset indent
215mdconfig -a -t swap -s 128M -u 10
216newfs -U /dev/md10
217mount /dev/md10 /tmp
218chmod 1777 /tmp
219.Ed
220.Pp
221To create a 5MB file-backed disk
222.Ns ( Fl a
223and
224.Fl t Ar vnode
225are implied):
226.Bd -literal -offset indent
227dd if=/dev/zero of=somebackingfile bs=1k count=5k
228mdconfig -f somebackingfile -u 0
229bsdlabel -w md0 auto
230newfs md0c
231mount /dev/md0c /mnt
232.Ed
233.Pp
234To create an
235.Xr md 4
236device out of an ISO 9660 CD image file
237.Ns ( Fl a
238and
239.Fl t Ar vnode
240are implied), using the first available
241.Xr md 4
242device, and then mount the new memory disk:
243.Bd -literal -offset indent
244mount -t cd9660 /dev/`mdconfig -f cdimage.iso` /mnt
245.Ed
246.Sh SEE ALSO
247.Xr md 4 ,
248.Xr ffs 7 ,
249.Xr bsdlabel 8 ,
250.Xr fdisk 8 ,
251.Xr mdmfs 8 ,
252.Xr malloc 9
253.Sh HISTORY
254The
255.Nm
256utility first appeared in
257.Fx 5.0
258as a cleaner replacement for the
259.Xr vn 4
260and
261.Xr vnconfig 8
262combo.
263.Sh AUTHORS
264The
265.Nm
266utility was written by
267.An Poul-Henning Kamp
268.Aq phk@FreeBSD.org .
269