# Questions about ramdisk in FreeBSD



## PeteS (Dec 19, 2010)

Hi,

I need a ramdisk similar to the tmpfs /dev/shm that is automatically setup in debian.

Is FreeBSD doing anything similar automatically?

If not, what is the recommended way to set this up in the boot process?

Thanks in advance for your help,
Pete S


----------



## wblock@ (Dec 19, 2010)

You might explain what /dev/shm does, and why you need a ramdisk.  The situation may be different on FreeBSD.

For automatic setup, see mdmfs(8).  For background, see mdconfig(8).


----------



## PeteS (Dec 19, 2010)

I want to use a ramdisk to exchange information between different scripts and programs. Since these files will be written and read continuously I don't want to place them on the SSD I use as a system drive.

In debian (and most other linux distros) a tmpfs ramdisk is always created and mounted on /dev/shm during boot. So I used that location in the past but as I have switched to running FreeBSD I was wondering what options I have.

Thanks,
Pete


----------



## jalla (Dec 19, 2010)

Put this in /etc/rc.conf

```
tmpmfs="YES" 
tmpsize="100m" 
tmpmfs_flags="-S"
```


----------



## Beastie (Dec 19, 2010)

FreeBSD has its own implementation of tmpfs(5). Just create a directory somewhere and add this to /etc/fstab in order to mount it on startup:

```
tmpfs /path/to/the/directory tmpfs rw 0 0
```

That's it.


----------



## PeteS (Dec 19, 2010)

Thanks, it worked perfectly after I removed the partition already mounted on /tmp in /etc/fstab.


----------



## PeteS (Dec 19, 2010)

Thanks! I'll stick to the mfs as the man page says that tmpfs is currently considered an experimental feature.


----------



## Beastie (Dec 19, 2010)

It has been "experimental" for the past two years and I've been using it every single day for as long. It's currently holding my browser's profile.


----------



## wblock@ (Dec 19, 2010)

PeteS said:
			
		

> Thanks! I'll stick to the mfs as the man page says that tmpfs is currently considered an experimental feature.



Look at /etc/rc.d/tmp; it's the same thing.  tmpmfs="YES" creates a ramdisk with mdconfig(8).  It's just a little more specialized.


----------

