Log2Ram Documentation

repository·master·Indexed 25 days ago

https://github.com/azlux/log2ram

A utility that creates a RAM-based mount point for /var/log to reduce write operations to physical storage and extend hardware lifespan. Includes instructions for APT and manual installation, configuration of variables in /etc/log2ram.conf, management of sync frequency via systemd timers, and troubleshooting for /var/log size issues.

Tokens
1.1K
Snippets
3
Records
7
Agent score
35%

What's inside Log2Ram

  1. Install Log2Ram via APT (Recommended)

    master

    To install Log2Ram on Debian-based systems using the official repository, follow these steps. Note that for Debian 13 Trixie, a specific preference pin is required to ensure the correct source is used.

    Important: REBOOT your system before installing other services (like apache2) after this installation.

    . /etc/os-release
    sudo wget -O /usr/share/keyrings/azlux-archive-keyring.gpg https://azlux.fr/repo.gpg
    sudo tee /etc/apt/sources.list.d/azlux.list >/dev/null <<EOF
    deb [signed-by=/usr/share/keyrings/azlux-archive-keyring.gpg] http://packages.azlux.fr/debian/ $VERSION_CODENAME main
    EOF
    # Debian 13 Trixie needs a better Log2Ram source; see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1122989
    [ "$VERSION_CODENAME" = trixie ] && sudo tee /etc/apt/preferences.d/log2ram.pref >/dev/null <<EOF
    Package: log2ram
    Pin: origin packages.azlux.fr
    Pin-Priority: 1001
    EOF
    sudo apt update
    sudo apt install log2ram
  2. Uninstall Log2Ram

    master

    To remove Log2Ram from your system:

    Via APT: sudo apt remove log2ram (Use --purge to also remove configuration files).

    Manually: chmod +x /usr/local/bin/uninstall-log2ram.sh && sudo /usr/local/bin/uninstall-log2ram.sh

  3. Install Log2Ram manually

    master

    If you prefer not to use APT, you can install Log2Ram manually from the source archive. It is recommended to have rsync installed for better performance.

    curl -L https://github.com/azlux/log2ram/archive/master.tar.gz | tar zxf -
    cd log2ram-master
    chmod +x install.sh && sudo ./install.sh
    cd ..
    rm -r log2ram-master
  4. Change Log2Ram sync frequency

    master

    By default, Log2Ram synchronizes RAM to disk once a day via a CRON job. To change this, edit the systemd timer.

    To set a specific schedule (e.g., every Monday at 23:55), run systemctl edit log2ram-daily.timer and add:

    [Timer]
    OnCalendar=
    OnCalendar=Mon *-*-* 23:55:00

    Note: The empty OnCalendar= line is required to disable the existing default schedule.

    To disable daily syncing entirely (syncing only on shutdown/reboot), run: systemctl disable log2ram-daily.timer.

  5. Configure Log2Ram variables

    master

    Modify the configuration in /etc/log2ram.conf to adjust how Log2Ram behaves.

    Available variables:

    • SIZE: RAM reservation size (default: 128M).
    • USE_RSYNC: If false, uses cp instead of rsync (default is true).
    • NOTIFICATION: Set to false to disable mail notifications when RAM is low.
    • NOTIFICATION_COMMAND: Command used for error notifications (default: mail).
    • PATH_DISK: Additional paths to sync, separated by ;.
    • JOURNALD_AWARE: Enables log rotation for journald logs before syncing (default: true).
    • ZL2R: Enables zram compatibility (default: false). Requires zram-generator to be configured first.
    • COMP_ALG: Compression algorithm from /proc/crypto (default: lz4).
    • LOG_DISK_SIZE: Uncompressed zram disk size.
  6. Troubleshoot: /var/log too large for RAM

    master

    If /var/log contains more data than the allocated SIZE in log2ram.conf, the service will fail.

    1. Identify large directories:

    sudo du -hs /var/log/* | sort -h | tail -n 3

    1. Reduce journald size: Edit /etc/systemd/journald.conf and set:

    SystemMaxUse=20M

    OR perform an immediate vacuum of the journal logs: journalctl --vacuum-size=32M (Ensure this value is smaller than your Log2Ram SIZE).

    1. Apply changes and reboot:

    sudo systemctl restart systemd-journald followed by sudo reboot.