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