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?

2 Answers 2

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.

9
  • If these are many small writes, is it better to have /var off the SD card where possible? (for SD lifetime) Commented Jul 2, 2012 at 8:56
  • I guess, but you should probably back it up onto the SD card fairly regularly. Commented Jul 2, 2012 at 9:04
  • 1
    -1; Mounting a filesystem in ram is not just for speed nor is the most frequent use-case for speed.
    – user606723
    Commented Jul 2, 2012 at 12:31
  • @user606723 Ok, what are the frequent use cases then? Commented Jul 2, 2012 at 12:35
  • 1
    It's a place to put files that are non-volatile and can be deleted when necessary. It's certainly not for speed because there is nothing ensuring /tmp is mounted in ram; In fact, many "Production" environments put these partitions on hard drives "just in case" they may need such information for future use.
    – user606723
    Commented Jul 2, 2012 at 12:45
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.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.