Create a 1G sized file

$ truncate +1G boot.disk

Create memory disk out of the file

$ mdconfig -f boot.disk
md0

$ ls -l /dev/md0
crw-r----- 1 root operator 0, 132 Aug 23 14:57 /dev/md0

Create a partitioning scheme (i.e. gpt below)

$ sudo gpart create -s gpt md0
md0 created

$ sudo gpart show md0
=> 34 2097085 md0 GPT (1.0G)
34 2097085 - free - (1G)

Add a new partition

$ sudo gpart add -t freebsd-ufs md0
md0p1 added
$ sudo gpart show md0
=> 34 2097085 md0 GPT (1.0G)
34 2097085 1 freebsd-ufs (1G)

Create a ufs filesystem

$ sudo newfs /dev/md0p1
/dev/md0p1: 1024.0MB (2097080 sectors) block size 32768, fragment size 4096
using 4 cylinder groups of 256.00MB, 8192 blks, 32768 inodes.
super-block backups (for fsck_ffs -b #) at:
192, 524480, 1048768, 1573056

Mount the filesystem

$ sudo mount /dev/md0p1 /mnt/
$ df -k
/dev/md0p1 1015416 8 934176 0% /mnt

$ sudo mdconfig -l
md0

undo the experiment

unmount /mnt
$ sudo umount /mnt/

detach the disk
$ sudo mdconfig -d -u 0