xref: /freebsd/share/man/man4/md.4 (revision b601c69bdbe8755d26570261d7fd4c02ee4eff74)
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 SEE ALSO
99.Xr disklabel 5 ,
100.Xr disklabel 8 ,
101.Xr fdisk 8 ,
102.Xr loader 8 ,
103.Xr newfs 8 ,
104.Xr vmstat 8
105.Sh HISTORY
106The
107.Nm
108driver first appeared in
109.Fx 4.0
110as a cleaner replacement
111for the MFS functionality previously used in PicoBSD
112and in the FreeBSD installation process.
113.Sh AUTHORS
114The
115.Nm
116driver was written by
117.An Poul-Henning Kamp
118.Aq phk@FreeBSD.org .
119