🌐
OSTechNix
ostechnix.com › home › linux tips & tricks › how to write log files in ram using log2ram in linux
How To Write Log Files In RAM Using Log2ram In Linux - OSTechNix
May 10, 2022 - Now, reboot your system to activate Log2ram. ... The Log2ram script creates a /var/log mount point in RAM. So all log files written in the /var/log folder will not actually be written in the the physical disk.
🌐
GitHub
github.com › azlux › log2ram
GitHub - azlux/log2ram: ramlog like for systemd (Put log into a ram folder)
You need to stop Log2Ram (systemctl stop log2ram) and execute the installation process. If you used APT, this will be done automatically. In the file /etc/log2ram.conf, there are nine variables: SIZE: defines the size the log folder will reserve ...
Starred by 2.9K users
Forked by 196 users
Languages   Shell
🌐
Linux.com
linux.com › home › news › improve system performance by moving your log files to ram
Improve system performance by moving your log files to RAM - Linux.com
July 16, 2008 - Author: Ben Martin The Ramlog project lets you keep your system logs in RAM while your machine is running and copies them to disk when you shut down. If you are running a laptop or mobile device with syslog enabled, Ramlog might help you increase your battery life or the life of the flash drive ...
🌐
Linuxfun
linuxfun.org › en › 2021 › 01 › 01 › what-log2ram-does-en
How log2ram works. | The World's Linux Journal
December 11, 2021 - This article introduces log2ram that will help you to move /var/log/ from microSD/HDD to RAM!With this package the lifetime of microSD will be longer than now with ease!
🌐
Linux Magazine
linux-magazine.com › Online › Blogs › Productivity-Sauce › Store-Logs-in-RAM-with-LogRunner
Store Logs in RAM with LogRunner » Linux Magazine
When running, LogRunner creates a RAM disk and copies all log files onto it. The clever part is that the utility has a backup function that helps to keep RAM usage below a specified limit (16MB by default).
🌐
Ubuntu Geek
ubuntugeek.com › improve-system-performance-by-moving-your-log-files-to-ram-using-ramlog.html
Improve system performance by moving your log files to RAM Using Ramlog | Ubuntu Geek
If kernel ramdisk is used, ramdisk created in /dev/ram9 and it is mounted to /var/log, by default ramlog takes all ramdisk memory specified by kernel argument "ramdisk_size".
🌐
IT'S FOSS
itsfoss.gitlab.io › post › how-to-write-log-files-in-ram-using-log2ram-in-linux
How To Write Log Files In RAM Using Log2ram In Linux :: IT'S FOSS
August 16, 2025 - Guide to Log2ram in Linux Write log files to RAM for faster access reduced disk wear. Learn how to set it up.
🌐
UbuntuPIT
ubuntupit.com › home › tutorials › how to write log files in ram using log2ram in linux
How To Write Log Files in RAM Using Log2ram in Linux
October 23, 2024 - Log2ram is the process of writing files in Ram instead of device storage. In this post, we will learn how To write log files In RAM using Log2ram In Linux
Find elsewhere
🌐
Baeldung
baeldung.com › home › administration › log the memory consumption on linux
Log the Memory Consumption on Linux | Baeldung on Linux
March 18, 2024 - It also includes an option to print the usage statistics continuously. Unlike the other two commands we saw earlier, this prints more information about memory usage. ... $ sar -o memory.log -r 1 3 --human Linux 4.15.0-76-generic (slave-node) 04/21/22 _x86_64_ (4 CPU) 15:00:23 kbmemfree kbavail kbmemused %memused kbbuffers kbcached kbcommit %commit kbactive kbinact kbdirty 15:00:24 2.7G 4.4G 5.0G 65.2% 779.4M 1012.5M 7.5G 97.4% 3.8G 605.7M 84.0k 15:00:25 2.7G 4.4G 5.0G 65.2% 779.4M 1012.5M 7.5G 97.4% 3.8G 605.8M 120.0k 15:00:26 2.7G 4.4G 5.0G 65.2% 779.4M 1012.6M 7.5G 97.4% 3.8G 605.9M 156.0k Average: 2.7G 4.4G 5.0G 65.2% 779.4M 1012.5M 7.5G 97.4% 3.8G 605.8M 120.0k
🌐
Reddit
reddit.com › r/linux › move your logs and temp files to ram and watch your portable fly!
r/linux on Reddit: Move your logs and temp files to RAM and watch your portable fly!
July 31, 2010 - This is true by policy on most GNU/Linux systems. But on my netbook, which is basically a web browsing appliance, I have chosen to trade away persistence of /var/log and /var/tmp in order to reduce disk writes. YMMV, but my subjective and non-scientific experience is "yes, it does 'feel' faster". More replies ... If you move them to ram, then you have less ram for apps/applications, and will end up in swap that much sooner.
🌐
MakeUseOf
makeuseof.com › home › linux › how to use log2ram on linux to save wear and tear on your disks
How to Use Log2Ram on Linux to Save Wear and Tear on Your Disks
October 14, 2022 - With Log2Ram installed on your Linux machine, logs aren't written directly to your disk, instead, as the name suggests, they're written to RAM.
Top answer
1 of 2
8

Technically, you can mount /var/log as tmpfs. You'd need to be sure that /var/log is mounted before syslogd starts, but that's the case by default on most distributions since they support /var on a separate partition.

