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