MDCONFIG(8)

๐Ÿ“ฆ
version 15.1 ยท 2 versions
, in freebsd 15.1

๐Ÿ’พ 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 with malloc(9). This limits the size to the malloc bucket limit in the kernel. โš ๏ธ And like, if the -o reserve option 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 file becomes 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 the vnode type memory disk. The -a and -t vnode options 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, display md(4) device names of which file is used as the backing store. If both -u and -f options are specified, display devices which match the two conditions. And if the -v option is specified, show all details. full lore drop ๐Ÿ“–
  • -n โ€” When printing md(4) device names, print only the unit number without the md(4) prefix. minimalism ๐Ÿ’…
  • -s size โ€” Size of the memory disk. Size is the number of 512 byte sectors unless suffixed with a b, k, m, g, t, or p which denotes byte, kilobyte, megabyte, gigabyte, terabyte and petabyte respectively. When used without the -r option, the -a and -t swap options 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 -y option below. yes bestie, it's a package deal ๐Ÿค
  • -y heads/cylinder โ€” For malloc or vnode backed devices, the -x and -y options 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 โ€” For vnode backed devices: avoid IO_SYNC for increased performance but at the risk of deadlocking the entire kernel. ๐Ÿ”ฅ fast, but the entire kernel, bestie. the entire kernel.
    • [no]cache โ€” For vnode backed 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 -d flag to forcibly destroy an md(4) disk that is still in use. โš ๏ธ this is the "ignore the vibes check" button, use it knowing the vibes were bad
  • [no]mustdealloc โ€” For vnode backed devices: detect whether hole-punching is supported by the underlying file system. If the file system supports hole-punching, then to handle a BIO_DELETE request, 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_DELETE requests to the device are not handled and will fail with EOPNOTSUPP.

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 โ€” For vnode backed 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 the md(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
  • ๐Ÿ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms