This constant writing can have an impact on the lifespan of your storage medium, and cause it to wear out sooner than it otherwise would. Save your disks and your wallet by using the Log2Ram app to minimize disk writing!
How Do Linux Logs Wear Out Disks?
Logs are a valuable troubleshooting resource on Linux, and are used by the system, kernel, boot processes, package managers, individual apps, and Xorg. If it’s on your system, it probably generates log files.
If anything goes wrong with your Linux machine, or any app misbehaves, your first action is to check the relevant log files, and see what was going on at the time.
You can find most logs in /var/log. This directory typically has dozens of files and subdirectories, and the disk space used can range into tens of gigabytes.
Modern Solid State Drives (SSDs) have a limited number of read/write cycles, and the more data is written to the disk, the shorter their lifespan will be. Because Linux is constantly logging everything that happens on the system, these read/write cycles are adding up faster than they need to. Buying new hardware for your PC is fun, but not if you’re doing it because of catastrophic drive failure.
Single-board computers which boot their operating system from a microSD card are especially prone to damage due to excessive use.
How Log2Ram Can Save Your Disks
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.
You can either choose to have your logs permanently deleted, written to disk at a set time every day, or have a final version written to disk at shutdown.
Install and Use Log2Ram on Your Linux PC
Before you start, you should update and upgrade all packages on your system. Open a terminal and enter:
Download the Log2Ram archive, and extract it:
Move into the new log2ram directory and make the install script executable:
Run the install script:
Now reboot:
After logging back into your machine, check that log2ram is running:
Log2ram writes to disk every day. If you want to change the frequency, enter:
…and edit the timer entry.
If you prefer to only have logs written on when the system shuts down or reboots, you can disable the timer completely with:
You can configure additional options by using nano to edit the log2ram configuration file:
Here, you’ll find five variables you can tweak to make Log2Ram better suited for your system. The default size of the log folder in RAM is set to 40MB, but if you’re only committing writes at shutdown, and tend to leave your machine on for days at a time, you will want to increase this to a more realistic value. Changing the PATH_DISK variable will allow you to save your logs to a non-default location.
Should You Use Log2Ram on Linux?
While Log2Ram saves on disk wear and tear, it can prevent you from diagnosing problems if your Linux PC crashes out unexpectedly. As logs are only occasionally written to disk, you won’t get up-to-the-microsecond information on what was going on just before a crash.
Whether you need to use this information or not, it’s handy to have it available.