You are not logged in.

#1 2014-03-24 22:23:02

Infinity
Member
From: EU
Registered: 2013-12-16
Posts: 18

Is it possible to move entire /var to ram?

Hello.

I'm working on some project where the linux distro (Arch) will be installed exclusively on a flash device. I'd like this device to have a very long life, so I decided to minimize the amount of writes to the NAND flash where the rootfs is located. I've already setup some things like tmpfs for various mounts, applying certain mount options, changing the disk scheduler to noop, etc. It would be best, if I mounted the entire rootfs as read only. However some applications still need to write to a certain place in /var.

So I was thinking... is it possible to move the entire /var folder into ram and have it mounted as a tmpfs? Normally I don't mind using tmpfs like this, and I understand that the data will be lost across reboots, but the thing is that programs will often rely on data and certain folder structure being present. For example nginx refuses to run, if the /var/log/nginx folder does not exist - it refuses to create one on its own. This pretty much means that the data has to be present in the tmpfs. Is there a way to do this? Possibly have an existing read-only /var folder on the NAND flash, and an overlayfs + tmpfs on top?

Regards!

Offline

#2 2014-03-24 22:25:49

Slithery
Administrator
From: Norfolk, UK
Registered: 2013-12-01
Posts: 5,776

Re: Is it possible to move entire /var to ram?

Take a look at Graysky's anything-sync-daemon, it should do what you're after.


No, it didn't "fix" anything. It just shifted the brokeness one space to the right. - jasonwryan
Closing -- for deletion; Banning -- for muppetry. - jasonwryan

aur - dotfiles

Offline

#3 2014-03-24 22:27:04

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,724
Website

Re: Is it possible to move entire /var to ram?

There is a lot more than a directory structure in /var/.  Pacman's databases for one - you'd likely have a very (if not completely) broken package manager.

EDIT: indeed the above should work.  It *minimizes* the writes, while still allowing important data to be committed to the SD before shutdown.

Last edited by Trilby (2014-03-24 22:27:47)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#4 2014-03-24 22:33:57

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: Is it possible to move entire /var to ram?

Have you treid https://aur.archlinux.org/packages/anyt … nc-daemon/ ?
https://wiki.archlinux.org/index.php/An … ync-daemon


Edit: Toooo laaaate.

Last edited by karol (2014-03-24 22:35:16)

Offline

#5 2014-03-25 07:04:54

Mr Green
Forum Fellow
From: U.K.
Registered: 2003-12-21
Posts: 5,899
Website

Re: Is it possible to move entire /var to ram?

I would be subjective as to the folders from /var you put in /tmpfs, pacmans pkg cache can get quite large over time. Certainly log files, databases should be ok. Anything sync daemon will do the job and as I remember does make backups on shutdown...


Mr Green

Offline

#6 2014-03-25 08:54:24

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,612
Website

Re: Is it possible to move entire /var to ram?

I never tested asd targeting the /var partition before.  No idea how systemd will treat having open files synced over.  If u try it, let us know how it goes but do so at your own risk.


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#7 2014-03-25 10:13:50

Infinity
Member
From: EU
Registered: 2013-12-16
Posts: 18

Re: Is it possible to move entire /var to ram?

Thanks for all the input, but I'm still a bit skeptic about this setup.

Maybe I should have specified more details about this project. It's going to be a DIY web radio that's running off an ARM board (not raspberry pi) with Arch linux ARM. Technically I do not care, if I lose the changes in /var across reboots as long as the original settings can be restored at each boot (i.e. folder structure). The truth is the device normally isn't going to be rebooted and/or shut down by init (runlevel scripts) or systemd, I'll just unplug it from power on occasions. Pacman is only going to be used on initial installation of software like MPD and web server.

Last edited by Infinity (2014-03-25 10:14:41)

Offline

#8 2014-03-25 10:38:52

roentgen
Member
Registered: 2011-03-15
Posts: 91

Re: Is it possible to move entire /var to ram?

I would do whatever they do on the netinstall iso. They load the entire system from an image

file root-image.fs.sfs 
root-image.fs.sfs: Squashfs filesystem

I would take care of the needed writes later after I'd manage that.

Offline

#9 2014-03-25 17:11:33

teateawhy
Member
From: GER
Registered: 2012-03-05
Posts: 1,138
Website

Re: Is it possible to move entire /var to ram?

Infinity wrote:

Thanks for all the input, but I'm still a bit skeptic about this setup.

Maybe I should have specified more details about this project. It's going to be a DIY web radio that's running off an ARM board (not raspberry pi) with Arch linux ARM. Technically I do not care, if I lose the changes in /var across reboots as long as the original settings can be restored at each boot (i.e. folder structure). The truth is the device normally isn't going to be rebooted and/or shut down by init (runlevel scripts) or systemd, I'll just unplug it from power on occasions. Pacman is only going to be used on initial installation of software like MPD and web server.

A possible solution for this is to build a customized live CD with Archiso.
If it is possible, add a button to the ARM board to act as poweroff button.

Last edited by teateawhy (2014-03-25 17:13:04)

Offline

#10 2014-03-26 15:47:32

ANOKNUSA
Member
Registered: 2010-10-22
Posts: 2,141

Re: Is it possible to move entire /var to ram?

Infinity wrote:

Pacman is only going to be used on initial installation of software like MPD and web server.

Correct me if I'm wrong, but if all this thing's doing is playing music via a web server then logging is the only thing I can imagine frequently writing to any directory at all. If nothing's going to change in the long run, disable all logging daemons and call it a day; whether you disable the daemons or have them write to RAM, the data's going to be destroyed in the event of a problem.  Besides, if you never intend on updating the system there will eventually come a tipping point at which, if something goes wrong, reinstalling is your only option.

Other than that, I'm afraid I can't be much help, as in my opinion SD flash is basically only good for situations that requires minimal reliability (so I've never really bothered with something like this).  If it eases your doubt, I've been running OpenELEC on my Raspberry Pi for about a year on the same SD card without any problems, and a new SD card is dirt-cheap if anything destructive happens.

Offline

Board footer

Powered by FluxBB