Raspberry SD-Karte schonen

/var/log in eine RAMDisk auslagern:

In die /etc/fstab schreiben:

tmpfs /var/log tmpfs defaults,noatime,nosuid,mode=0755,size=50M 0 0

Jetzt noch das varlog-Script aus diesem Thread umsetzen! (Siehe Dateianhänge an dieser Seite)

cat >> /etc/logrotate_varlog.conf << "EOFCONF"
# see "man logrotate" for details
# rotate log files weekly
#daily

# keep 4 weeks worth of backlogs
rotate 7

# create new (empty) log files after rotating old ones
create

# uncomment this if you want your log files compressed
compress

# Logs are moved into directory for rotation
olddir /var/archive

# packages drop log rotation information into this directory
#include /etc/logrotate.d

/var/log_save/journal/8c5604e85c924195aef34a3e4079998d/system.journal {
    missingok
    notifempty
}

# system-specific logs may be configured here

EOFCONF

cat >> /etc/systemd/system/logrotate.service << "EOFSVC"
[Unit]
Description=Rotate log files
Documentation=man:logrotate(8) man:logrotate.conf(5)
ConditionACPower=true

[Service]
Type=oneshot
ExecStart=/usr/sbin/logrotate /etc/logrotate_varlog.conf
Nice=19
IOSchedulingClass=best-effort
IOSchedulingPriority=7

EOFSVC


cat >> /etc/systemd/system/logrotate.timer << "EOFTIMER"
[Unit]
Description=Daily rotation of log files
Documentation=man:logrotate(8) man:logrotate.conf(5)

[Timer]
OnBootSec=2min
Unit=logrotate.service

[Install]
WantedBy=timers.target

EOFTIMER

Swap abschalten:

systemctl disable dphys-swapfile


KategorieRaspberry

Raspberry SD-Karte schonen (zuletzt geändert am 2020-11-17 15:16:41 durch HansStefanSuhle)