Creating a RAM disk on TrueNAS Scale

Yamon234

Dabbler
Joined
Oct 5, 2021
Messages
13
Hello all! I'm running the latest version of TrueNAS Scale and I would like to know how to create a RAM disk and mount it as a "usable drive". Probably something small like 3Gb for temporary unimportant file storage. I'm running a UPS and have an overabundance of RAM for my use case. I imagine it might be a Init script that makes and mounts a drive? I have alot of professional IT experience but haven't messed around with RAM disks much at all.
I tried to research this topic quite a bit but I keep hitting dead end threads of people telling OPs they shouldn't be using a RAM disk. So instead of discussing my use case for it I'd like to answer the question once and for all and have simple clear instructions on how to do it.
Thank you in advance for any help! And to be clear I'm not trying to bash people in other threads for not helping most of the time they've been right about the OP being better off with another solution but it's been pretty hard to find an answer to this question because of that.
 

Kris Moore

SVP of Engineering
Administrator
Moderator
iXsystems
Joined
Nov 12, 2015
Messages
1,471
As a caution, TrueNAS does not officially support ramdisks, so you are on your own if something screws up :P

That said, its easy to make one via the CLI:

Code:
mkdir /mnt/ramfs
mount -t tmpfs -o size=115G myramdisk /mnt/ramfs
 

jgreco

Resident Grinch
Joined
May 29, 2011
Messages
18,680
Hey, @Kris Moore , has there been any reconsideration about NOT abusing /mnt as the mountpoint for the pool?

FHS, hier(7), other documentation, and historical practice place FreeNAS/TrueNAS squarely at odds with common wisdom and normal practices.
 

Yamon234

Dabbler
Joined
Oct 5, 2021
Messages
13
As a caution, TrueNAS does not officially support ramdisks, so you are on your own if something screws up :P

That said, its easy to make one via the CLI:

Code:
mkdir /mnt/ramfs
mount -t tmpfs -o size=115G myramdisk /mnt/ramfs
Thanks Kris! This worked perfectly! For kicks and giggles I threw some data on it and rebooted and sure enough it's gone!
Thanks a million!
 

RavenNAS

Dabbler
Joined
Mar 7, 2022
Messages
34
Code:
mkdir /mnt/ramfs
mount -t tmpfs -o size=115G myramdisk /mnt/ramfs
Would this remount after a reboot or would it have to be recreated each time? and I'm sure it probably will need to be recreated after a update to TrueNAS?
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,700
Would this remount after a reboot or would it have to be recreated each time? and I'm sure it probably will need to be recreated after a update to TrueNAS?
It will be needed after every reboot.

I have a pre-init task running with this command:

mkdir /mnt/RamDisk && mdmfs -M -S -o async -s 36864m md10 /mnt/RamDisk && chown plex:plex /mnt/RamDisk/ && chmod 0775 /mnt/RamDisk

Works great for Plex transcoding.
 

HoneyBadger

actually does care
Administrator
Moderator
iXsystems
Joined
Feb 6, 2014
Messages
5,112
Would this remount after a reboot or would it have to be recreated each time? and I'm sure it probably will need to be recreated after a update to TrueNAS?
You'd have to set this up as a pre or post-init script that would fire every boot.

If you're running an app under SCALE, you could use a memory-backed volume under Docker.
 

RavenNAS

Dabbler
Joined
Mar 7, 2022
Messages
34
You'd have to set this up as a pre or post-init script that would fire every boot.

If you're running an app under SCALE, you could use a memory-backed volume under Docker.
I'm trying to set something up for Frigate NVR app, each camera feed gets saved to /tmp/cache in 10 second chucks for it to scan, transcode and ether delete or move to /recordings. times that by the number of cameras and scans I'm worried about IO and disk burn out in the long term since its mounted on my only ssd with ix-app

when I run
Code:
mount -t tmpfs -o size=100MB myramdisk /mnt/ramfs
it gives me an error "wrong fs type, bad option, bad superblock on ramdisk, missing codepage or helper program"

and I can't see the memory backed volume options for frigate

edit: oops I see the problem should be 100m not 100MB
 
Last edited:

HoneyBadger

actually does care
Administrator
Moderator
iXsystems
Joined
Feb 6, 2014
Messages
5,112
I'm trying to set something up for Frigate NVR app, each camera feed gets saved to /tmp/cache in 10 second chucks for it to scan, transcode and ether delete or move to /recordings. times that by the number of cameras and scans I'm worried about IO and disk burn out in the long term since its mounted on my only ssd with ix-app
You should be able to set up the Frigate Docker container to use a storage type of tmpfs/memory-backed in the configuration; IIRC it's not available as a standard SCALE App so it would launch through the Custom App shortcut as a Docker container.
 

RavenNAS

Dabbler
Joined
Mar 7, 2022
Messages
34
it's not available as a standard SCALE App so it would launch through the Custom App shortcut as a Docker container.
Okay thanks, I knew I remembered seeing that option somewhere. I'll just stick to the apps they workout pretty well for me. next time.

So I created a pre-init job with
Code:
mkdir /mnt/ramfs && mount -t tmpfs -o size=100m ramdisk /mnt/ramfs
and frigate is set to host path /mnt/ramfs as its /tmp/cache. seems to be working good but haven't reboot, yet.

thank you for the help

(edit: to anyone seeing this in the future, videos with longer motion or detects may be larger in size and 100m MIGHT not be enough, but this should be fine up to 6x 4k cameras short motions)
 
Last edited:
Top