RAMdisks, creating under FreeBSD 5.x
From FreeBSDwiki
I invariably get irritated and confused by mdconfig's syntax, since I need it just often enough to never remember how to use it, and no more. And most of the readily google-able documentation on the web covers FreeBSD 4.x's vnconfig instead, which is useless if you're running a 5.x system. So I just wrote myself a handy little shell script that I keep in my home directory for reference's sake:
ph34r# cat makeramdisk.sh #!/bin/sh case "$1" in start) /sbin/mdconfig -a -t malloc -s 256M -u 10 /sbin/newfs -U /dev/md10 /sbin/mount /dev/md10 /mnt/ramdisk echo "256MB ramdisk created on /dev/md10 and mounted on /mnt/ramdisk" exit 0 ;; stop) /sbin/umount /mnt/ramdisk /sbin/mdconfig -d -u 10 echo "ramdisk unmounted from /mnt/ramdisk and deleted from /dev/md10" ;; *) echo "Usage: `basename $0` {start|stop}" >&2 exit 64 ;; esac
To use this script, you would type makeramdisk.sh start or makeramdisk.sh stop to create and mount, or dismount and delete, respectively, a 256MB RAMdisk on /dev/md10. You should be able to figure out from the examples what you'd need to do different to change the size of the drive, where you mount it, etc.