xref: /freebsd/sbin/mdconfig/mdconfig.8 (revision 315ee00f)
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 August 27, 2021
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 mustdealloc
248For
249.Cm vnode
250backed devices: detect whether hole-punching is supported by the underlying file
251system.
252If the file system supports hole-punching, then to handle a
253.Dv BIO_DELETE
254request, some or all of the request's operation range may be turned into a hole
255in the file used for backing store.
256Any parts which are not turned into holes are zero-filled in
257the file.
258If the file system does not support
259hole-punching,
260.Dv BIO_DELETE
261requests to the device are not handled and will fail with
262.Er EOPNOTSUPP .
263.Pp
264When
265.Cm mustdealloc
266is not specified or
267.Oo Cm no Oc Ns Cm mustdealloc
268is specified, for a
269.Dv BIO_DELETE
270request, if the file system supports hole-punching, some or all of the request's
271operation range may be turned into a hole in the file used for backing store.
272Any parts which are not turned into holes are zero-filled in the file.
273If the file system of the vnode type memory disk does not support hole-punching,
274the request's operation range is zero-filled in the file.
275.It Oo Cm no Oc Ns Cm readonly
276Enable/disable readonly mode.
277.It Oo Cm no Oc Ns Cm verify
278For
279.Cm vnode
280backed devices: enable/disable requesting verification of the
281file used for backing store.
282The type of verification depends on which security features are available.
283One example of verification is testing file integrity with
284checksums or cryptographic signatures.
285.El
286.It Fl u Ar unit
287Request a specific unit number or device name for the
288.Xr md 4
289device instead of automatic allocation.
290If a device name is specified, it must start with
291.Dq md
292followed by the unit number.
293.El
294.Pp
295The last form,
296.Nm
297.Ar file ,
298is provided for convenience as an abbreviation of
299.Nm
300.Fl a
301.Fl t Cm vnode
302.Fl f Ar file .
303.Sh EXAMPLES
304Create a disk with
305.Pa /tmp/boot.flp
306as backing storage.
307The name of the allocated unit will be printed on stdout, such as
308.Dq Li md0 :
309.Bd -literal -offset indent
310mdconfig /tmp/boot.flp
311.Ed
312.Pp
313Create a 1 gigabyte swap backed memory disk named
314.Dq Li md3 :
315.Bd -literal -offset indent
316mdconfig -s 1g -u md3
317.Ed
318.Pp
319Detach and free all resources used by
320.Pa /dev/md3 :
321.Bd -literal -offset indent
322mdconfig -du md3
323.Ed
324.Pp
325Show detailed information on current memory disks:
326.Bd -literal -offset indent
327mdconfig -lv
328.Ed
329.Pp
330Resize the
331.Dq Li md3
332memory disk to 2 gigabytes:
333.Bd -literal -offset indent
334mdconfig -rs 2g -u md3
335.Ed
336.Pp
337Create a 1 gigabyte swap backed disk, initialize an
338.Xr ffs 7
339file system on it, and mount it on
340.Pa /tmp :
341.Bd -literal -offset indent
342mdconfig -s 1g -u md10
343newfs -U /dev/md10
344mount /dev/md10 /tmp
345chmod 1777 /tmp
346.Ed
347.Pp
348Create a memory disk out of an ISO 9660 CD image file,
349using the first available
350.Xr md 4
351device, and then mount it:
352.Bd -literal -offset indent
353mount -t cd9660 /dev/`mdconfig -f cdimage.iso` /mnt
354.Ed
355.Pp
356Create a file-backed device from a hard disk image that begins
357with 512K of raw header information.
358.Xr gnop 8
359is used to skip over the header information, positioning
360.Pa md1.nop
361to the start of the filesystem in the image.
362.Bd -literal -offset indent
363mdconfig -u md1 -f diskimage.img
364gnop create -o 512K md1
365mount /dev/md1.nop /mnt
366.Ed
367.Sh SEE ALSO
368.Xr fpathconf 2 ,
369.Xr fspacectl 2 ,
370.Xr open 2 ,
371.Xr md 4 ,
372.Xr ffs 7 ,
373.Xr gpart 8 ,
374.Xr mdmfs 8 ,
375.Xr malloc 9 ,
376.Xr vn_deallocate 9
377.Sh HISTORY
378The
379.Nm
380utility first appeared in
381.Fx 5.0
382as a cleaner replacement for the vn kernel module
383and the vnconfig utility combo.
384.Sh AUTHORS
385The
386.Nm
387utility was written by
388.An Poul-Henning Kamp Aq Mt phk@FreeBSD.org .
389