﻿{"id":18566,"date":"2022-10-27T08:25:01","date_gmt":"2022-10-27T00:25:01","guid":{"rendered":"https:\/\/www.linuxmi.com\/?p=18566"},"modified":"2022-10-26T20:32:38","modified_gmt":"2022-10-26T12:32:38","slug":"linux-log2ram","status":"publish","type":"post","link":"https:\/\/www.linuxmi.com\/linux-log2ram.html","title":{"rendered":"Linux \u4e0a\u4f7f\u7528 Log2Ram \u6765\u5ef6\u957f\u78c1\u76d8\u4f7f\u7528\u5bff\u547d"},"content":{"rendered":"<p>\u8fde\u7eed\u65e5\u5fd7\u8bb0\u5f55\u548c\u8bfb\/\u5199\u64cd\u4f5c\u53ef\u80fd\u4f1a\u635f\u5bb3\u60a8\u7684\u5b58\u50a8\u78c1\u76d8\u3002\u5728 Linux \u684c\u9762\u4e0a\u5b89\u88c5 Log2Ram \u4ee5\u5ef6\u957f\u78c1\u76d8\u7684\u4f7f\u7528\u5bff\u547d\u3002<\/p>\n<p>Linux \u673a\u5668\u6240\u505a\u7684\u51e0\u4e4e\u6240\u6709\u64cd\u4f5c\u90fd\u4f5c\u4e3a\u65e5\u5fd7\u6587\u4ef6\u7684\u4e00\u90e8\u5206\u5199\u5165\u78c1\u76d8\u3002\u5373\u4f7f\u60a8\u79bb\u5f00\u952e\u76d8\u6216\u7761\u89c9\uff0c\u6570\u5341\u4e2a\u65e5\u5fd7\u4e5f\u4f1a\u4e0d\u65ad\u66f4\u65b0\uff0c\u968f\u65f6\u53ef\u4f9b\u60a8\u641c\u7d22\u548c\u8bca\u65ad\u95ee\u9898\u6216\u4f18\u5316\u6d41\u7a0b\u3002<\/p>\n<p>\u8fd9\u79cd\u6301\u7eed\u7684\u5199\u5165\u53ef\u80fd\u4f1a\u5bf9\u5b58\u50a8\u4ecb\u8d28\u7684\u4f7f\u7528\u5bff\u547d\u4ea7\u751f\u5f71\u54cd\uff0c\u5e76\u5bfc\u81f4\u5176\u78e8\u635f\u901f\u5ea6\u6bd4\u5176\u4ed6\u65b9\u5f0f\u66f4\u5feb\u3002\u901a\u8fc7\u4f7f\u7528 Log2Ram \u5e94\u7528\u7a0b\u5e8f\u4fdd\u5b58\u60a8\u7684\u78c1\u76d8\u548c\u94b1\u5305\uff0c\u4ee5\u5c3d\u91cf\u51cf\u5c11\u78c1\u76d8\u5199\u5165\uff01<\/p>\n<h2 id=\"how-do-linux-logs-wear-out-disks\">Linux \u65e5\u5fd7\u5982\u4f55\u78e8\u635f\u78c1\u76d8\uff1f<\/h2>\n<p>\u65e5\u5fd7\u662f Linux \u4e0a\u6709\u4ef7\u503c\u7684\u6545\u969c\u6392\u9664\u8d44\u6e90\uff0c\u7531\u7cfb\u7edf\u3001\u5185\u6838\u3001\u5f15\u5bfc\u8fdb\u7a0b\u3001\u5305\u7ba1\u7406\u5668\u3001\u5355\u4e2a\u5e94\u7528\u7a0b\u5e8f\u548c Xorg \u4f7f\u7528\u3002\u5982\u679c\u5b83\u5728\u60a8\u7684\u7cfb\u7edf\u4e0a\uff0c\u5b83\u53ef\u80fd\u4f1a\u751f\u6210\u65e5\u5fd7\u6587\u4ef6\u3002<\/p>\n<p>\u5982\u679c\u60a8\u7684Linux\u8ba1\u7b97\u673a\u51fa\u73b0\u95ee\u9898\uff0c\u6216\u8005\u4efb\u4f55\u5e94\u7528\u7a0b\u5e8f\u884c\u4e3a\u5f02\u5e38\uff0c\u60a8\u7684\u7b2c\u4e00\u4e2a\u64cd\u4f5c\u662f\u68c0\u67e5\u76f8\u5173\u7684\u65e5\u5fd7\u6587\u4ef6\uff0c\u5e76\u67e5\u770b\u5f53\u65f6\u53d1\u751f\u4e86\u4ec0\u4e48\u3002<\/p>\n<p>\u60a8\u53ef\u4ee5\u5728 <strong>\/var\/log <\/strong>\u4e2d\u627e\u5230\u5927\u591a\u6570\u65e5\u5fd7\u3002\u6b64\u76ee\u5f55\u901a\u5e38\u5177\u6709\u6570\u5341\u4e2a\u6587\u4ef6\u548c\u5b50\u76ee\u5f55\uff0c\u4f7f\u7528\u7684\u78c1\u76d8\u7a7a\u95f4\u53ef\u4ee5\u8fbe\u5230\u6570\u5341 GB\uff0c\u6211\u8fd9\u4e2a\u4e5f\u6709 4 GB\uff0c\u5982\u4e0b\u56fe<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-18567\" src=\"https:\/\/www.linuxmi.com\/wp-content\/uploads\/2022\/10\/dush.png\" alt=\"\" width=\"1038\" height=\"209\" \/><\/p>\n<p>\u73b0\u4ee3\u56fa\u6001\u786c\u76d8 \uff08SSD\uff09 \u7684\u8bfb\/\u5199\u5468\u671f\u6570\u6709\u9650\uff0c\u5199\u5165\u78c1\u76d8\u7684\u6570\u636e\u8d8a\u591a\uff0c\u5176\u4f7f\u7528\u5bff\u547d\u5c31\u8d8a\u77ed\u3002\u56e0\u4e3a Linux \u4e0d\u65ad\u8bb0\u5f55\u7cfb\u7edf\u4e0a\u53d1\u751f\u7684\u6240\u6709\u4e8b\u60c5\uff0c\u6240\u4ee5\u8fd9\u4e9b\u8bfb\/\u5199\u5468\u671f\u7684\u52a0\u8d77\u6765\u6bd4\u4ed6\u4eec\u9700\u8981\u7684\u8981\u5feb\u3002\u4e3a\u4f60\u7684\u7535\u8111\u8d2d\u4e70\u65b0\u786c\u4ef6\u5f88\u6709\u8da3\uff0c\u4f46\u5982\u679c\u4f60\u56e0\u4e3a\u707e\u96be\u6027\u7684\u9a71\u52a8\u5668\u6545\u969c\u800c\u8fd9\u6837\u505a\uff0c\u90a3\u5c31\u4e0d\u884c\u4e86\u3002<\/p>\n<h2 id=\"how-log2ram-can-save-your-disks\">Log2Ram \u5982\u4f55\u4fdd\u5b58\u60a8\u7684\u78c1\u76d8<\/h2>\n<p>\u5728 Linux \u8ba1\u7b97\u673a\u4e0a\u5b89\u88c5 Log2Ram \u540e\uff0c\u65e5\u5fd7\u4e0d\u4f1a\u76f4\u63a5\u5199\u5165\u78c1\u76d8\uff0c\u800c\u662f\u987e\u540d\u601d\u4e49\uff0c\u5b83\u4eec\u4f1a\u5199\u5165 RAM\u3002<\/p>\n<p>\u60a8\u53ef\u4ee5\u9009\u62e9\u6c38\u4e45\u5220\u9664\u65e5\u5fd7\u3001\u6bcf\u5929\u5728\u8bbe\u5b9a\u7684\u65f6\u95f4\u5199\u5165\u78c1\u76d8\uff0c\u6216\u8005\u5728\u5173\u673a\u65f6\u5c06\u6700\u7ec8\u7248\u672c\u5199\u5165\u78c1\u76d8\u3002<\/p>\n<p>\u7279\u522b\u5bb9\u6613\u56e0\u8fc7\u5ea6\u4f7f\u7528\u800c\u635f\u574f\u3002<\/p>\n<h2 id=\"install-and-use-log2ram-on-your-linux-pc\">\u5728\u60a8\u7684 Linux PC \u4e0a\u5b89\u88c5\u548c\u4f7f\u7528 Log2Ram<\/h2>\n<p>\u5728\u5f00\u59cb\u4e4b\u524d\uff0c\u60a8\u5e94\u8be5\u66f4\u65b0\u548c\u5347\u7ea7\u7cfb\u7edf\u4e0a\u7684\u6240\u6709\u8f6f\u4ef6\u5305\u3002\u6253\u5f00\u7ec8\u7aef\u5e76\u8f93\u5165\uff1a<\/p>\n<pre class=\"pure-highlightjs\"><code class=\"null\">sudo apt update\r\nsudo apt upgrade<\/code><\/pre>\n<p>\u4e0b\u8f7d Log2Ram \u5b58\u6863\uff0c\u5e76\u5c06\u5176\u89e3\u538b\u7f29\uff1a<\/p>\n<pre class=\"pure-highlightjs\"><code class=\"null\">linuxmi@linuxmi:~\/www.linuxmi.com$ curl -L https:\/\/github.com\/azlux\/log2ram\/archive\/master.tar.gz | tar zxf -<\/code><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-18575\" src=\"https:\/\/www.linuxmi.com\/wp-content\/uploads\/2022\/10\/log2ram-1.png\" alt=\"\" width=\"1038\" height=\"290\" \/><\/p>\n<p>\u8f6c\u52a8\u5230\u65b0\u7684 log2ram \u76ee\u5f55\uff0c\u4f7f\u5b89\u88c5\u811a\u672c\u53ef\u6267\u884c\uff1a<\/p>\n<pre class=\"pure-highlightjs\"><code class=\"null\">linuxmi@linuxmi:~\/www.linuxmi.com$ cd log2ram-master\r\nlinuxmi@linuxmi:~\/www.linuxmi.com\/log2ram-master$ chmod +x install.sh<\/code><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-18568\" src=\"https:\/\/www.linuxmi.com\/wp-content\/uploads\/2022\/10\/log2ram.png\" alt=\"\" width=\"1038\" height=\"182\" \/><\/p>\n<p>\u8fd0\u884c\u5b89\u88c5\u811a\u672c\uff1a<\/p>\n<pre class=\"pure-highlightjs\"><code class=\"null\">linuxmi@linuxmi:~\/www.linuxmi.com\/log2ram-master$ sudo .\/install.sh\r\n[sudo] linuxmi \u7684\u5bc6\u7801\uff1a <\/code><\/pre>\n<p>\u8f93\u51fa\u793a\u4f8b\uff1a<\/p>\n<pre class=\"pure-highlightjs\"><code class=\"null\">Created symlink \/etc\/systemd\/system\/sysinit.target.wants\/log2ram.service \u2192 \/etc\/systemd\/system\/log2ram.service.\r\nCreated symlink \/etc\/systemd\/system\/timers.target.wants\/log2ram-daily.timer \u2192 \/etc\/systemd\/system\/log2ram-daily.timer.\r\n#####         Reboot to activate log2ram         #####\r\n##### edit \/etc\/log2ram.conf to configure options ####<\/code><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-18569\" src=\"https:\/\/www.linuxmi.com\/wp-content\/uploads\/2022\/10\/log2ram-3.png\" alt=\"\" width=\"1038\" height=\"344\" \/><\/p>\n<p>\u73b0\u5728\u91cd\u65b0\u542f\u52a8\uff1a<\/p>\n<pre class=\"pure-highlightjs\"><code class=\"null\">linuxmi@linuxmi:~\/www.linuxmi.com$ reboot<\/code><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-18570\" src=\"https:\/\/www.linuxmi.com\/wp-content\/uploads\/2022\/10\/log2ram-5.png\" alt=\"\" width=\"1038\" height=\"182\" \/><\/p>\n<p>\u91cd\u65b0\u767b\u5f55\u5230\u8ba1\u7b97\u673a\u540e\uff0c\u8bf7\u68c0\u67e5 log2ram \u662f\u5426\u6b63\u5728\u8fd0\u884c\uff1a<\/p>\n<pre class=\"pure-highlightjs\"><code class=\"null\">linuxmi@linuxmi:~\/www.linuxmi.com$ sudo systemctl status log2ram<\/code><\/pre>\n<p>\u8f93\u51fa\u5982\u4e0b\u56fe\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-18572\" src=\"https:\/\/www.linuxmi.com\/wp-content\/uploads\/2022\/10\/log2ram-6.png\" alt=\"\" width=\"1038\" height=\"857\" \/><\/p>\n<p>\u65e5\u5fd72ram\u6bcf\u5929\u5199\u5165\u78c1\u76d8\u3002\u5982\u679c\u8981\u66f4\u6539\u9891\u7387\uff0c\u8bf7\u8f93\u5165\uff1a<\/p>\n<pre><code class=\"hljs css\"><span class=\"hljs-selector-tag\">sudo<\/span> <span class=\"hljs-selector-tag\">systemctl<\/span> <span class=\"hljs-selector-tag\">edit<\/span> <span class=\"hljs-selector-tag\">log2ram-daily<\/span><span class=\"hljs-selector-class\">.timer<\/span><\/code><\/pre>\n<p>&#8230;\u5e76\u7f16\u8f91\u8ba1\u65f6\u5668\u6761\u76ee\u3002<\/p>\n<p>\u5982\u679c\u60a8\u5e0c\u671b\u4ec5\u5728\u7cfb\u7edf\u5173\u95ed\u6216\u91cd\u65b0\u5f15\u5bfc\u65f6\u5199\u5165\u65e5\u5fd7\uff0c\u5219\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b8c\u5168\u7981\u7528\u8ba1\u65f6\u5668\uff1a<\/p>\n<pre><code class=\"hljs css\"><span class=\"hljs-selector-tag\">sudo<\/span> <span class=\"hljs-selector-tag\">systemctl<\/span> <span class=\"hljs-selector-tag\">disable<\/span> <span class=\"hljs-selector-tag\">log2ram-daily<\/span><span class=\"hljs-selector-class\">.timer<\/span><\/code><\/pre>\n<p>\u60a8\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528 nano \u7f16\u8f91 log2ram \u914d\u7f6e\u6587\u4ef6\u6765\u914d\u7f6e\u5176\u4ed6\u9009\u9879\uff1a<\/p>\n<pre class=\"pure-highlightjs\"><code class=\"null\">linuxmi@linuxmi:~\/www.linuxmi.com$ sudo vim \/etc\/log2ram.conf<\/code><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-18573\" src=\"https:\/\/www.linuxmi.com\/wp-content\/uploads\/2022\/10\/log2ram-9.png\" alt=\"\" width=\"1038\" height=\"857\" \/><\/p>\n<p>\u5728\u8fd9\u91cc\uff0c\u60a8\u5c06\u627e\u5230\u4e94\u4e2a\u53d8\u91cf\uff0c\u60a8\u53ef\u4ee5\u8c03\u6574\u4ee5\u4f7f Log2Ram \u66f4\u9002\u5408\u60a8\u7684\u7cfb\u7edf\u3002RAM \u4e2d\u65e5\u5fd7\u6587\u4ef6\u5939\u7684\u9ed8\u8ba4\u5927\u5c0f\u8bbe\u7f6e\u4e3a 40MB\uff0c\u4f46\u5982\u679c\u60a8\u53ea\u5728\u5173\u673a\u65f6\u63d0\u4ea4\u5199\u5165\uff0c\u5e76\u4e14\u503e\u5411\u4e8e\u4e00\u6b21\u6253\u5f00\u8ba1\u7b97\u673a\u6570\u5929\uff0c\u5219\u9700\u8981\u5c06\u5176\u589e\u52a0\u5230\u66f4\u73b0\u5b9e\u7684\u503c\u3002\u66f4\u6539 PATH_DISK \u53d8\u91cf\u5c06\u5141\u8bb8\u60a8\u5c06\u65e5\u5fd7\u4fdd\u5b58\u5230\u975e\u9ed8\u8ba4\u4f4d\u7f6e\u3002<\/p>\n<h2 id=\"should-you-use-log2ram-on-linux\">\u4f60\u5e94\u8be5\u5728 Linux \u4e0a\u4f7f\u7528 Log2Ram \u5417\uff1f<\/h2>\n<p>\u867d\u7136 Log2Ram \u53ef\u4ee5\u51cf\u5c11\u78c1\u76d8\u78e8\u635f\uff0c\u4f46\u5982\u679c Linux PC \u610f\u5916\u5d29\u6e83\uff0c\u5b83\u4f1a\u963b\u65ad\u60a8\u8bca\u65ad\u95ee\u9898\u3002\u7531\u4e8e\u65e5\u5fd7\u53ea\u662f\u5076\u5c14\u5199\u5165\u78c1\u76d8\uff0c\u56e0\u6b64\u60a8\u65e0\u6cd5\u83b7\u5f97\u6709\u5173\u5d29\u6e83\u524d\u6240\u53d1\u751f\u60c5\u51b5\u7684\u6700\u65b0\u5fae\u79d2\u4fe1\u606f\u3002<\/p>\n<p>\u4e0d\u8fc7\uff0c\u901a\u8fc7\u5728 Linux \u4e2d\u542f\u7528 Log2ram \u670d\u52a1\uff0c\u4f60\u7684\u7269\u7406\u5185\u5b58\u5c06\u5f00\u59cb\u66f4\u6709\u6548\u5730\u5de5\u4f5c\uff0c\u5e76\u4e14\u60a8\u5c06\u770b\u5230\u6027\u80fd\u663e\u8457\u63d0\u9ad8\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8fde\u7eed\u65e5\u5fd7\u8bb0\u5f55\u548c\u8bfb\/\u5199\u64cd\u4f5c\u53ef\u80fd\u4f1a\u635f\u5bb3\u60a8\u7684\u5b58\u50a8\u78c1\u76d8\u3002\u5728 Linux \u684c\u9762\u4e0a\u5b89\u88c5 Log2Ram \u4ee5\u5ef6\u957f\u78c1 &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[3],"tags":[1250],"class_list":["post-18566","post","type-post","status-publish","format-standard","hentry","category-linux","tag-log2ram"],"aioseo_notices":[],"views":680,"_links":{"self":[{"href":"https:\/\/www.linuxmi.com\/wp-json\/wp\/v2\/posts\/18566","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.linuxmi.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.linuxmi.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.linuxmi.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.linuxmi.com\/wp-json\/wp\/v2\/comments?post=18566"}],"version-history":[{"count":3,"href":"https:\/\/www.linuxmi.com\/wp-json\/wp\/v2\/posts\/18566\/revisions"}],"predecessor-version":[{"id":18576,"href":"https:\/\/www.linuxmi.com\/wp-json\/wp\/v2\/posts\/18566\/revisions\/18576"}],"wp:attachment":[{"href":"https:\/\/www.linuxmi.com\/wp-json\/wp\/v2\/media?parent=18566"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.linuxmi.com\/wp-json\/wp\/v2\/categories?post=18566"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.linuxmi.com\/wp-json\/wp\/v2\/tags?post=18566"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}