{"id":704,"date":"2020-04-07T23:10:05","date_gmt":"2020-04-07T22:10:05","guid":{"rendered":"https:\/\/notiz.comanet.xyz\/?p=704"},"modified":"2022-05-22T15:09:05","modified_gmt":"2022-05-22T14:09:05","slug":"linux-log2ram","status":"publish","type":"post","link":"https:\/\/notiz.comanet.xyz\/?p=704","title":{"rendered":"Linux Log2Ram"},"content":{"rendered":"\n<p><strong>Treba povecati log size<\/strong><\/p>\n\n\n\n<p># Size for the ram folder, it defines the size the log folder will reserve into the RAM. <br># If it&#8217;s not enough, log2ram will not be able to use ram. Check you \/var\/log size folder. <br># The default is 40M and is basically enough for a lot of applications. <br># You will need to increase it if you have a server and a lot of log for example. <br>SIZE=400M <\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>milan@RavaRadio:~ $ systemctl status log2ram<br>\u25cf log2ram.service &#8211; Log2Ram<br>Loaded: loaded (\/etc\/systemd\/system\/log2ram.service; enabled; vendor prese&gt;<br>Active: failed (Result: exit-code) since Sun 2022-05-22 15:44:32 CEST; 7mi&gt;<br>Process: 376 ExecStart=\/usr\/local\/bin\/log2ram start (code=exited, status=1\/&gt;<br>Main PID: 376 (code=exited, status=1\/FAILURE)<br>CPU: 152ms<\/p>\n\n\n\n<p>May 22 15:44:32 RavaRadio log2ram[273]: ERROR: RAM disk for &#8220;\/var\/hdd.log\/&#8221; too&gt;<br>May 22 15:44:32 RavaRadio log2ram[362]: \/usr\/local\/bin\/log2ram: 45: mail: not f&gt;<br>May 22 15:44:32 RavaRadio log2ram[376]: ERROR: RAM disk for &#8220;\/var\/hdd.log\/&#8221; too&gt;<br>May 22 15:44:32 RavaRadio log2ram[397]: \/usr\/local\/bin\/log2ram: 45: mail: not f&gt;<br>May 22 15:44:32 RavaRadio systemd[1]: log2ram.service: Main process exited, cod&gt;<br>May 22 15:44:32 RavaRadio systemd[1]: log2ram.service: Failed with result &#8216;exit&gt;<br>May 22 15:44:32 RavaRadio systemd[1]: Failed to start Log2Ram.<br>lines 1-14\/14 (END)\u2026skipping\u2026<br>\u25cf log2ram.service &#8211; Log2Ram<br>Loaded: loaded (\/etc\/systemd\/system\/log2ram.service; enabled; vendor preset: enabled)<br>Active: failed (Result: exit-code) since Sun 2022-05-22 15:44:32 CEST; 7min ago<br>Process: 376 ExecStart=\/usr\/local\/bin\/log2ram start (code=exited, status=1\/FAILURE)<br>Main PID: 376 (code=exited, status=1\/FAILURE)<br>CPU: 152ms<\/p>\n\n\n\n<p>May 22 15:44:32 RavaRadio log2ram[273]: ERROR: RAM disk for &#8220;\/var\/hdd.log\/&#8221; too small. Can&#8217;t sync.<br>May 22 15:44:32 RavaRadio log2ram[362]: \/usr\/local\/bin\/log2ram: 45: mail: not found<br>May 22 15:44:32 RavaRadio log2ram[376]: ERROR: RAM disk for &#8220;\/var\/hdd.log\/&#8221; too small. Can&#8217;t sync.<br>May 22 15:44:32 RavaRadio log2ram[397]: \/usr\/local\/bin\/log2ram: 45: mail: not found<br>May 22 15:44:32 RavaRadio systemd[1]: log2ram.service: Main process exited, code=exited, status=1\/FAILURE<br>May 22 15:44:32 RavaRadio systemd[1]: log2ram.service: Failed with result &#8216;exit-code&#8217;.<br>May 22 15:44:32 RavaRadio systemd[1]: Failed to start Log2Ram.<br>~<\/p>\n\n\n\n<p>Like ramlog for systemd (on debian 8 jessie for example).<\/p>\n\n\n\n<p>Usefull for <strong>RaspberryPi<\/strong> for not writing on the SD card all the time. You need it because your SD card doesn&#8217;t want to suffer anymore!<\/p>\n\n\n\n<p>Explanations: The script creates a <code>\/var\/log<\/code> mount point in RAM. So any writing of the log to the <code>\/var\/log<\/code>\n folder will not actually be written to disk (in this case to the sd \ncard for a raspberry card) but directly to RAM. By default, every days, \nthe CRON will launch a synchronization of the RAM to the folder located \non the physical disk. The script will also make this copy of RAM to disk\n in case of machine shutdown (but cannot do it in case of power \nfailure). This way you avoid excessive writing on the SD card.<\/p>\n\n\n\n<p>The script <a href=\"https:\/\/github.com\/azlux\/log2ram\">log2ram<\/a> can work on every linux system. So you can use it with your own daemon manager if you don&#8217;t have systemd.<\/p>\n\n\n\n<p>Log2Ram is based on transient log for Systemd here : <a href=\"https:\/\/www.debian-administration.org\/article\/661\/A_transient_\/var\/log\">A transient \/var\/log<\/a><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><a href=\"https:\/\/github.com\/azlux\/log2ram#menu\"><\/a><\/h2>\n\n\n\n<h2 class=\"wp-block-heading\">Menu<\/h2>\n\n\n\n<ol class=\"wp-block-list\"><li><a href=\"https:\/\/github.com\/azlux\/log2ram#install\">Install<\/a><\/li><li><a href=\"https:\/\/github.com\/azlux\/log2ram#upgrade\">Upgrade<\/a><\/li><li><a href=\"https:\/\/github.com\/azlux\/log2ram#customize\">Customize<\/a><\/li><li><a href=\"https:\/\/github.com\/azlux\/log2ram#it-is-working\">It is working ?<\/a><\/li><li><a href=\"https:\/\/github.com\/azlux\/log2ram#uninstall-\">Uninstall<\/a><\/li><\/ol>\n\n\n\n<h2 class=\"wp-block-heading\"><a href=\"https:\/\/github.com\/azlux\/log2ram#install\"><\/a><\/h2>\n\n\n\n<h2 class=\"wp-block-heading\">Install<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><a href=\"https:\/\/github.com\/azlux\/log2ram#with-apt-recommended\"><\/a><\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">With APT (recommended)<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>echo \"deb http:\/\/packages.azlux.fr\/debian\/ buster main\" | sudo tee \/etc\/apt\/sources.list.d\/azlux.list\nwget -qO - https:\/\/azlux.fr\/repo.gpg.key | sudo apt-key add -\napt update\napt install log2ram\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><a href=\"https:\/\/github.com\/azlux\/log2ram#manually\"><\/a><\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">Manually<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>curl -Lo log2ram.tar.gz https:\/\/github.com\/azlux\/log2ram\/archive\/master.tar.gz\ntar xf log2ram.tar.gz\ncd log2ram-master\nchmod +x install.sh &amp;&amp; sudo .\/install.sh\ncd ..\nrm -r log2ram-master\n<\/code><\/pre>\n\n\n\n<p><strong>REBOOT<\/strong> before installing anything else (for example apache2)<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><a href=\"https:\/\/github.com\/azlux\/log2ram#upgrade\"><\/a><\/h2>\n\n\n\n<h2 class=\"wp-block-heading\">Upgrade<\/h2>\n\n\n\n<p>You need to stop log2ram (<code>service log2ram stop<\/code>) and start the <a href=\"https:\/\/github.com\/azlux\/log2ram#install\">install<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><a href=\"https:\/\/github.com\/azlux\/log2ram#customize\"><\/a><\/h2>\n\n\n\n<h2 class=\"wp-block-heading\">Customize<\/h2>\n\n\n\n<h4 class=\"wp-block-heading\"><a href=\"https:\/\/github.com\/azlux\/log2ram#variables-\"><\/a><\/h4>\n\n\n\n<h4 class=\"wp-block-heading\">variables :<\/h4>\n\n\n\n<p>In the file <code>\/etc\/log2ram.conf<\/code>, there are three variables:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><code>SIZE<\/code>: defines the size the log folder will reserve into the RAM (default is 40M).<\/li><li><code>USE_RSYNC<\/code>: Can be set to <code>true<\/code> if you prefer \u00b4rsync\u00b4 rather than \u00b4cp\u00b4. I use the command <code>cp -u<\/code> and <code>rsync -X<\/code>, I don&#8217;t copy the all folder every time for optimization.<\/li><li><code>MAIL<\/code>: Disables the error system mail if there is not enough place on RAM (if set to <code>false<\/code>)<\/li><li><code>ZL2R<\/code>: Enable zram compatibility (<code>false<\/code> by default). Check the comment on the config file. See <a href=\"https:\/\/github.com\/StuartIanNaylor\/zram-swap-config\">https:\/\/github.com\/StuartIanNaylor\/zram-swap-config<\/a> to configure a zram space on your raspberry before enable this option.<\/li><\/ul>\n\n\n\n<h4 class=\"wp-block-heading\"><a href=\"https:\/\/github.com\/azlux\/log2ram#refresh-time\"><\/a><\/h4>\n\n\n\n<h4 class=\"wp-block-heading\">refresh time:<\/h4>\n\n\n\n<p>By default Log2Ram writes to the HardDisk every day. If you think this is too much, you can move <code>\/etc\/cron.daily\/log2ram<\/code> in an other cron folder, or remove it if you prefer writing logs only at stop\/reboot.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><a href=\"https:\/\/github.com\/azlux\/log2ram#it-is-working\"><\/a><\/h3>\n\n\n\n<h3 class=\"wp-block-heading\">It is working?<\/h3>\n\n\n\n<p>You can now check the mount folder in ram with (You will see lines with log2ram if working)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># df -h\n\u2026\nlog2ram          40M  532K   40M   2% \/var\/log\n\u2026\n\n# mount\n\u2026\nlog2ram on \/var\/log type tmpfs (rw,nosuid,nodev,noexec,relatime,size=40960k,mode=755)\n\u2026\n<\/code><\/pre>\n\n\n\n<p>If you have issue with apache2, you can try to add <code>apache2.service<\/code> next to other services on the <code>Before<\/code> parameter in <code>\/etc\/systemd\/system\/log2ram.service<\/code> it will solve the pb<\/p>\n\n\n\n<p>The log for log2ram will be written at: <code>\/var\/log\/log2ram.log<\/code><\/p>\n\n\n\n<p>Compressor for zram. Usefull for the <code>COMP_ALG<\/code> of ZRAM on the config file.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Compressor name<\/th><th>Ratio<\/th><th>Compression<\/th><th>Decompress.<\/th><\/tr><\/thead><tbody><tr><td>zstd 1.3.4 -1<\/td><td>2.877<\/td><td>470 MB\/s<\/td><td>1380 MB\/s<\/td><\/tr><tr><td>zlib 1.2.11 -1<\/td><td>2.743<\/td><td>110 MB\/s<\/td><td>400 MB\/s<\/td><\/tr><tr><td>brotli 1.0.2 -0<\/td><td>2.701<\/td><td>410 MB\/s<\/td><td>430 MB\/s<\/td><\/tr><tr><td>quicklz 1.5.0 -1<\/td><td>2.238<\/td><td>550 MB\/s<\/td><td>710 MB\/s<\/td><\/tr><tr><td>lzo1x 2.09 -1<\/td><td>2.108<\/td><td>650 MB\/s<\/td><td>830 MB\/s<\/td><\/tr><tr><td>lz4 1.8.1<\/td><td>2.101<\/td><td>750 MB\/s<\/td><td>3700 MB\/s<\/td><\/tr><tr><td>snappy 1.1.4<\/td><td>2.091<\/td><td>530 MB\/s<\/td><td>1800 MB\/s<\/td><\/tr><tr><td>lzf 3.6 -1<\/td><td>2.077<\/td><td>400 MB\/s<\/td><td>860 MB\/s<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h6 class=\"wp-block-heading\"><a href=\"https:\/\/github.com\/azlux\/log2ram#now-muffins-for-everyone\"><\/a><\/h6>\n\n\n\n<h6 class=\"wp-block-heading\">Now, muffins for everyone!<\/h6>\n\n\n\n<h2 class=\"wp-block-heading\"><a href=\"https:\/\/github.com\/azlux\/log2ram#uninstall-\"><\/a><\/h2>\n\n\n\n<h2 class=\"wp-block-heading\">Uninstall \ud83d\ude41<\/h2>\n\n\n\n<p>(Because sometime we need it)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>chmod +x \/usr\/local\/bin\/uninstall-log2ram.sh &amp;&amp; sudo \/usr\/local\/bin\/uninstall-log2ram.sh\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Treba povecati log size # Size for the ram folder, it defines the size the log folder will reserve into the RAM. # If it&#8217;s not enough, log2ram will not be able to use ram. Check you \/var\/log size folder. # The default is 40M and is basically enough for a lot of applications. #&#8230;<\/p>\n","protected":false},"author":1,"featured_media":705,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,6,29,13],"tags":[],"class_list":["post-704","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-how-to-s","category-linux","category-raspberry-pi","category-tips-tricks"],"_links":{"self":[{"href":"https:\/\/notiz.comanet.xyz\/index.php?rest_route=\/wp\/v2\/posts\/704","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/notiz.comanet.xyz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/notiz.comanet.xyz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/notiz.comanet.xyz\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/notiz.comanet.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=704"}],"version-history":[{"count":2,"href":"https:\/\/notiz.comanet.xyz\/index.php?rest_route=\/wp\/v2\/posts\/704\/revisions"}],"predecessor-version":[{"id":823,"href":"https:\/\/notiz.comanet.xyz\/index.php?rest_route=\/wp\/v2\/posts\/704\/revisions\/823"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/notiz.comanet.xyz\/index.php?rest_route=\/wp\/v2\/media\/705"}],"wp:attachment":[{"href":"https:\/\/notiz.comanet.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=704"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/notiz.comanet.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=704"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/notiz.comanet.xyz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=704"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}