# automating RamDisk creating



## grdt (Jun 16, 2013)

I've just installed FreeBSD 9.1, and are on the way to install Qmail, but come into an issue, that I will put /var/qmail/tmp on a RAMdisk. On CentOS it's done like automating RAMdisk creating, and add this to my /etc/rc.local like:
`# /sbin/mke2fs -q -m 0 /dev/ram0`  (format the ramdisk)
`# /bin/mount /dev/ram0 /var/qmail/tmp`  (mount the ramdisk to the directory)
`# /bin/chown qmailq qmail /var/qmail/tmp`
`# /bin/chmod 1777 /var/qmail/tmp`

So, how could this be done in FreeBSD?


----------



## ShelLuser (Jun 16, 2013)

grdt said:
			
		

> I've just installed FreeBSD 9.1, and are on the way to install Qmail, but come into an issue, that I will put /var/qmail/tmp on a RAMdisk.


Why would you want to do that?



			
				grdt said:
			
		

> So, how could this be done in FreeBSD?


First of all I think you may be trying to solve a problem which isn't even there in the first place. You really do not want to treat FreeBSD as if it was Linux because that approach will make you run into issues in the future.

As to your question: you might want to look into the mdconfig(8) manual page ("Memory Disk Config") although I think tmpfs(5) could also be a very liable solution.

From the top of my head; to setup a memory disk all you would basically need is something like:


```
md  /var/qmail/tmp   mfs   rw,-s128M 0 0
```
IF I understood right (but I suggest you also check these manual pages to be sure) then this will tell FreeBSD to use mdconfig to setup the file system. The -s is nothing more but a command line option required for mdconfig to specify the size of the memory disk.

Using tmpfs should be pretty straight forward I think, the manual page has all the details.

I can't say which out of these two is better. But I do wonder why you'd want to do this, in general UFS (or maybe ZFS if that's being used) isn't all that slow.


----------



## grdt (Jun 16, 2013)

ShelLuser said:
			
		

> Why would you want to do that?
> 
> I've a script, available to act as front-end for qmail-queue allowing to run Spam and Virus checking on a RAM-Disk.
> 
> ...



Will do look into this.


----------



## grdt (Jun 16, 2013)

I've a script - available to act as front-end for qmail-queue allowing to run *s*pam and *v*irus checking on a RAM-*d*isk.


----------

