xref: /freebsd/share/man/man4/md.4 (revision f0cfa1b168014f56c02b83e5f28412cc5f78d117)
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 November 5, 2017
11.Dt MD 4
12.Os
13.Sh NAME
14.Nm md
15.Nd memory disk
16.Sh SYNOPSIS
17To compile this driver into the kernel,
18place the following lines in your
19kernel configuration file:
20.Bd -ragged -offset indent
21.Cd "device md"
22.Ed
23.Pp
24Alternatively, to load the driver as a
25module at boot time, place the following line in
26.Xr loader.conf 5 :
27.Bd -literal -offset indent
28geom_md_load="YES"
29.Ed
30.Sh DESCRIPTION
31The
32.Nm
33driver provides support for four kinds of memory backed virtual disks:
34.Bl -tag -width preload
35.It Cm malloc
36Backing store is allocated using
37.Xr malloc 9 .
38Only one malloc-bucket is used, which means that all
39.Nm
40devices with
41.Cm malloc
42backing must share the malloc-per-bucket-quota.
43The exact size of this quota varies, in particular with the amount
44of RAM in the
45system.
46The exact value can be determined with
47.Xr vmstat 8 .
48.It Cm preload
49A file loaded by
50.Xr loader 8
51with type
52.Sq md_image
53is used for backing store.
54For backwards compatibility the type
55.Sq mfs_root
56is also recognized.
57If the kernel is created with option
58.Dv MD_ROOT
59the first preloaded image found will become the root file system.
60.It Cm vnode
61A regular file is used as backing store.
62This allows for mounting ISO images without the tedious
63detour over actual physical media.
64.It Cm swap
65Backing store is allocated from buffer memory.
66Pages get pushed out to the swap when the system is under memory
67pressure, otherwise they stay in the operating memory.
68Using
69.Cm swap
70backing is generally preferable over
71.Cm malloc
72backing.
73.El
74.Pp
75For more information, please see
76.Xr mdconfig 8 .
77.Sh EXAMPLES
78To create a kernel with a ramdisk or MD file system, your kernel config
79needs the following options:
80.Bd -literal -offset indent
81options 	MD_ROOT			# MD is a potential root device
82options		MD_ROOT_SIZE=8192	# 8MB ram disk
83makeoptions	MFS_IMAGE=/h/foo/ARM-MD
84options 	ROOTDEVNAME=\\"ufs:md0\\"
85.Ed
86.Pp
87The image in
88.Pa /h/foo/ARM-MD
89will be loaded as the initial image each boot.
90To create the image to use, please follow the steps to create a file-backed
91disk found in the
92.Xr mdconfig 8
93man page.
94Other tools will also create these images, such as NanoBSD.
95.Sh SEE ALSO
96.Xr gpart 8 ,
97.Xr loader 8 ,
98.Xr mdconfig 8 ,
99.Xr mdmfs 8 ,
100.Xr newfs 8 ,
101.Xr vmstat 8
102.Sh HISTORY
103The
104.Nm
105driver first appeared in
106.Fx 4.0
107as a cleaner replacement
108for the MFS functionality previously used in
109.Tn PicoBSD
110and in the
111.Fx
112installation process.
113.Pp
114The
115.Nm
116driver did a hostile takeover of the
117.Xr vn 4
118driver in
119.Fx 5.0 .
120.Sh AUTHORS
121The
122.Nm
123driver was written by
124.An Poul-Henning Kamp Aq Mt phk@FreeBSD.org .
125