xref: /dragonfly/share/man/man4/md.4 (revision 984263bc)
1.\" ----------------------------------------------------------------------------
2.\" "THE BEER-WARE LICENSE" (Revision 42):
3.\" <phk@FreeBSD.ORG> wrote this file.  As long as you retain this notice you
4.\" can do whatever you want with this stuff. If we meet some day, and you think
5.\" this stuff is worth it, you can buy me a beer in return.   Poul-Henning Kamp
6.\" ----------------------------------------------------------------------------
7.\"
8.\" $FreeBSD: src/share/man/man4/md.4,v 1.3.2.4 2001/06/18 22:00:12 dd Exp $
9.\"
10.Dd July 4, 2000
11.Dt MD 4
12.Os
13.Sh NAME
14.Nm md
15.Nd memory disk
16.Sh SYNOPSIS
17.Cd device md
18.Pp
19To specify the default maximum size of
20.Xr malloc 9
21backed disks:
22.Cd options MD_NSECT=20000
23.Sh DESCRIPTION
24The
25.Nm
26driver provides support for two kinds of memory backed virtual disks:
27.Xr malloc 9
28backed
29and pre-loaded module backed.
30.Pp
31The
32.Xr malloc 9
33backed
34disks
35are severely limited in size by constraints imposed by
36.Xr malloc 9 .
37Specifically, only one malloc bucket is used, which means that all
38.Nm
39devices with
40.Xr malloc 9
41backing must share the malloc per-bucket quota.
42The exact size of this quota varies,
43in particuar with the amount of RAM in the system.
44The exact value can be determined with
45.Xr vmstat 8 .
46.Pp
47A sector filled with identical bytes does not consume storage,
48and therefore the storage allocated by a
49.Nm
50disk can be freed with a command such as this:
51.Bd -literal -offset indent
52dd if=/dev/zero of=/dev/md567
53.Ed
54.Pp
55The default maximum size of a
56.Nm
57disk
58backed by
59.Xr malloc 9
60is 20,000 sectors of 512 bytes each.
61This can be changed
62with the kernel option
63.Dv MD_NSECT .
64.Pp
65At boot time the
66.Nm
67driver will search for pre-loaded modules of type
68.Sq md_image
69and instantiate a
70.Nm
71device for each of these modules.
72The type
73.Sq mfs_root
74is also allowed for backward compatibility.
75These devices are backed by the RAM reserved by the
76.Xr loader 8 ,
77and as such not limited by the
78.Xr malloc 9
79size constraints.
80However, this also means that the storage cannot be released.
81For the same reason,
82the
83.Dq identical byte
84detection is not applicable.
85.Pp
86The
87.Nm
88driver uses the
89.Dq almost-clone
90convention,
91whereby opening device number N creates device instance number N+1.
92.Pp
93The
94.Xr vmstat 8
95utility can be used to monitor memory usage by
96.Xr malloc 9
97backed
98.Nm
99disks,
100but not those backed by pre-loaded modules.
101.Sh EXAMPLES
102To mount a
103.Xr malloc 9
104backed
105.Nm
106device on
107.Pa /tmp :
108.Bd -literal
109if [ -e /dev/md0 -a -e /dev/md0c ]; then
110	disklabel -r -w md0 auto && \\
111	newfs /dev/md0c && \\
112	mount /dev/md0c /tmp && \\
113	chmod 1777 /tmp
114fi
115.Ed
116.Sh SEE ALSO
117.Xr disklabel 5 ,
118.Xr disklabel 8 ,
119.Xr fdisk 8 ,
120.Xr loader 8 ,
121.Xr newfs 8 ,
122.Xr vmstat 8
123.Sh HISTORY
124The
125.Nm
126driver first appeared in
127.Fx 4.0
128as a cleaner replacement
129for the MFS functionality previously used in PicoBSD
130and in the
131.Fx
132installation process.
133.Sh AUTHORS
134The
135.Nm
136driver was written by
137.An Poul-Henning Kamp
138.Aq phk@FreeBSD.org .
139