MDCONFIG(8)
๐พ MDCONFIG(8) โ the mdconfig girlie's guide
okay so bestie, welcome to mdconfig, from the System Manager's Manual, and it's literally the tool that creates and controls memory disks. iconic behavior only ๐
โจ NAME โจ
mdconfig โ create and control memory disks ๐ซถ
๐ธ SYNOPSIS ๐ธ
mdconfig -a -t type [-n] [-o [no]option] ... [-f file] [-s size]
[-S sectorsize] [-u unit] [-x sectors/track]
[-y heads/cylinder] [-L label]
mdconfig -d -u unit [-o [no]force]
mdconfig -r -u unit -s size [-o [no]force]
mdconfig -l [-n] [-v] [-f file] [-u unit]
mdconfig file
๐ฆ DESCRIPTION ๐ฆ
The mdconfig utility creates and controls md(4) devices. no cap, that's the whole vibe.
The options are basically "pick your action", and here's the tea on each one:
-aโ Attach a memory disk. This configures and attaches a memory disk with the parameters you specified, and attaches it to the system. If you didn't pass-u unit, the newly created device name gets printed on stdout. cute little surprise ๐-dโ Detach a memory disk from the system and release all resources. say bye ๐-rโ Resize a memory disk.-t typeโ Select the type of the memory disk. and bestie, the types are:mallocโ Storage for this type of memory disk is allocated withmalloc(9). This limits the size to the malloc bucket limit in the kernel. โ ๏ธ And like, if the-o reserveoption is not set, creating and filling a large malloc-backed memory disk is a very easy way to panic the system. not a slay, an actual panic, be careful ๐vnodeโ A file specified with-f filebecomes the backing store for this memory disk.swapโ Storage for this type of memory disk is allocated from buffer memory. Pages get pushed out to swap when the system is under memory pressure, otherwise they stay in the operating memory. Using swap backing is generally preferred instead of using malloc backing. the responsible queen choice ๐nullโ Bitsink; all writes do nothing, all reads return zeroes. it's giving void, it's giving nothingness, it's giving black hole ๐ณ๏ธ
-f fileโ Filename to use for thevnodetype memory disk. The-aand-t vnodeoptions are implied if not specified. so convenient, we love an auto-fill โจ-lโ List configured devices. If given with-u, display details about that particular device. If given with-f file, displaymd(4)device names of which file is used as the backing store. If both-uand-foptions are specified, display devices which match the two conditions. And if the-voption is specified, show all details. full lore drop ๐-nโ When printingmd(4)device names, print only the unit number without themd(4)prefix. minimalism ๐-s sizeโ Size of the memory disk. Size is the number of 512 byte sectors unless suffixed with ab,k,m,g,t, orpwhich denotes byte, kilobyte, megabyte, gigabyte, terabyte and petabyte respectively. When used without the-roption, the-aand-t swapoptions are implied if not specified. math but make it cute ๐งฎ-S sectorsizeโ Sectorsize to use for the memory disk, in bytes.-x sectors/trackโ See the description of the-yoption below. yes bestie, it's a package deal ๐ค-y heads/cylinderโ Formallocorvnodebacked devices, the-xand-yoptions can be used to specify a synthetic geometry. This is useful for constructing bootable images for later download to other devices. fake it till you make it ๐-L labelโ Associate a label (arbitrary string) with the new memory disk. The label can then be inspected with
mdconfig -l -v
name your child, give it a little name tag ๐
-o [no]optionโ Set or reset options. here's the whole menu, bestie:[no]asyncโ Forvnodebacked devices: avoidIO_SYNCfor increased performance but at the risk of deadlocking the entire kernel. ๐ฅ fast, but the entire kernel, bestie. the entire kernel.[no]cacheโ Forvnodebacked devices: enable/disable caching of data in system caches. The default is to not cache.
Accesses via the device are converted to accesses via the vnode. The caching policy for the vnode is used initially. This is normally to cache. This caching policy is retained if the cache option is used. Otherwise, caching is limited by releasing data from caches soon after each access. The release has the same semantics as the POSIX_FADV_DONTNEED feature of posix_fadvise(2). The result is that with normal (non-zfs) caching, buffers are released from the buffer cache soon after they are constructed, but their data is kept in the page cache at lower priority.
The cache option tends to waste memory by giving unwanted double caching, but it saves time if there is memory to spare. double caching is lowkey wasteful but highkey speedy, pick your fighter ๐ญ
[no]reserveโ Allocate and reserve all needed storage from the start, rather than as needed. secure the bag upfront ๐ฐ[no]compressโ Enable/disable compression features to reduce memory usage. small and efficient, the dream ๐ธ[no]forceโ Disable/enable extra sanity checks to prevent the user from doing something that might adversely affect the system. This can be used with the-dflag to forcibly destroy anmd(4)disk that is still in use. โ ๏ธ this is the "ignore the vibes check" button, use it knowing the vibes were bad[no]mustdeallocโ Forvnodebacked devices: detect whether hole-punching is supported by the underlying file system. If the file system supports hole-punching, then to handle aBIO_DELETErequest, some or all of the request's operation range may be turned into a hole in the file used for backing store. Any parts which are not turned into holes are zero-filled in the file. If the file system does not support hole-punching,BIO_DELETErequests to the device are not handled and will fail withEOPNOTSUPP.
When mustdealloc is not specified or [no]mustdealloc is specified, for a BIO_DELETE request, if the file system supports hole-punching, some or all of the request's operation range may be turned into a hole in the file used for backing store. Any parts which are not turned into holes are zero-filled in the file. If the file system of the vnode type memory disk does not support hole-punching, the request's operation range is zero-filled in the file. ๐ณ๏ธ holes within holes, it's giving layered lore
[no]readonlyโ Enable/disable readonly mode. look, don't touch ๐[no]verifyโ Forvnodebacked devices: enable/disable requesting verification of the file used for backing store. The type of verification depends on which security features are available. One example of verification is testing file integrity with checksums or cryptographic signatures. trust but verify, literally ๐
-u unitโ Request a specific unit number or device name for themd(4)device instead of automatic allocation. If a device name is specified, it must start with โmdโ followed by the unit number. you want that one, you get that one โจ
And the very last form, mdconfig file, is provided for convenience as an abbreviation of mdconfig -a -t vnode -f file. shortcut queen ๐
๐ EXAMPLES ๐
Create a disk with /tmp/boot.flp as backing storage. The name of the allocated unit will be printed on stdout, such as โmd0โ:
mdconfig /tmp/boot.flp
Create a 1 gigabyte swap backed memory disk named โmd3โ:
mdconfig -s 1g -u md3
Detach and free all resources used by /dev/md3:
mdconfig -du md3
Show detailed information on current memory disks:
mdconfig -lv
Resize the โmd3โ memory disk to 2 gigabytes:
mdconfig -rs 2g -u md3
Create a 1 gigabyte swap backed disk, initialize an ffs(4) file system on it, and mount it on /tmp:
mdconfig -s 1g -u md10
newfs -U /dev/md10
mount /dev/md10 /tmp
chmod 1777 /tmp
Create a memory disk out of an ISO 9660 CD image file, using the first available md(4) device, and then mount it:
mount -t cd9660 /dev/`mdconfig -f cdimage.iso` /mnt
Create a file-backed device from a hard disk image that begins with 512K of raw header information. gnop(8) is used to skip over the header information, positioning md1.nop to the start of the filesystem in the image.
mdconfig -u md1 -f diskimage.img
gnop create -o 512K md1
mount /dev/md1.nop /mnt
๐ SEE ALSO ๐
fpathconf(2), fspacectl(2), open(2), ffs(4), md(4), gpart(8), mdmfs(8), malloc(9), vn_deallocate(9) โ the whole friend group ๐ซถ
โญ HISTORY โญ
The mdconfig utility first appeared in FreeBSD 5.0 as a cleaner replacement for the vn kernel module and the vnconfig utility combo. glow-up of the century, honestly ๐
๐ AUTHORS ๐
The mdconfig utility was written by Poul-Henning Kamp <phk@FreeBSD.org>. legend behavior, we stan ๐
and that's the page bestie!! this one's from the Debian edition, dated June 1, 2024 โ go forth and make memory disks, but like, responsibly ๐ โจ
๐ฆ where this page comes from
- freebsd 15.1: base 15.1
- Copyright (c) 1993 University of Utah
- Copyright (c) 1980, 1989, 1991, 1993 The Regents of the University of California. All rights reserved
- Copyright (c) 2000 Poul-Henning Kamp All rights reserved
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms