{"id":262822,"date":"2023-02-21T10:58:52","date_gmt":"2023-02-21T02:58:52","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=262822"},"modified":"2023-01-30T11:59:21","modified_gmt":"2023-01-30T03:59:21","slug":"linux-zram","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/linux-zram.html","title":{"rendered":"\u5728 Linux \u4e0a\u7528 zram \u66ff\u4ee3\u4f20\u7edf\u4ea4\u6362\u7a7a\u95f4"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\nzram \u662f\u4e00\u4e2a\u7528\u4e8e\u521b\u5efa\u5185\u5b58\u538b\u7f29\u7f13\u5b58\u7684\u5de5\u5177\uff0c\u7279\u522b\u662f\u53ef\u4ee5\u7528\u4f5c\u4ea4\u6362\u7a7a\u95f4\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n
\"\"<\/p>\n

Free operationg system. The word \"Linux\" is lined with gold letters on wooden planks. 3D illustration graphics<\/p>\n<\/div>\n

\u6211\u5728\u6211\u7684\u7535\u8111\u4e0a\u82b1\u4e86\u5f88\u591a\u65f6\u95f4\uff08\u6211\u662f\u8bf4\u5de5\u4f5c\uff09\uff0c\u6211\u53d1\u73b0\u4e86\u5f88\u591a\u6709\u8da3\u7684\u4e1c\u897f\u3002\u5176\u4e2d\u6700\u8fd1\u5f15\u8d77\u6211\u6ce8\u610f\u7684\u662f \u200b\u200bzram0\u200b\u200b\u200b \u8bbe\u5907\u3002\u6211\u662f\u5728\u51e0\u4e2a\u6708\u524d\u5199\u4e00\u7bc7\u6587\u7ae0\u65f6\u7b2c\u4e00\u6b21\u6ce8\u610f\u5230\u5b83\uff0c\u5b83\u663e\u793a\u5728 \u200b\u200blsblk\u200b\u200b \u547d\u4ee4\u7684\u8f93\u51fa\u4e2d\uff1a<\/p>\n

# lsblkNAME          MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTSsda             8:0    0 931.5G  0 disk\u251c\u2500sda1          8:1    0   600M  0 part[...]zram0         252:0    0     8G  0 disk [SWAP]\r\n<\/pre>\n

\u5b83\u88ab\u8bc6\u522b\u4e3a\u4ea4\u6362\u7a7a\u95f4\uff0c\u8fd9\u5c31\u662f\u9996\u5148\u5f15\u8d77\u6211\u7684\u597d\u5947\u5fc3\u7684\u539f\u56e0\uff0c\u6240\u4ee5\u6211\u505a\u4e86\u4e00\u4e9b\u7814\u7a76\u3002zram \u6700\u521d\u88ab\u79f0\u4e3a \u201c\u538b\u7f29\u7f13\u5b58compcache\u201d\uff0c\u5373 \u201c\u538b\u7f29\u7684\u9ad8\u901f\u7f13\u5b58\u201d\u3002\u4e8b\u5b9e\u8bc1\u660e\uff0czram \u662f\u4e00\u4e2a\u7528\u4e8e\u521b\u5efa\u5185\u5b58\u5185\u538b\u7f29\u7f13\u5b58\u7684\u5de5\u5177\uff0c\u7279\u522b\u662f\u4f5c\u4e3a\u4ea4\u6362\u7a7a\u95f4\u4f7f\u7528\u3002<\/p>\n

\u4f46\u4e3a\u4ec0\u4e48\u5462\uff1f<\/p>\n

\u5f53\u6211\u5f00\u59cb\u7814\u7a76 zram \u65f6\uff0c\u6211\u53ea\u53d1\u73b0\u4e86\u51e0\u7bc7\u5173\u4e8e\u5c06 zram \u7528\u4e8e\u4ea4\u6362\u7a7a\u95f4\u7684\u57fa\u7840\u6587\u7ae0\u3002\u8d77\u521d\uff0c\u8fd9\u5bf9\u6211\u6765\u8bf4\u4f3c\u4e4e\u6709\u70b9\u8fdd\u53cd\u76f4\u89c9\u3002\u6bd5\u7adf\uff0c\u5982\u679c\u4f60\u7684\u5185\u5b58\u5feb\u7528\u5b8c\u4e86\uff0c\u4f60\u628a\u9875\u9762\u4ea4\u6362\u5230\u5185\u5b58\u4e2d\u7684\u865a\u62df\u9a71\u52a8\u5668\u4e2d\uff0c\u6709\u4ec0\u4e48\u597d\u5904\u5462\uff1f<\/p>\n

\u7136\u540e\u6211\u627e\u5230\u4e86 Fedora \u9879\u76ee\u7684\u7ef4\u57fa\u9875\u9762\uff0c\u5b83\u63d0\u8bae\u4f7f\u7528 \u200b\u200bzram \u4ea4\u6362\u7a7a\u95f4\u200b\u200bswap-on-zram\u3002\u8be5\u5efa\u8bae\u8bf4\uff1a\u201c\u4ea4\u6362\u662f\u6709\u7528\u7684\uff0c\u9664\u4e86\u5b83\u7684\u901f\u5ea6\u5f88\u6162\u3002zram \u662f\u4e00\u4e2a\u4f7f\u7528\u4e86\u538b\u7f29\u7684\u5185\u5b58\u9a71\u52a8\u5668\u3002\u5728\u542f\u52a8\u65f6\u521b\u5efa\u4e00\u4e2a zram \u4ea4\u6362\u7a7a\u95f4\uff0c\u5e76\u4e14\u4e0d\u518d\u4f7f\u7528\u9ed8\u8ba4\u7684\u4ea4\u6362\u5206\u533a\u3002\u201d<\/p>\n

\u8be5\u9875\u9762\u7684\u5176\u4f59\u90e8\u5206\u662f\u5173\u4e8e\u5b83\u7684\u7ec6\u8282\u3001\u597d\u5904\u3001\u526f\u4f5c\u7528\u548c\u53cd\u9988\u3002<\/p>\n

Linux \u4e0a\u7528\u4e8e\u4ea4\u6362\u7a7a\u95f4\u7684 zram<\/strong><\/div>\n

\u4f7f\u7528 zram \u4f5c\u4e3a\u4ea4\u6362\u7a7a\u95f4\uff0c\u4e0e\u5e38\u89c4\u7684\u57fa\u4e8e\u5206\u533a\u6216\u57fa\u4e8e\u6587\u4ef6\u7684\u4ea4\u6362\u7a7a\u95f4\u505a\u7684\u4e8b\u60c5\u76f8\u540c\u3002\u5f53\u5185\u5b58\u538b\u529b\u8fc7\u5927\u65f6\uff0c\u4e00\u4e9b\u6700\u8fd1\u4f7f\u7528\u6700\u5c11\u7684\u6570\u636e\u4f1a\u88ab\u79fb\u5230\u4ea4\u6362\u7a7a\u95f4\u3002\u5e73\u5747\u6765\u8bf4\uff0c\u5b83\u4f1a\u88ab\u538b\u7f29\u5230\u5176\u539f\u59cb\u5927\u5c0f\u7684 50% \u5de6\u53f3\uff0c\u5e76\u88ab\u653e\u7f6e\u5728\u5185\u5b58\u7684 zram \u7a7a\u95f4\u4e2d\u3002\u8fd9\u6bd4\u5c06\u8fd9\u4e9b\u5185\u5b58\u9875\u5b58\u50a8\u5728\u786c\u76d8\u4e0a\u8981\u5feb\u5f97\u591a\uff0c\u5e76\u53ef\u4ee5\u91ca\u653e\u51fa\u5b83\u6240\u4f7f\u7528\u7684\u5185\u5b58\u7528\u4e8e\u5176\u4ed6\u7528\u9014\u3002<\/p>\n

\u8282\u7701\u4ea4\u6362\u7a7a\u95f4<\/strong><\/div>\n

\u6211\u8bd5\u56fe\u627e\u5230\u5173\u4e8e\u914d\u7f6e\u591a\u5c11\u4ea4\u6362\u7a7a\u95f4\u6216 zram \u4ea4\u6362\u7a7a\u95f4\u7684\u603b\u7ed3\u5efa\u8bae\u3002\u8fd9\u4f7f\u6211\u91cd\u65b0\u56de\u987e\u4e86\u4ea4\u6362\u7a7a\u95f4\u7684\u8bbe\u7f6e\uff0c\u4ee5\u53ca\u6211\u4e4b\u524d\u7684\u6587\u7ae0\u300a\u200b\u200b\u73b0\u4ee3 Linux \u7cfb\u7edf\u7684\u6b63\u786e\u4ea4\u6362\u7a7a\u95f4\u662f\u591a\u5c11\uff1f\u200b\u200b\u300b\u3002\u5c31\u6211\u6240\u77e5\uff0c\u4ece RHEL \u548c Fedora \u7684\u6700\u65b0\u6587\u6863\u6765\u770b\uff0c\u63a8\u8350\u7684\u4ea4\u6362\u7a7a\u95f4\u6570\u91cf\u5e76\u6ca1\u6709\u6539\u53d8\u3002\u4e0d\u8fc7\uff0c\u8be5\u6587\u6863\u5ffd\u7565\u4e86 zram \u7684\u4f7f\u7528\u3002<\/p>\n

\u7136\u800c\uff0c\u5728\u4e0d\u4f7f\u7528 zram \u7684\u65e7\u7248 Linux \u6216 zram \u88ab\u7981\u7528\u7684\u60c5\u51b5\u4e0b\uff0c\u4e4b\u524d\u6587\u7ae0\u4e2d\u7684\u8868\u683c\u4ecd\u7136\u4e3a\u4ea4\u6362\u7a7a\u95f4\u7684\u5206\u914d\u63d0\u4f9b\u4e86\u4e00\u4e2a\u597d\u7684\u8d77\u70b9\u3002<\/p>\n

\u6211\u627e\u5230\u7684\u5173\u4e8e zram \u529f\u80fd\u7684\u6587\u6863\u5728 zram \u5982\u4f55\u6839\u636e\u5185\u5b58\u5927\u5c0f\u5206\u914d\u7a7a\u95f4\uff0c\u4ee5\u53ca\u5206\u914d\u7ed9 zram \u4ea4\u6362\u7a7a\u95f4\u7684\u6570\u91cf\u65b9\u9762\u662f\u4e0d\u4e00\u81f4\u7684\u3002<\/p>\n

\u7531\u4e8e\u7f3a\u4e4f\u6743\u5a01\u6027\u7684\u6587\u6863\uff0c\u6211\u8fdb\u884c\u4e86\u4e00\u4e9b\u5b9e\u9a8c\u6765\u51ed\u7ecf\u9a8c\u786e\u5b9a\u7528\u4e8e\u5206\u914d zram \u4ea4\u6362\u7a7a\u95f4\u7684\u7b97\u6cd5\u3002\u6211\u4e3a\u6b64\u4f7f\u7528\u4e86\u6211\u81ea\u5df1\u7684\u7269\u7406\u548c\u865a\u62df\u7cfb\u7edf\u3002\u7ed3\u679c\u5f88\u6709\u8da3\uff0c\u4e0e\u6211\u8fc4\u4eca\u4e3a\u6b62\u53d1\u73b0\u7684\u4efb\u4f55\u6587\u6863\u90fd\u4e0d\u4e00\u81f4\u3002<\/p>\n

\u5728\u6240\u6709\u8db3\u591f\u5927\u7684\u7cfb\u7edf\u4e0a\uff0czram \u7684\u9ed8\u8ba4\u5927\u5c0f\u662f 8GB\uff0c\u4f46\u5728\u5185\u5b58\u8f83\u5c0f\u7684\u4e3b\u673a\u4e0a\u901a\u5e38\u4f1a\u5927\u5927\u51cf\u5c11\u3002\u5728\u6211\u7528\u4e8e\u6d4b\u8bd5\u7684\u4e00\u53f0\u865a\u62df\u673a\uff08VM\uff09\u4e0a\uff0c\u53ef\u4ee5\u8bbf\u95ee 4GB \u7684\u5185\u5b58\uff0czram \u7684\u865a\u62df\u4ea4\u6362\u7a7a\u95f4\u88ab\u5206\u914d\u4e3a 3.8GB\u3002\u6211\u7684\u4e00\u53f0\u65e7\u6234\u5c14\u7535\u8111\u62e5\u6709 8GB \u7684\u5185\u5b58\uff0czram \u88ab\u8bbe\u7f6e\u4e3a 7.6GB\u3002\u5f53\u5185\u5b58\u51cf\u5c11\u5230 2GB \u65f6\uff0czram \u5c31\u51cf\u5c11\u5230 1.9GB\u3002<\/p>\n

\u6211\u62e5\u6709\u7684\u6240\u6709\u5185\u5b58\u8d85\u8fc7 8GB \u7684\u7269\u7406\u548c\u865a\u62df\u4e3b\u673a\u90fd\u663e\u793a\u6b63\u597d\u662f 8GB \u7684 zram\u3002\u8fd9\u5305\u62ec\u6211\u62e5\u6709 64GB \u5185\u5b58\u7684\u4e3b\u5de5\u4f5c\u7ad9\u548c\u5176\u4ed6\u62e5\u6709 16GB \u6216 32GB \u5185\u5b58\u7684\u4e3b\u673a\u3002<\/p>\n

\u57fa\u4e8e\u8fd9\u51e0\u4e2a\u6570\u636e\u70b9\uff0c\u6211\u53ef\u4ee5\u5f97\u51fa\u8fd9\u6837\u7684\u7ed3\u8bba\uff1a\u76ee\u524d\u7684\u9ed8\u8ba4\u8bbe\u7f6e\u662f\u6700\u591a 8GB \u7684 zram\uff0c\u800c\u5728 8GB \u6216\u4ee5\u4e0b\u7684\u4e3b\u673a\u4e0a\uff0czram \u5360\u5185\u5b58\u7684 95%\u3002<\/p>\n

\u6211\u8bfb\u8fc7\u4e00\u4e9b\u6587\u7ae0\uff0c\u5176\u4e2d\u63d0\u5230\u4e86 zram \u4ea4\u6362\u7a7a\u95f4\u7684\u5176\u4ed6\u5927\u5c0f\uff0c\u751a\u81f3\u9ad8\u8fbe 100% \u7684\u5185\u5b58\uff0c\u4f46\u8fd9\u4e9b\u4f3c\u4e4e\u90fd\u662f\u7406\u8bba\u4e0a\u7684\uff0c\u800c\u4e0d\u662f\u73b0\u5b9e\u3002<\/p>\n

\u4f60\u7684\u53d1\u884c\u7248\u53ef\u80fd\u4e0d\u540c\uff0c\u4f46\u8fd9\u91cc\u662f Fedora \u548c\u7c7b\u4f3c\u53d1\u884c\u7248\u7684\u5b9e\u9645 zram \u4ea4\u6362\u7a7a\u95f4\u7684\u5206\u914d\u60c5\u51b5\uff1a<\/p>\n

\u5185\u5b58 \u21d0 8 GB\uff1a0.95 \u00d7 \u5185\u5b58
\n\u5185\u5b58 > 8 GB:8 GB
\n\u8bf7\u6ce8\u610f\uff0czram \u4ea4\u6362\u7a7a\u95f4\u5927\u5c0f\u7684\u7b97\u6cd5\u5e76\u6ca1\u6709\u57fa\u4e8e\u5bf9\u4efb\u4f55\u7ed9\u5b9a\u7684\u73b0\u5b9e\u4e16\u754c\u7684\u7cfb\u7edf\u6216\u5e94\u7528\u7a0b\u5e8f\u7684 \u201c\u6700\u4f73\u201d \u4ea4\u6362\u5927\u5c0f\u7684\u5efa\u8bae\u3002\u8fd9\u79cd zram \u4ea4\u6362\u7a7a\u95f4\u7684\u5206\u914d\u662f\u4e00\u79cd\u76f8\u5f53\u6982\u7387\u6027\u7684\u65b9\u6cd5\uff0c\u5b83\u5e94\u8be5\u5728\u5e7f\u6cdb\u7684 Linux \u4e3b\u673a\u4e0a\u8fd0\u884c\u826f\u597d\u3002\u7136\u800c\uff0c\u6700\u5927\u7684 zram \u4ea4\u6362\u7a7a\u95f4\u5927\u5c0f\u88ab\u914d\u7f6e\u4e3a 8GB\uff0c\u800c\u4e14\u6211\u4e00\u76f4\u63a8\u8350 8GB \u4f5c\u4e3a\u4f20\u7edf\u4ea4\u6362\u7a7a\u95f4\u7684\u6700\u5927\u5bb9\u91cf\uff0c\u6211\u60f3\u6211\u53ef\u4ee5\u8bf4\u5b83\u53cd\u6620\u4e86 zram \u4ea4\u6362\u7a7a\u95f4\u7684\u6700\u4f73\u5927\u5c0f\u3002<\/p>\n

\u7ba1\u7406 zram \u4ea4\u6362\u7a7a\u95f4<\/strong><\/div>\n

zram \u7684\u9ed8\u8ba4\u503c\u4fdd\u5b58\u5728 \u200b\u200b\/usr\/lib\/systemd\/zram-generator.conf\u200b\u200b \u914d\u7f6e\u6587\u4ef6\u4e2d\u3002\u4ee5\u4e0b\u662f\u6211\u7684\u4e00\u4e2a\u6d4b\u8bd5\u865a\u62df\u673a\uff0c\u5206\u914d\u4e86 5097GB \u7684\u5185\u5b58\u3002<\/p>\n

# cat \/usr\/lib\/systemd\/zram-generator.conf# This config file enables a \/dev\/zram0 device with the default settings:# - size - same as available RAM or 8GB, whichever is less# - compression - most likely lzo-rle## To disable, uninstall zram-generator-defaults or create empty# \/etc\/systemd\/zram-generator.conf file.[zram0]zram-size= min(ram, 8192)<\/pre>\n

\u4f60\u53ef\u4ee5\u5728 \u200b\u200bzram-generator.conf\u200b\u200b \u914d\u7f6e\u6587\u4ef6\u7684\u6700\u540e\u4e00\u884c\u6539\u53d8\u9ed8\u8ba4\u7684 zram \u4ea4\u6362\u7a7a\u95f4\u5927\u5c0f\u3002\u4f46\u6211\u5efa\u8bae\u4e0d\u8981\u8fd9\u6837\u505a\uff0c\u9664\u975e\u4f60\u80fd\u660e\u786e\u8bf4\u660e\u8fd9\u6837\u505a\u7684\u539f\u56e0\uff0c\u5e76\u5728\u4f60\u505a\u4efb\u4f55\u6539\u53d8\u540e\u6d4b\u8bd5\u4f60\u7684\u7ed3\u679c\u3002\u50cf Linux \u4e2d\u7684\u8bb8\u591a\u5176\u4ed6\u914d\u7f6e\u9ed8\u8ba4\u503c\u4e00\u6837\uff0czram \u7684\u9ed8\u8ba4\u503c\u5df2\u7ecf\u88ab\u5f88\u597d\u5730\u6d4b\u8bd5\u8fc7\u4e86\uff0c\u9002\u5408\u5927\u591a\u6570\u4f7f\u7528\u60c5\u51b5\u3002<\/p>\n

\u76d1\u63a7 zram<\/strong><\/div>\n

\u53ef\u4ee5\u4f7f\u7528 \u200b\u200bzramctl\u200b\u200b \u5de5\u5177\u6765\u67e5\u770b zram \u7684\u5f53\u524d\u72b6\u6001\u3002<\/p>\n

# zramctlNAME       ALGORITHM DISKSIZE DATA COMPR TOTAL STREAMS MOUNTPOINT\/dev\/zram0 lzo-rle       4.8G   4K   80B   12K       4[SWAP]\r\n<\/pre>\n

\u4f20\u7edf\u7684 \u200b\u200bswapon\u200b\u200b \u547d\u4ee4\u4e5f\u53ef\u4ee5\u7528\u6765\u67e5\u770b\u4ea4\u6362\uff0c\u5305\u62ec\u4f5c\u4e3a\u4ea4\u6362\u4f7f\u7528\u7684 zram\uff1a<\/p>\n

# swapon --showNAME       TYPE      SIZE USED PRIO\/dev\/zram0 partition 4.8G   0B  100\r\n<\/pre>\n

\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u200b\u200bzramctl\u200b\u200b \u5728\u4e0d\u5305\u542b\u6570\u636e\u65f6\u4e0d\u62a5\u544a zram\uff0c\u6240\u4ee5\u7ed3\u679c\u4f1a\u5305\u542b\u7a7a\u8f93\u51fa\u3002\u800c\u50cf \u200b\u200blsblk\u200b\u200b\u3001\u200b\u200bswapon\u200b\u200b\u3001 \u200b\u200btop\u200b\u200b\u3001\u200b\u200bfree\u200b\u200b\u3001\u200b\u200bhtop\u200b\u200b \u7b49\u5de5\u5177\uff0c\u5373\u4f7f\u4e0d\u5305\u542b\u6570\u636e\uff0c\u4e5f\u4f1a\u663e\u793a zram\u3002<\/p>\n

\u505c\u7528 zram<\/strong><\/div>\n

\u200b\u200bswapoff -a\u200b\u200b \u547d\u4ee4\u4f1a\u5173\u95ed zram \u4ea4\u6362\u7a7a\u95f4\u4ee5\u53ca\u7528\u4f5c\u4ea4\u6362\u7684\u4f20\u7edf HDD \u6216 SSD \u5b58\u50a8\u3002\u200b\u200bswapon -a\u200b\u200b \u547d\u4ee4\u5728 zram \u4e3a\u7a7a\u65f6\u4e0d\u663e\u793a\u5b83\uff0c\u53ef\u4ee5\u4f7f\u7528 \u200b\u200bzramctl \/dev\/zram0\u200b\u200b \u4ee3\u66ff\u3002<\/p>\n

# swapon --show# lsblkNAME          MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTSsda             8:00  120G  0 disk\u251c\u2500sda1          8:10    1G  0 part \/boot\/efi\u251c\u2500sda2          8:20    1G  0 part \/boot\u2514\u2500sda3          8:30  118G  0 part  \u251c\u2500vg01-root 253:00   10G  0 lvm  \/  \u251c\u2500vg01-swap 253:10    3G  0 lvm  [SWAP]  \u251c\u2500vg01-usr  253:10   30G  0 lvm  \/usr  \u251c\u2500vg01-home 253:20   10G  0 lvm  \/home  \u251c\u2500vg01-var  253:30   30G  0 lvm  \/var  \u2514\u2500vg01-tmp  253:40   10G  0 lvm  \/tmpsr0            11:01 1024M  0 romzram0         252:00    0B  0 disk# zramctl## zramctl \/dev\/zram0NAME       ALGORITHM DISKSIZE DATA COMPR TOTAL STREAMS MOUNTPOINT\/dev\/zram0 lzo-rle         0B   0B    0B    0B       4\r\n<\/pre>\n

\u6ce8\u610f\uff0c\u200b\u200b\/dev\/zram0\u200b\u200b \u5728\u8fd9\u4e9b\u547d\u4ee4\u4e2d\u5e76\u6ca1\u6709\u663e\u793a\u4e3a\u4ea4\u6362\u7a7a\u95f4\uff0c\u76f4\u5230\u5b83\u88ab\u7528\u4e8e\u8be5\u76ee\u7684\u3002\u8fd9\u7ed9\u6211\u9020\u6210\u4e86\u4e00\u4e9b\u56f0\u60d1\uff0c\u76f4\u5230\u6211\u7684\u5b9e\u9a8c\u8868\u660e\u8fd9\u662f\u4e8b\u5b9e\u3002<\/p>\n

\u521b\u5efa zram \u4ea4\u6362\u7a7a\u95f4<\/strong><\/div>\n

zram \u672c\u8eab\u5df2\u7ecf\u5b58\u5728\u4e86\u5927\u7ea6 20 \u5e74\uff0c\u4f46\u53ea\u662f\u5728\u8fc7\u53bb\u7684\u4e00\u4e24\u5e74\u91cc\u624d\u5728\u4e00\u4e9b\u53d1\u884c\u7248\u4e0a\u4f5c\u4e3a\u4ea4\u6362\u7a7a\u95f4\u4f7f\u7528\u3002\u4f60\u7684\u4e00\u4e9b\u6216\u6240\u6709\u4e3b\u673a\u4e0a\u5f53\u524d\u7684 Linux \u73af\u5883\u53ef\u80fd\u6ca1\u6709\u7528 zram \u521b\u5efa\u4ea4\u6362\u7a7a\u95f4\u3002\u5982\u679c\u662f\u8fd9\u79cd\u60c5\u51b5\uff0c\u5b83\u53ef\u4ee5\u5f88\u5bb9\u6613\u5730\u88ab\u8865\u6551\u3002<\/p>\n

\u5bf9\u4e8e Fedora 32\uff0c\u5b83\u662f\u9ed8\u8ba4\u4f7f\u7528 zram \u4ea4\u6362\u7a7a\u95f4\u4e4b\u524d\u7684\u6700\u540e\u4e00\u4e2a\u7248\u672c\uff0c\u5b83\u53ea\u9700\u8981\u4e09\u4e2a\u7b80\u5355\u7684\u547d\u4ee4\u3002<\/p>\n

\u9996\u5148\uff0c\u9a8c\u8bc1\u662f\u5426\u5b58\u5728 \u200b\u200bzram-swap.service\u200b\u200b \u6587\u4ef6\uff0c\u5b83\u4f5c\u4e3a \u200b\u200bzram\u200b\u200b RPM \u5305\u7684\u4e00\u90e8\u5206\u5b89\u88c5\uff1a<\/p>\n

# systemctl status zram-swap\u25cf zram-swap.service - Enable compressed swap in memory using zram     Loaded: loaded (\/usr\/lib\/systemd\/system\/zram-swap.service; disabled; vendor preset: disabled)     Active: inactive (dead)\r\n<\/pre>\n

\u63a5\u4e0b\u6765\uff0c\u5b89\u88c5 \u200b\u200bzram-generator-defaults\u200b\u200b \u548c \u200b\u200bzram-generator\u200b\u200b \u8f6f\u4ef6\u5305\uff1a<\/p>\n

# dnf install zram-generator-defaults zram-generator\r\n<\/pre>\n

\u542f\u7528\u5e76\u542f\u52a8 \u200b\u200bzram-swap\u200b\u200b \u670d\u52a1\uff1a<\/p>\n

# systemctl enable zram-swap.service# systemctl start zram-swap.service\r\n<\/pre>\n

\u7136\u540e\u9a8c\u8bc1 \u200b\u200bzram0\u200b\u200b \u662f\u5426\u5b58\u5728\u5e76\u88ab\u7528\u4f5c\u4ea4\u6362\u7a7a\u95f4\uff1a<\/p>\n

# lsblkNAME          MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTsda             8:00  120G  0 disk\u251c\u2500sda1          8:10    2G  0 part \/boot\u2514\u2500sda2          8:20  118G  0 part  \u251c\u2500vg01-root 253:00   10G  0 lvm  \/  \u251c\u2500vg01-swap 253:10    3G  0 lvm  [SWAP]  \u251c\u2500vg01-usr  253:20   35G  0 lvm  \/usr  \u251c\u2500vg01-tmp  253:30   15G  0 lvm  \/tmp  \u251c\u2500vg01-var  253:40   35G  0 lvm  \/var  \u2514\u2500vg01-home 253:50   20G  0 lvm  \/homesr0            11:01 1024M  0 romzram0         252:00  7.5G  0 disk [SWAP]\r\n<\/pre>\n
\u7528 zram \u6539\u8fdb\u4ea4\u6362\u7a7a\u95f4<\/strong><\/div>\n

\u8fd9\u5c31\u662f\u5168\u90e8\u5185\u5bb9\u4e86\u3002\u5728 Fedora \u4e0a\u8fd9\u5f88\u5bb9\u6613\u3002\u4e0d\u540c\u7684\u53d1\u884c\u7248\u53ef\u80fd\u4e5f\u4e00\u6837\u7b80\u5355\uff0c\u53ea\u662f\u8f6f\u4ef6\u5305\u540d\u79f0\u548c\u547d\u4ee4\u7684\u7ec6\u8282\u53ef\u80fd\u4e0d\u540c\u3002\u5728\u4f60\u7684\u7535\u8111\u4e0a\u8bd5\u8bd5 zram \u4ea4\u6362\u7a7a\u95f4\u5427\u3002\u5728\u6211\u7684\u4e0b\u4e00\u7bc7\u6587\u7ae0\u4e2d\uff0c\u6211\u5c06\u8fdb\u4e00\u6b65\u6f14\u793a\u4e00\u4e9b zram \u9009\u9879\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

\u6211\u5728\u6211\u7684\u7535\u8111\u4e0a\u82b1\u4e86\u5f88\u591a\u65f6\u95f4\uff08\u6211\u662f\u8bf4\u5de5\u4f5c\uff09\uff0c\u6211\u53d1\u73b0\u4e86\u5f88\u591a\u6709\u8da3\u7684\u4e1c\u897f\u3002\u5176\u4e2d\u6700\u8fd1\u5f15\u8d77\u6211\u6ce8\u610f\u7684\u662f \u200b\u200bzram0\u200b\u200b\u200b […]<\/p>\n","protected":false},"author":1469,"featured_media":262824,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-262822","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/262822","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1469"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=262822"}],"version-history":[{"count":2,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/262822\/revisions"}],"predecessor-version":[{"id":262826,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/262822\/revisions\/262826"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/262824"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=262822"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=262822"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=262822"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}