Initial import from FreeBSD RELENG_4:
[dragonfly.git] / share / man / man4 / md.4
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
19 To specify the default maximum size of
20 .Xr malloc 9
21 backed disks:
22 .Cd options MD_NSECT=20000
23 .Sh DESCRIPTION
24 The
25 .Nm
26 driver provides support for two kinds of memory backed virtual disks:
27 .Xr malloc 9
28 backed
29 and pre-loaded module backed.
30 .Pp
31 The
32 .Xr malloc 9
33 backed
34 disks
35 are severely limited in size by constraints imposed by
36 .Xr malloc 9 .
37 Specifically, only one malloc bucket is used, which means that all
38 .Nm
39 devices with
40 .Xr malloc 9
41 backing must share the malloc per-bucket quota.
42 The exact size of this quota varies,
43 in particuar with the amount of RAM in the system.
44 The exact value can be determined with
45 .Xr vmstat 8 .
46 .Pp
47 A sector filled with identical bytes does not consume storage,
48 and therefore the storage allocated by a
49 .Nm
50 disk can be freed with a command such as this:
51 .Bd -literal -offset indent
52 dd if=/dev/zero of=/dev/md567
53 .Ed
54 .Pp
55 The default maximum size of a
56 .Nm
57 disk
58 backed by
59 .Xr malloc 9
60 is 20,000 sectors of 512 bytes each.
61 This can be changed
62 with the kernel option
63 .Dv MD_NSECT .
64 .Pp
65 At boot time the
66 .Nm
67 driver will search for pre-loaded modules of type
68 .Sq md_image
69 and instantiate a
70 .Nm
71 device for each of these modules.
72 The type
73 .Sq mfs_root
74 is also allowed for backward compatibility.
75 These devices are backed by the RAM reserved by the
76 .Xr loader 8 ,
77 and as such not limited by the
78 .Xr malloc 9
79 size constraints.
80 However, this also means that the storage cannot be released.
81 For the same reason,
82 the
83 .Dq identical byte
84 detection is not applicable.
85 .Pp
86 The
87 .Nm
88 driver uses the
89 .Dq almost-clone
90 convention,
91 whereby opening device number N creates device instance number N+1.
92 .Pp
93 The
94 .Xr vmstat 8
95 utility can be used to monitor memory usage by
96 .Xr malloc 9
97 backed
98 .Nm
99 disks,
100 but not those backed by pre-loaded modules.
101 .Sh EXAMPLES
102 To mount a
103 .Xr malloc 9
104 backed
105 .Nm
106 device on
107 .Pa /tmp :
108 .Bd -literal
109 if [ -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
114 fi
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
124 The
125 .Nm
126 driver first appeared in
127 .Fx 4.0
128 as a cleaner replacement
129 for the MFS functionality previously used in PicoBSD
130 and in the
131 .Fx
132 installation process.
133 .Sh AUTHORS
134 The
135 .Nm
136 driver was written by
137 .An Poul-Henning Kamp
138 .Aq phk@FreeBSD.org .