Monitoring RPi4 SD card wear, when used together with AdGuard

They say SD Cards can wear out quickly if your write too much too quickly too it. (I think at least.) I was just wondering if there is anyway to monitor how much my SD Card is being written to and how much wear it has in Luci. I mainly want this because I'm looking to install AdGuard Home and currently by default it is in /var. I'm pretty sure this basically means RAM. I also think this means I'll lose my config on reboot. I would move it but I don't really want to destroy my SD card. So I wanna move it and monitor what's happening to the card so I can tweak Adguard's settings (e.g. logging) to minimise the damage.

Thanks in advance for any help.

what hardware are you using ?

since you mention a SD card, is it a Raspberry, or similar ?

Openwrt doesn't write a lot to the storage, because of wear, it's mainly used to maintain config and firmware + addons between reboots, like AdGuard.

Yup, Raspberry Pi 4 exactly. The SD Card has 32GB of space which OpenWRT barely uses. I wouldn't be so cautious about storing stuff on it given the space but apparently SD Cards can't handle much writes.

Depends on the SD card you're using.

There are cards designed for writes, but the cheapest probably aren't.

Openwrt minimizes writing to the storage, so you should be safe, unless you start to log a lot of stuff, or use the card for additional functionality, doing lots of writing.

Well I use Sandisk which seems like high quality. And I think Adguard Home might fall under additional functionality.

Are you by any chance aware of what sort of writing it does and how to minimise it?

You don't know if it's high quality, until it fails :wink:

AdGuard is additional functionality, but it's also designed for running on routers, so the software should be aware of the limited flash life span (when written to), of those devices.

What I meant by additional functionality, would for instance be a file server, using the SD as storage.

I have a RPi 1B, used for monitoring the boiler in our house, it's been using the same SD card since day one, probably 7-8 years by now.

I wouldn't worry to much :wink:

1 Like

Thanks, I think I can confidently use it now. Do you know if you where I would move it to from /var?

do you really need to - Permanent /var directory, will I be safe?

1 Like

I read it but not sure if I understood. Is the /var directory permanent? Can it be made permanent? If so is that a good idea (reading that post made it seem like a bad idea). Is there any other directory that would be better suited?

Sorry not sure if this is suited for this topic but any help would be greatly appreciated.

if you tweak AGH yaml files you can have it write to ram instead of disk. or even just mount a usb drive and install/run it off that. By default if you install manually AGH installs to the /opt/AdGuardHome directory so you can easily remap that.

OpenWrt now has an installable package for AGH but if you want to manually install just follow my thread.

Theres also a wiki now too.

1 Like

SD cards are designed for significantly higher write cycle use than the flash memory typically found in embedded devices -- when you consider that they are used as media for digital cameras and other devices, it is important that they are relatively robust. But yes, eventually they will wear out and fail.

With that in mind, though... SD cards are also easily replaced, cheap, and plentiful. While you obviously don't want to intentionally burn through these things and waste money/environment, it is trivial to replace an SD card, provided you have a backup. This is in contrast to an embedded device which has storage that is not robust and not easily replaceable.

1 Like

Oh wow that wiki is insanely useful. Thanks alot.

True but I'll have to find the right time to turn off the internet to backup the card.

You can actually just use the standard system backup which will save all of your config files and anything else you specify in the /etc/sysupgrade.conf file. This doesn't produce a clone, but will save the files that are most critical.

The card replacement process would be fairly simple:

  1. write an OpenWrt image to the card*
  2. install any user installed packages
  3. restore the backup

*You can actually create custom images that include any extra packages you've installed. Beyond that, your custom images can even include your configuration files so that it is completely ready to go.

you can even automate it by using a script like this and edit it to do all your modifications.

Only if your device is easily accessible (and not 12000 miles away, with nobody near it able to assist).


Note to self: pay close attention to flash write cycles when sending a craft to Lagrange 2 :rofl:


This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.