-
Notifications
You must be signed in to change notification settings - Fork 195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Potentially doing more harm than good by increasing bytes written? #173
Comments
Hi, Good parameters have been a long discussion with rsync developers. We have debate between I just saw some rsync trick on the link you've provide where people run rsync many times, that can be a improvement. To comfort you on the potential harm, log2ram maybe write a full file every time, but it do it only one time a day. It still better than write small changes minutes after minutes because SDcard have segments block you open at every write. It's my own observation. About your concern, the workaround for you is the disable the systemctl-timer job. This way, logs will be write only on shutdown/reboot. Best regards, |
log2ram-daily.service runs once a day, not really a big concern. How many writes are you expecting to save? To support renames, one could run md5 checksums on source & target files, match them up and rename them before rsync runs, as follows:
Do note the duplicates which will result in unnecessary renames (kern.log & syslog). To get around it would require additional code and rigorous testing. Something that could work would be the following code:
Is it worth it? It will create all sorts of issues demanding testing to ensure no data loss occurs. For example you could lose POSIX attributes if more than two files with the same md5sum are matched up out of order (like kern.log & syslog from the example), if they only differ in permissions or owner. If your logs are large it will run for a long time. Worse, if they're being written to and md5sum is stuck, then it will run forever. Getting around it from a shell script is no trivial matter. |
- Adds support for missing options in the /etc/log2ram.conf (USE_RSYNC and MAIL) - apt-key command has been deprecated, as mentioned by issue azlux#173. Changing it to use a keyring in /usr/share/keyrings
- Adds support for missing options in the /etc/log2ram.conf (USE_RSYNC and MAIL) - apt-key command has been deprecated, as mentioned by issue azlux#173. Changing it to use a keyring in /usr/share/keyrings
- Adds support for missing options in the /etc/log2ram.conf (USE_RSYNC and MAIL) - apt-key command has been deprecated, as mentioned by issue azlux#173. Changing it to use a keyring in /usr/share/keyrings
thank you for publishing your findings! I guess since I'm using btrfs with enabled compression I wouldn't need the compression part of logrotate, but I think it's also the thing that takes care of deleting old logs, is that correct? Do you have any suggestions on how to workaround this problem? Could we maybe get logrotate to use timestamp strings instead of an incrementing number that renames all old logs on every run? UPDATE: so I've checked out the file |
log2ram
is supposed to be useful for e.g. protecting the SD card of Raspberry Pis from wearing out.Usually the log is constantly synced to SD card, causing write amplification. Because the SD card will have to read and write back a whole block each time. Log2RAM solves this by having the logs written to tempfs and only persisted on the SD card e.g. once a day or once a week. So far so great!
But by default the Raspian is configured to log rotate. Usually this is harmless.
Every logfile (
daemon
,debug
,dpkg
,kern
,syslog
,user
,...) and every version of that is just renamed with incremented numbers. And by default number 2 and up is compressed.E.g.
syslog
->syslog.1
, ...syslog3.gz
->syslog4.gz
,...Renames don't cause excessive writes, they are basically free.
But what
log2ram
does as far as I know is usingrsync
to copy those changes to the SD card. link to sourceI think it is smart enough to not touch files that are already present and are identical. But
rsync
has no way of tracking renames. sourceThe previously free renames get turned into expensive rewrites of all the log files on every rotation! It will always rewrite syslog.1, syslog2.gz, syslog3.gz syslog4.gz and so on until syslog7.gz on every log rotation. By default turning 2 writes (once uncompressed and once compressed) into 8 writes (twice uncompressed and 6 times compressed)
According to this rsync has a flag
-y, --fuzzy
that tellsrsync
that it should look for a basis file for any destination file that is missing. But I am unsure if that just reduces the transferred data from source to destination or if this would actually reduce writes (doubtful).Is this correct? If so could you please warn about this effect prominently in the
README.md
? And suggest how to work around this? I know from issue #65 that Log2Ram is a KISS project and wants to minimize impact on other OS components. But if the above is a real issue please provide at least a simple workaround or sample/etc/logrotate
config in theREADME.md
to address the problem that affects everybody with the default install.If this is not a correct issue please say why it isn't in the documentation.
Other maybe related issues:
#64, #65 (old log) , #92 (fuzzy param causing issues)
And I also found #45, and #81
The text was updated successfully, but these errors were encountered: