For the complete documentation index, see llms.txt. This page is also available as Markdown.

25.2 Virtual Memory Disks

In addition to physical disks, FreeBSD also supports creating and using virtual memory disks. One typical use of virtual memory disks is to access the contents of an ISO file system without first burning it to a CD or DVD and then mounting the CD/DVD media. See the "Installing Software from DVD" section for more information.

FreeBSD also supports creating memory-based or file-based virtual memory disks using the mdconfig command, allocating storage from memory regions or hard disks respectively. The former is a memory-based virtual memory disk, and the latter is a file-based virtual memory disk.

Creating a Memory-Based Virtual Memory Disk

To create a memory-based virtual memory disk, use -t swap to specify the memory disk type, and specify the size of the virtual memory disk to create.

Then format the virtual memory disk and mount it. This example creates a virtual memory disk with a size of 50MB, numbered 1.

# mdconfig -a -t swap -s 50m -u 1

Check the memory disk number:

# mdconfig -l
md1

Format the virtual memory disk as a UFS file system, then mount it:

# newfs -U md1
/dev/md1: 50.0MB (102400 sectors) block size 32768, fragment size 4096
	using 4 cylinder groups of 12.53MB, 401 blks, 1664 inodes.
	with soft updates
super-block backups (for fsck_ffs -b #) at:
 192, 25856, 51520, 77184
# mount /dev/md1 /mnt

Check the memory disk file system:

Creating a File-Based Virtual Memory Disk

To create a file-based virtual memory disk, first allocate a region from the disk. This example creates a 50MB sparse file newimage:

Next, attach the file to a virtual memory disk:

Assign a GPT partition table to the virtual memory disk:

Format it as a UFS file system:

Mount the virtual memory disk:

Verify the file-backed disk size:

Last updated