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.\" $DragonFly: src/share/man/man4/md.4,v 1.5 2007/11/07 21:38:00 swildner Exp $ 10.\" 11.Dd September 28, 2009 12.Dt MD 4 13.Os 14.Sh NAME 15.Nm md 16.Nd memory disk 17.Sh SYNOPSIS 18.Cd device md 19.Pp 20To specify the default maximum size of 21.Xr kmalloc 9 22backed disks: 23.Cd options MD_NSECT=20000 24.Pp 25Alternatively, to load the driver as a module at boot time, place the 26following line in 27.Pa /boot/loader.conf : 28.Bd -literal -offset indent 29md_load="YES" 30.Ed 31.Sh DESCRIPTION 32The 33.Nm 34driver provides support for two kinds of memory backed virtual disks: 35.Xr kmalloc 9 36backed 37and pre-loaded module backed. 38.Pp 39The 40.Xr kmalloc 9 41backed 42disks 43are severely limited in size by constraints imposed by 44.Xr kmalloc 9 . 45Specifically, only one malloc bucket is used, which means that all 46.Nm 47devices with 48.Xr kmalloc 9 49backing must share the malloc per-bucket quota. 50The exact size of this quota varies, 51in particular with the amount of RAM in the system. 52The exact value can be determined with 53.Xr vmstat 8 . 54.Pp 55A sector filled with identical bytes does not consume storage, 56and therefore the storage allocated by a 57.Nm 58disk can be freed with a command such as this: 59.Bd -literal -offset indent 60dd if=/dev/zero of=/dev/md567 61.Ed 62.Pp 63The default maximum size of a 64.Nm 65disk 66backed by 67.Xr kmalloc 9 68is 20,000 sectors of 512 bytes each. 69This can be changed 70with the kernel option 71.Dv MD_NSECT . 72.Pp 73At boot time the 74.Nm 75driver will search for pre-loaded modules of type 76.Sq md_image 77and instantiate a 78.Nm 79device for each of these modules. 80The type 81.Sq mfs_root 82is also allowed for backward compatibility. 83These devices are backed by the RAM reserved by the 84.Xr loader 8 , 85and as such not limited by the 86.Xr kmalloc 9 87size constraints. 88However, this also means that the storage cannot be released. 89For the same reason, 90the 91.Dq identical byte 92detection is not applicable. 93.Pp 94The 95.Nm 96driver uses the 97.Dq almost-clone 98convention, 99whereby opening device number N creates device instance number N+1. 100.Pp 101The 102.Xr vmstat 8 103utility can be used to monitor memory usage by 104.Xr kmalloc 9 105backed 106.Nm 107disks, 108but not those backed by pre-loaded modules. 109.Sh EXAMPLES 110To mount a 111.Xr kmalloc 9 112backed 113.Nm 114device on 115.Pa /tmp : 116.Bd -literal 117if [ -e /dev/md0 ]; then 118 newfs /dev/md0 && \\ 119 mount /dev/md0 /tmp && \\ 120 chmod 1777 /tmp 121fi 122.Ed 123.Sh SEE ALSO 124.Xr disklabel 5 , 125.Xr disklabel 8 , 126.Xr fdisk 8 , 127.Xr loader 8 , 128.Xr newfs 8 , 129.Xr vmstat 8 130.Sh HISTORY 131The 132.Nm 133driver first appeared in 134.Fx 4.0 135as a cleaner replacement 136for the MFS functionality previously used in PicoBSD 137and in the 138.Fx 139installation process. 140.Sh AUTHORS 141The 142.Nm 143driver was written by 144.An Poul-Henning Kamp 145.Aq phk@FreeBSD.org . 146