User Tools

Site Tools


unix:freebsd:ramdisks

RamDisks

Found this nice little script that avoids some of the confusion of creating RamDisks under FreeBSD. Just making my own copy here. It creates md10 only, and frees it when you're done (just change the variables).

This creates it as a RAMDisk on Swap. If you want to use main memory, add -M in the mdmfs command

makeRamDisk.sh
#!/bin/sh
 
#
# Taken from http://www.freebsdwiki.net/index.php/Create_RAMdisks_under_FreeBSD_5.x
#
# Tested and works on FreeBSD 10
 
case "$1" in
start)
        /sbin/mdmfs -s 256M md10 /mnt/ramdisk
        echo "256MB ramdisk created on /dev/md10 and mounted on /mnt/ramdisk"
        /sbin/mdconfig -l -u 10
        exit 0
        ;;
stop)
        /sbin/umount /mnt/ramdisk
        /sbin/mdconfig -d -u 10
        echo "ramdisk unmounted from /mnt/ramdisk and deleted from /dev/md10"
        /sbin/mdconfig -l
        ;;
*)
        echo "Usage: `basename $0` {start|stop}" >&2
        exit 64
        ;;
esac
unix/freebsd/ramdisks.txt · Last modified: 2016/09/08 00:11 by 127.0.0.1