MD(4) | Device Drivers Manual | MD(4) |
md
— memory
disk
To compile this driver into the kernel, place the following lines in your kernel configuration file:
device md
Alternatively, to load the driver as a module at boot time, place the following line in loader.conf(5):
geom_md_load="YES"
The md
driver provides support for four
kinds of memory backed virtual disks:
malloc
md
devices with 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 vmstat(8).preload
If the kernel is created with option
MD_ROOT
the first preloaded image found will
become the root file system.
vnode
swap
swap
backing is generally
preferable over malloc
backing.For more information, please see mdconfig(8).
To create a kernel with a ramdisk or MD file system, your kernel config needs the following options:
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\"
The image in /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 mdconfig(8) man page. Other tools will also create these images, such as NanoBSD.
On armv6 and armv7 architectures, an MD_ROOT image larger than approximately 55 MiB may require building a custom kernel using several tuning options related to kernel memory usage.
options LOCORE_MAP_MB=<num>
options NKPT2PG=<num>
options VM_KMEM_SIZE_SCALE=<num>
The kernel and modules, including the root image, also consume KVA. The combination of a large root image and the default scaling may preallocate so much KVA that there is not enough remaining address space to allocate kernel stacks, IO buffers, and other resources that are not part of kmem_arena. Overallocating kmem_arena space is likely to manifest as failure to launch userland processes with "cannot allocate kernel stack" messages.
Setting the scale value too high may result in kernel failure to allocate memory because kmem_arena is too small, and the failure may require significant runtime to manifest. Empirically, a value of 5 works well for a 200 MiB root image on a system with 2 GiB of physical ram.
gpart(8), loader(8), mdconfig(8), mdmfs(8), newfs(8), vmstat(8)
The md
driver first appeared in
FreeBSD 4.0 as a cleaner replacement for the MFS
functionality previously used in PicoBSD and in the
FreeBSD installation process.
The md
driver did a hostile takeover of
the vn(4) driver in FreeBSD
5.0.
The md
driver was written by
Poul-Henning Kamp
<phk@FreeBSD.org>.
January 8, 2020 | Debian |