8

Re this answer: https://raspberrypi.stackexchange.com/a/867/339

It is suggested that /var be mounted in memory, so to avoid causing your root partition to fill accidentally.

I've got a couple of questions about this, one particularly RPi related:

1: In the case of logging, are these logs then available to view? - Say the machine crashes or whatever - can you get back to the logs to see what went wrong.

2: In the specific case of the RPi with fairly limited RAM available, is doing this a good idea? - if there's a risk of filling a disk is there not also a problem with running out of memory?

Jon Egerton
  • 2,983
  • 2
  • 21
  • 31

2 Answers2

7

You have to evaluate your particular use case. Normally, you would mount a filesystem in RAM for speed.

1: In the case of logging, are these logs then available to view? - Say the machine crashes or whatever - can you get back to the logs to see what went wrong.

If the RPi crashes and you have to restart it, the logs will not be available.

2: In the specific case of the RPi with fairly limited RAM available, is doing this a good idea? - if there's a risk of filling a disk is there not also a problem with running out of memory?

I agree that, in general, RAM is too low to waste some on a filesystem. You do, of course, limit the size of the filesystem.

Alternative

Create another partition on your SD card, so it can fill it up without filling up the entire card.

Alex Chamberlain
  • 15,120
  • 13
  • 63
  • 112
5

Mounting a filesystem in RAM is not just done for speed. The most common case of this is with the average /tmp directory, which is mounted via tmpfs on almost all modern Linux distributions

In fact, instead of mounting /var in RAM, you should consider symlinking the appropriate subdirectories to /tmp

This is what many embedded Linux distributions do (OpenWRT, etc.). Although, keep in mind they are meant to run a much 'smaller' hardware: 8MB flash 32MB RAM

1: In the case of logging, are these logs then available to view? - Say the machine crashes or whatever - can you get back to the logs to see what went wrong.

Of course, you will lose these logs on restart. If you're concerned about this, you could consider a remote syslogd

2: In the specific case of the RPi with fairly limited RAM available, is doing this a good idea? - if there's a risk of filling a disk is there not also a problem with running out of memory?

The amount of logs that will get generated is not as large as you may think. It would be easy to keep them in memory granted the machine isn't running for years. (And then you'd simply need to clean them as you would anyway). That said, this also means the amount of data recorded to the sdcard isn't really that significant either.

tlhIngan
  • 3,342
  • 5
  • 18
  • 33
user606723
  • 464
  • 3
  • 8