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