Memory based file system (ramdisk) on FreeBSD

To create a ramdisk for /tmp and detach it on FreeBSD 8
# /sbin/mdmfs -M -S -o async -s size md0 /tmp

Don't forget to chmod +w for read/write
# chmod +w /tmp

Detach it and delete from /dev/md0
# /sbin/mdconfig -d -u 0

There is a shell script for the operation

%cat ramdisk.sh
#!/bin/sh

case "$1" in
create)
/sbin/mdmfs -M -S -o async -s 18432m md0 /tmp
/bin/chmod 777 /tmp
echo "18G ramdisk created on md0 and mounted on /tmp"
exit 0
;;
destory)
/sbin/umount /tmp
/sbin/mdconfig -d -u 0
echo "ramdisk umounted from /tmp and destory from md0"
;;
*)
echo "Usage: `basename $0` {create|destory}" >&2
exit 64
;;
esac
Caution! This is for specificed purpose only! You have to modify the parameters if you want to use it.

Comments

Popular posts from this blog

How to construct a B+ tree with example

How to show only month and year fields in android Date-picker?

Visitor Counter Script Using PHP