freebsd-skq/share/man/man4/md.4
ian 783b0eb845 Add a new kernel config option, MD_ROOT_READONLY, which forces on the
MD_READONLY flag for the md device automatically instantiated during
kernel init for an mdroot filesystem.

Note that there is specifically and by design no tunable or sysctl
control over this feature.  Without this option, you already have control
over whether the mdroot fs is writeable using vfs.root.mountfrom.options
from loader(8), the root_rw_mount rcvar, and by using "mount -u[rw] /"
or equivelent on the fly.  This option is being added to provide a way
to make the mdroot fs truly immutable before userland code begins running.

Differential Revision:	https://reviews.freebsd.org/D13411
2017-12-20 18:23:22 +00:00

126 lines
3.0 KiB
Groff

.\" ----------------------------------------------------------------------------
.\" "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 December 7, 2017
.Dt MD 4
.Os
.Sh NAME
.Nm md
.Nd memory disk
.Sh SYNOPSIS
To compile this driver into the kernel,
place the following lines in your
kernel configuration file:
.Bd -ragged -offset indent
.Cd "device md"
.Ed
.Pp
Alternatively, to load the driver as a
module at boot time, place the following line in
.Xr loader.conf 5 :
.Bd -literal -offset indent
geom_md_load="YES"
.Ed
.Sh DESCRIPTION
The
.Nm
driver provides support for four kinds of memory backed virtual disks:
.Bl -tag -width preload
.It Cm malloc
Backing store is allocated using
.Xr malloc 9 .
Only one malloc-bucket is used, which means that all
.Nm
devices with
.Cm malloc
backing must share the malloc-per-bucket-quota.
The exact size of this quota varies, in particular with the amount
of RAM in the
system.
The exact value can be determined with
.Xr vmstat 8 .
.It Cm preload
A file loaded by
.Xr loader 8
with type
.Sq md_image
is used for backing store.
For backwards compatibility the type
.Sq mfs_root
is also recognized.
If the kernel is created with option
.Dv MD_ROOT
the first preloaded image found will become the root file system.
.It Cm vnode
A regular file is used as backing store.
This allows for mounting ISO images without the tedious
detour over actual physical media.
.It Cm swap
Backing store is allocated from buffer memory.
Pages get pushed out to the swap when the system is under memory
pressure, otherwise they stay in the operating memory.
Using
.Cm swap
backing is generally preferable over
.Cm malloc
backing.
.El
.Pp
For more information, please see
.Xr mdconfig 8 .
.Sh EXAMPLES
To create a kernel with a ramdisk or MD file system, your kernel config
needs the following options:
.Bd -literal -offset indent
options MD_ROOT # MD is a potential root device
options MD_ROOT_READONLY # disallow mounting root writeable
options MD_ROOT_SIZE=8192 # 8MB ram disk
makeoptions MFS_IMAGE=/h/foo/ARM-MD
options ROOTDEVNAME=\\"ufs:md0\\"
.Ed
.Pp
The image in
.Pa /h/foo/ARM-MD
will be loaded as the initial image each boot.
To create the image to use, please follow the steps to create a file-backed
disk found in the
.Xr mdconfig 8
man page.
Other tools will also create these images, such as NanoBSD.
.Sh SEE ALSO
.Xr gpart 8 ,
.Xr loader 8 ,
.Xr mdconfig 8 ,
.Xr mdmfs 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
.Tn PicoBSD
and in the
.Fx
installation process.
.Pp
The
.Nm
driver did a hostile takeover of the
.Xr vn 4
driver in
.Fx 5.0 .
.Sh AUTHORS
The
.Nm
driver was written by
.An Poul-Henning Kamp Aq Mt phk@FreeBSD.org .