You'll obviously lose all logs, which I guarantee will be a problem one day. Logs are there for a purpose — there're rarely needed, but they're there when they're needed. For example, if your system crashes, what was it doing before the crash? Since when has this package been incstalled? When did I print this document? etc.

You won't gain much disk space: logs don't take much space relative to a hard disk. Check how much space they use on your system; I'd expect something like 0.1% of the disk size.

You won't gain any performance. Logs amount to a negligible part of disk bandwidth on a normal desktop-type configuration.

The only gain would be to allow the disk to stay down, rather than spin up all the time to write new log entries. Spinning the disk down doesn't save much electricity if any: the hard disk is only a small part of a laptop power consumption, and spinning up requires a power surge. Furthermore spin cycles wear down the disk, so don't spin down too often. The main reason to spin down is the noise.

Rather than putting logs on tmpfs, arrange for your disk not to spin up when a file is written. Install Laptop Mode, which causes writes to disk to be suspended while the disk is spun down — only a full write buffer, an explicit sync or a disk read will spin the disk back up.

Depending on your configuration, you may need to instruct the syslog daemon not to call sync after each write. With the traditional syslog daemon, make sure that all file names in /etc/syslog.conf have - before them, e.g.

auth,authpriv.*         -/var/log/auth.log

With rsyslog, also make sure that log file names have - before them; the log files are configured in /etc/rsyslog.conf and /etc/rsyslog.d/*.

2 of 2
2

The other answer here is correct: You don't need to / want to do this for any sane circumstances. Doing so has various drawbacks and usually zero benefits. If your Linux system is on a hard drive (whether SSD or spinning), the simple answer is: You don't need this. If your system is spamming errors, this is still not a solution; it means you have a serious problem that needs investigation ASAP.

My own circumstances aren't sane. I'm running a toy project where I've installed a Linux OS on an ancient 8GB USB with far less than 1MB/s write speed, but on a computer with a good amount of RAM. It's not a production system. My system keeps hard-freezing for seconds at a time because of too many concurrent processes trying to write to my very slow drive. By sending all my cache and tmp dirs to RAM, I get a responsive system.

Here's the answer to your question:

  • Edit /etc/fstab as root.
  • Add something like this:
tmpfs /var/tmp tmpfs defaults,mode=1777,size=256M 0 0
tmpfs /var/log tmpfs defaults,mode=1775,size=512M 0 0

I've added ,size=256M and ,size=512M to limit their respective sizes, you may remove these if you want to them to consume up to 50% of your RAM.

🌐
Pi My Life Up
pimylifeup.com › home › using log2ram on the raspberry pi
Using Log2RAM on the Raspberry Pi - Pi My Life Up
September 25, 2022 - Improve the lifespan of your Raspberry Pi's SD Card with Log2RAM. This software moves your log files to RAM to reduce the number of writes.
🌐
MCU on Eclipse
mcuoneclipse.com › 2019 › 04 › 01 › log2ram-extending-sd-card-lifetime-for-raspberry-pi-lorawan-gateway
Log2Ram: Extending SD Card Lifetime for Raspberry Pi LoRaWAN Gateway | MCU on Eclipse
March 31, 2019 - As most of the data written as a gateway are the Linux log files, there is a solution to reduce the number of writes to the SD card using Log2Ram. It creates the mount point /var/log in RAM, so any writes to /var/log will be written to the RAM disk.
Top answer
1 of 2
5

CPU utilisation is easy:

From the command line:
while ( sleep 10 ) ; do cat /proc/loadavg >> mylogfile ; done

The sleep command will sleep 10 seconds and than return with the return value 0 (aka success). We abuse that to get a compact while( true ) sleep 10.

/proc/loadavg contains the load avarages of now, over the last 5 minutes, and over the last 15 minutes. If you are logging every 10 seconds then you are only interested in the first value.

Or in a script (using bash).

#!/bin/sh
# Using /bin/sh which is guaranteed to be present on any posix system.
# If you want to add shell specific parts in the script than replace this.
# E.g. if you want to use bash specific stuff then change it to:
# #!/usr/bin/env bash
# Make sure that the shebang is on the first line of the script (no comments above it!)

# While true, pause 10 seconds, then append information to Mylogfile
#
while ( sleep 10 ) ; do cat /proc/loadavg >> mylogfile ; done


We can add a cat /proc/meminfo to the information we append to the log file. /proc/meminfo is quite extensive and it will log a lot. If you only want to filter on specific memory information then please add that to the post.

The simplest form of that would result in:
while (sleep 10) ; do cat /proc/loadavg /proc/meminfo >> mylogfile ; done).

2 of 2
1

If you run atop as a daemon, it will log a huge amount of system state data: CPU usage, process list, disk I/O, memory usage and more. You can then step through the data with atop -r [filename].

🌐
Domoticz
domoticz.com › wiki › Moving_Log_and_Temporary_Files_To_a_RAM_Drive
Moving Log and Temporary Files To a RAM Drive - Domoticz
STEP 1 – Create the RAM disk and mount it Create the mount point: ... Make a backup copy of the system file we are going to edit, in case anything bad happens with the edit ... and edit the domoticz deamon logging parameters (default at system setup being #DAEMON_ARGS="$DAEMON_ARGS -log /tmp/domoticz.txt", also make sure you uncomment that line by removing the leading # character!) to now show: