Return to Level1Techs.com

Ramdisk on Linux that will move to a hard disk and back for reboots?

I’m still learning, but this is a place I trust to ask about things like this. I’ve been messing with making a ramdisk for an application and I was wondering if its not too hard to make it where the ram drive would be moved to a location on the hard drive when the application closes? For things like restarts and shutdowns, like when the power fails and the UPS takes over. Then when the application is started back up it’d create the ramdisk again and work from that? So not so much a back up on the hard disk like some guides want me to do, just kind of opening the application into a ramdisk automatically and doing the reverse when closing.

Does that make sense and is it feasible for someone like myself to set up? Thanks for any help.

I’m not sure entirely what it is you’re after, something like criu or just extra performance.

If latter, Linux has mlock and madvise that can force the app or mapped files to stay in pagecache (ram) while the app is running. Pagecache is also shared between processes.

Do you also want to force data writes to disk(or SSD/nvme) to not sync?

Just for clarification:

You want to open the application -> kernel creates a ramdisk and loads application into that -> application lives in RAM until A.) Application is closed (writes ramdisk to disk in current state) and/or B.) Signal is received from UPS that power is funky and application is closed and then written to ramdisk?

This might be what you are looking for:

https://wiki.archlinux.org/index.php/Anything-sync-daemon

I did something similar to this with the .mozilla directory for firefox. When I would boot, it would copy the contents of the .mozilla file to /tmp ( which is tmpfs or ramdisk ) and copy the contents back to /home/{USER}/.mozilla, so this is very possible if you want to do it. I worked it out with a systemd unit file and timer. I did need to set up what the unit file depends on because of boot, shutdown, and a periodic timer as well to ensure a backup.

I’m using BOINC for [email protected], so I was concern about the data being saved properly. I wanted to be able to open BOINC and in doing so start it on a ramdisk, let it do it’s thing within ram, and if for any reason it needs to be closed (a restart , a power failure, anything) it’ll return to it’s place on the hard drive so no data is lost and it can continue from where it last left off. So I don’t need backups or restoration points so much, just the benefits of a ramdisk install without having to install every time.

I’m trying to let BOINC maybe gain some performance and reduce the wear and tear on my SSD. I know the latter isn’t much of a concern these days, but if I’m running it 24/7 I figure it’ll manage to cause some noticeable wear compared to normal use. I figure it’s not a beginner thing, but if someone had done it before I could at least try and follow the steps while changing a few things for my use case.

So you mean something like /var/tmp?