MoinMoin Logo
  • Kommentare
  • Geschützte Seite
  • Menu
    • Navigation
    • AktuelleÄnderungen
    • SeiteFinden
    • ÜbersichtsKarte
    • Help
    • HilfeInhalt
    • HilfeZurMoinWikiSyntax
    • Anzeige
    • Dateianhänge
    • Info
    • Rohform
    • Druckansicht
    • Editieren
    • Laden
    • Speichern
  • Anmelden

Navigation

  • AktuelleÄnderungen
  • SeiteFinden
  • HilfeInhalt
Revision 12 vom 2020-11-17 15:21:01
  • Raspberry SD-Karte schonen

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


cat >> /etc/systemd/system/varlog.service << "EOFSERVICE"
[Unit]
Description=varlog.service:  Redirect /var/log to tmpfs
DefaultDependencies=no
Before=local-fs.target shutdown.target
Conflicts=umount.target

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/local/bin/varlog start
ExecStop=/usr/local/bin/varlog stop

[Install]
RequiredBy=systemd-journal-flush.service

EOFSERVICE


cat >> /usr/local/bin/sik.sh << "EOFSIK"
#!/bin/bash
# Ein system.journal aus einer mit gz gepackten Datei wieder herstellen. Aufruf im varlog sik Zweig.

if [ -f /var/archive/system.journal ]; then

echo -e "\t\033[1;31m"
echo "**************************************************************************************************"
echo  "* In /var/archive/ ist ein system.journal vorhanden es muss mit y gelöscht werden."
echo "**************************************************************************************************"
echo -e "Ihre Eingabe:\t\033[1;31m\c"; read wahl

echo "Datei wird gelöscht"
sleep 2
rm /var/archive/system.journal
reset
fi

auswahl=$(ls -X /var/archive/ | grep -i -e \. | cut -d. -f 3)
echo -e "\033[1;32m"
echo "**************************************************************************************************"
echo -e "* Folgende system.journal.x.gz Dateien wurden im Ordner /var/archive/ gefunden.\n\t"$auswahl
echo "* Bitte die gewünschte Datei Nummer (1...7) eingeben. Weiter mit <ENTER>"
echo "**************************************************************************************************"
read wn
sleep 2

gunzip /var/archive/system.journal.$wn.gz
sleep 2
mv /var/archive/system.journal.$wn /var/archive/system.journal
sleep 2
echo "**************************************************************************************************"
echo "* Das system.journal wird mit journalctl --verify -D geprüft."
echo "**************************************************************************************************"
journalctl --verify -D /var/archive/
sleep 3
echo -e "\033[1;32m"
echo "**************************************************************************************************"
echo "* Das system.journal wird mit journalctl -p err auf Fehler geprüft."
echo "**************************************************************************************************"
journalctl -p err -D /var/archive/
sleep 3
echo -e "\033[1;32m"
echo "**************************************************************************************************"
echo "* Mal sehen was von varlog so in das Journal geschrieben wurde."
echo "**************************************************************************************************"
reset
journalctl --file=/var/archive/system.journal | grep "varlog\|journal" -i
sleep 3
echo -e "\033[1;32m"
echo "**************************************************************************************************"
echo "* Das system.journal wird mit journalctl --file=... komplett angezeigt Bitte mit q = Quit Beenden."
echo "**************************************************************************************************"
journalctl --file=/var/archive/system.journal
reset

EOFSIK

Swap abschalten:

systemctl disable dphys-swapfile


KategorieRaspberry

  • MoinMoin Powered
  • Python Powered
  • GPL licensed
  • Valid HTML 4.01