xref: /freebsd/share/man/man4/md.4 (revision 77a0943ded95b9e6438f7db70c4a28e4d93946d4)
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$
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 .
37The limit imposed depends on the amount of physical RAM in the machine,
38and covers all
39.Xr malloc 9
40backed instances of
41.Nm
42devices.
43.Pp
44A sector filled with identical bytes does not consume storage,
45and therefore the storage allocated by a
46.Nm
47disk can be freed with a command such as this:
48.Bd -literal -offset indent
49dd if=/dev/zero of=/dev/md567
50.Ed
51.Pp
52The default maximum size of a
53.Nm
54disk
55backed by
56.Xr malloc 9
57is 20,000 sectors of 512 bytes each.
58This can be changed
59with the kernel option
60.Dv MD_NSECT .
61.Pp
62At boot time the
63.Nm
64driver will search for pre-loaded modules of type
65.Sq md_image
66and instantiate a
67.Nm
68device for each of these modules.
69The type
70.Sq mfs_root
71is also allowed for backward compatibility.
72These devices are backed by the RAM reserved by the
73.Xr loader 8 ,
74and as such not limited by the
75.Xr malloc 9
76size constraints.
77However, this also means that the storage cannot be released.
78For the same reason,
79the
80.Dq identical byte
81detection is not applicable.
82.Pp
83The
84.Nm
85driver uses the
86.Dq almost-clone
87convention,
88whereby opening device number N creates device instance number N+1.
89.Pp
90The
91.Xr vmstat 8
92utility can be used to monitor memory usage by
93.Xr malloc 9
94backed
95.Nm
96disks,
97but not those backed by pre-loaded modules.
98.Sh EXAMPLES
99To mount a
100.Xr malloc 9
101backed
102.Nm
103device on
104.Pa /tmp :
105.Bd -literal
106if [ -e /dev/md0 -a -e /dev/md0c ]; then
107	disklabel -r -w md0 auto && \\
108	newfs /dev/md0c && \\
109	mount /dev/md0c /tmp && \\
110	chmod 1777 /tmp
111fi
112.Ed
113.Sh SEE ALSO
114.Xr disklabel 5 ,
115.Xr disklabel 8 ,
116.Xr fdisk 8 ,
117.Xr loader 8 ,
118.Xr newfs 8 ,
119.Xr vmstat 8
120.Sh HISTORY
121The
122.Nm
123driver first appeared in
124.Fx 4.0
125as a cleaner replacement
126for the MFS functionality previously used in PicoBSD
127and in the
128.Fx
129installation process.
130.Sh AUTHORS
131The
132.Nm
133driver was written by
134.An Poul-Henning Kamp
135.Aq phk@FreeBSD.org .
136