Save Your SD Card: Install Log2Ram on Raspberry Pi
Linux distributions make it easy to keep system logs, and a paper trail helps me understand where things went wrong and how to fix them. As great as logging is, it can lead to an unexpected problem on a Raspberry Pi: constant disk writes degrade SD cards and cause them to fail. In this guide, I’ll show you how to fix this problem once and for all.
Log2Ram can be run on a Raspberry Pi to extend the lifespan of an SD card. Log2Ram works by reducing the number of disk writes used by system logging.
Read on to learn why you need Log2Ram and how to install it on your Pi. Let’s go!
If you’re new to Raspberry Pi or Linux, I’ve got something that can help you right away!
Download my free Linux commands cheat sheet – it’s a quick reference guide with all the essential commands you’ll need to get things done on your Raspberry Pi. Click here to get it for free!
Introduction to Log2Ram: Why You Might Need It
Raspberry Pi OS will keep logs as a normal part of operation. When a new event needs to be recorded, a disk write will occur. This constant process leads to wear and tear on your SD card. That’s where Log2Ram comes in.
Log2Ram is a program that stores log updates in memory, and then once a day, writes these changes to the disk all at once.
What Is the Benefit of Using Log2Ram?
You may already know that storage devices have limited read/write cycles. Once you exceed this limit, the drive can wear down until it stops functioning entirely. The write limit was rarely a concern for home users when we used hard disks.
However, write limits matter for modern solid-state devices, e.g., SSDs and SD cards. This limit can vary dramatically for SD cards—as low as 3,000 or as high as 100,000, depending on the quality and storage size. And manufacturers don’t always make this specification clear.

I’ve read user complaints about their Raspberry Pi chewing through SD cards or corrupting them with heavy writing. Therefore, the benefit of using Log2Ram is that it extends the life of your SD card.
Who Is Log2Ram Best For?
If you have a newer Raspberry Pi model (like the Pi 5 or Pi 4), use only basic programs, and have an excellent SD card (or the new official one), you’ll probably never encounter this problem.
You can get answers from real experts in minutes.
Get help with your setup
However, I recommend running Log2Ram if:
Bonus tip: If the terminal still feels confusing, I made a simple cheat sheet with 74 commands explained in plain English. You can grab it here for free..
If you want a clearer path than jumping from tutorial to tutorial, my book gives you a step-by-step roadmap to really understand your Raspberry Pi.
Check the book here- You’re using a not-so-great SD card brand, which often has a lower write endurance.
- You have an older SD card, as older designs had lower write limits.
- Your SD card storage is 32GB or less, especially if you keep your drive close to full capacity.
- You host LAMP, email, cryptomining, Minecraft, or other servers on your Pi, as these programs log heavily.
But if you’re unsure, why not protect your SD card if you can? After all, Log2Ram is easy to install and maintain. I’ve been running it for years without issue on a Raspberry Pi 4 with only 2 GB of memory.
How Does Log2Ram Work?
Log2Ram will create a mount point at /var/log that exists on your RAM. Every time a log file is updated, instead of writing to disk, the changes will be stored in memory. Once a day, Log2Ram will transfer these changes from memory to the SD card.

There’s one downside you should know about. Because log changes are stored in memory, if your Pi loses power, then any log updates since the last write will be lost.
You might also like: Want to install Windows 11 on your Pi? Here's how
Note: If you want to learn how to use graphical tools to make backups easy, I have a video on this topic just for community members. Join here to watch, and get access to 30+ other lessons for Raspberry Pi along with many other benefits!
To give you peace of mind, Log2Ram stores a daily backup of log files in the folder /var/hdd.log and also saves a backup when the Raspberry Pi is shut down properly.
I haven’t had to worry about this issue because my Pi is rock-solid, which is also why so many ground-breaking projects have used the Pi in surprising ways. If you love to tweak your Pi to its maximum potential, I highly recommend Log2Ram.
Log2Ram Installation Process
Now that you know how it works, let’s install Log2Ram. Open a terminal and put your typing gloves on—or copy/paste the commands below, I won’t judge.
Prerequisites for Log2Ram
First, make sure you have the most recent system packages:
- Update your system:
sudo apt update
sudo apt upgrade - Install rsync, which you probably already have:
sudo apt install rsync
Tip: Command lines can be a pain to memorize. I put the essential Linux commands on a printable cheat sheet so you don't have to keep googling them. You can grab the PDF here if you want to save some time.
Download Log2Ram
Next, download and extract the Log2Ram package from its official GitHub repository:
- Download using wget:
wget https://github.com/azlux/log2ram/archive/master.tar.gz -O log2ram.tar.gz - Extract the archive using tar:
tar xzf log2ram.tar.gz

Install Log2Ram
Finally, install Log2Ram with the script provided:
- Run the installation script, which will copy files and enable autostart:
cd log2ram-master
sudo ./install.sh - Reboot to activate:
sudo reboot - Check if Log2Ram is running properly:
systemctl status log2ram
If you see “active,” it’s working.
That’s it—you’re done! For most people, Log2Ram will work right out of the box. It’s a set-it-and-forget-it way of saving your SD card.
Bonus tip: If the terminal still feels confusing, I made a simple cheat sheet with 74 commands explained in plain English. You can grab it here for free..
If you’re curious about Log2Ram’s other features—especially if you’re running multiple servers on your Pi—then keep reading to learn how to modify its configuration.
Something not working? Don't waste hours going in circles. Ask in the RaspberryTips Community and get help from people who've already figured it out. Get unstuck now.
Log2Ram Configuration
Now that you’ve installed Log2Ram, let’s view its basic settings. Log2Ram’s configuration can be found in the /etc/log2ram.conf file. Open it using a text editor like Nano and take a look around.
Increasing Cache Size
In the config file, the “SIZE” parameter is the most important. The cache size tells Log2Ram how much physical memory to reserve for logs.
In the past, most issues with Log2Ram were caused by the default being too low. Thankfully, the newest version has increased the default cache size to 128 MB. If you’re only running a basic setup with SSH, this limit should be good enough.
However, if like me you’re running multiple servers that log extensively, such as Pi-Hole or UniFi Network Server, you’ll encounter issues if the cache runs out. For example, Log2Ram might give you an “out of memory” error, or the service won’t launch on startup for some reason.
Check this: Not Every Raspberry Pi Project Is Worth Building
The easiest solution to these problems is to increase your cache size. Here’s how:
- Open Log2Ram’s config file:
sudo nano /etc/log2ram.conf - Change SIZE to 256M (or whatever amount you think you need):

- Change LOG_DISK_SIZE to double your SIZE setting:

- Reboot for changes to take effect:
sudo reboot - Check if everything is still working:
df -hT
systemctl status log2ram
Other Configuration Options
Log2Ram has other features you can change, such as enabling notifications, adding custom log directories, and changing the time interval between disk writes. Most users won’t need to tinker with these settings, so I won’t cover them here.
But if you’re wondering how they work, you can read more about these features on the official GitHub. This page also has a useful troubleshooting section if you run into issues other than the ones mentioned above.
Related: 15 Tweaks to Get the Most Out of Your Raspberry Pi Server
That was pretty easy, right? Log2Ram is a neat little program for protecting your SD card, and I hope it serves you well as it has for me.
Not getting the same result?
Even when you follow every step, small differences in OS version, hardware or config can change the outcome. Instead of wasting time guessing, get help from people who have already fixed the same kind of issue.
- Get help on your exact issue
- Access step-by-step videos for tricky setups
- Browse the website without ads
