{"id":106727,"date":"2026-09-18T07:48:51","date_gmt":"2026-09-17T23:48:51","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/106727.html"},"modified":"2026-09-18T07:48:51","modified_gmt":"2026-09-17T23:48:51","slug":"linux-%e6%9c%8d%e5%8a%a1%e5%99%a8-tmp-%e7%9b%ae%e5%bd%95%ef%bc%9a%e4%bd%bf%e7%94%a8%e6%9c%ba%e5%88%b6%e4%b8%8e%e5%ae%89%e5%85%a8%e5%8a%a0%e5%9b%ba","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/106727.html","title":{"rendered":"Linux \u670d\u52a1\u5668 \/tmp \u76ee\u5f55\uff1a\u4f7f\u7528\u673a\u5236\u4e0e\u5b89\u5168\u52a0\u56fa"},"content":{"rendered":"<h2>Linux \u670d\u52a1\u5668 \/tmp \u76ee\u5f55&#xff1a;\u4f7f\u7528\u673a\u5236\u4e0e\u5b89\u5168\u52a0\u56fa<\/h2>\n<p>\u672c\u6587\u57fa\u4e8e Kylin V10 SP3 \/ RHEL 8 \u7cfb\u5217\u7cfb\u7edf\u5b9e\u8df5\u6574\u7406&#xff0c;\u9002\u7528\u4e8e\u4e91\u670d\u52a1\u5668\u548c Kubernetes \u8282\u70b9\u573a\u666f\u3002<\/p>\n<h3>1. \/tmp \u7684\u4e24\u79cd\u5b58\u50a8\u540e\u7aef<\/h3>\n<p>\u5f88\u591a\u4eba\u4ee5\u4e3a \/tmp \u5c31\u662f\u78c1\u76d8\u4e0a\u7684\u4e00\u4e2a\u76ee\u5f55&#xff0c;\u4f46\u5b9e\u9645\u4e0a\u5b83\u53ef\u80fd\u8fd0\u884c\u5728\u4e24\u79cd\u5b8c\u5168\u4e0d\u540c\u7684\u5b58\u50a8\u540e\u7aef\u4e0a\u3002<\/p>\n<h4>\u57fa\u4e8e\u78c1\u76d8&#xff08;\u9ed8\u8ba4\u76ee\u5f55&#xff09;<\/h4>\n<p>\u5982\u679c \/tmp \u6ca1\u6709\u88ab\u5355\u72ec\u6302\u8f7d&#xff0c;\u5b83\u5c31\u662f\u6839\u6587\u4ef6\u7cfb\u7edf \/ \u4e0b\u7684\u4e00\u4e2a\u666e\u901a\u76ee\u5f55&#xff0c;\u6570\u636e\u5b58\u50a8\u5728\u78c1\u76d8\u4e0a&#xff0c;\u4e0d\u5360\u7528\u5185\u5b58\u3002<\/p>\n<h4>\u57fa\u4e8e\u5185\u5b58&#xff08;tmpfs&#xff09;<\/h4>\n<p>\u5982\u679c \/tmp \u88ab\u6302\u8f7d\u4e3a tmpfs&#xff0c;\u5b83\u4f7f\u7528\u7269\u7406\u5185\u5b58&#xff08;RAM \u4e0d\u8db3\u65f6\u4f1a\u4f7f\u7528 swap&#xff09;\u3002tmpfs \u9ed8\u8ba4\u6700\u5927\u53ef\u4f7f\u7528 50% \u7684\u7cfb\u7edf\u5185\u5b58&#xff0c;\u4f46\u5b83\u662f\u6309\u9700\u5206\u914d\u7684\u2014\u2014\u5982\u679c \/tmp \u91cc\u53ea\u6709 10MB \u6587\u4ef6&#xff0c;\u5c31\u53ea\u5360\u7528 10MB \u5185\u5b58\u3002<\/p>\n<p>\u7528\u4ee5\u4e0b\u547d\u4ee4\u786e\u8ba4\u4f60\u7684\u7cfb\u7edf\u4f7f\u7528\u7684\u662f\u54ea\u79cd\u65b9\u5f0f&#xff1a;<\/p>\n<p><span class=\"token function\">df<\/span> <span class=\"token parameter variable\">-hT<\/span> \/tmp<br \/>\nfindmnt \/tmp<\/p>\n<p>\u5982\u679c\u8f93\u51fa\u4e2d FSTYPE \u662f tmpfs&#xff0c;\u8bf4\u660e\u662f\u5185\u5b58\u6a21\u5f0f&#xff1b;\u5982\u679c\u548c\u6839\u5206\u533a\u4e00\u6837&#xff08;\u5982 xfs\u3001ext4&#xff09;&#xff0c;\u8bf4\u660e\u662f\u78c1\u76d8\u6a21\u5f0f\u3002<\/p>\n<h3>2. systemd \u7684\u9690\u5f0f\u6302\u8f7d\u884c\u4e3a<\/h3>\n<p>\u5728 RHEL 8 \/ Kylin V10 \u7cfb\u7edf\u4e0a&#xff0c;\u5373\u4f7f \/etc\/fstab \u4e2d\u6ca1\u6709 \/tmp \u7684\u6761\u76ee&#xff0c;systemd \u4e5f\u53ef\u80fd\u81ea\u52a8\u5c06 \/tmp \u6302\u8f7d\u4e3a tmpfs\u3002\u8fd9\u662f\u901a\u8fc7 tmp.mount \u5355\u5143\u5b9e\u73b0\u7684\u3002<\/p>\n<p>systemctl status tmp.mount<\/p>\n<p>\u4f60\u53ef\u80fd\u4f1a\u770b\u5230\u7c7b\u4f3c\u5982\u4e0b\u8f93\u51fa&#xff1a;<\/p>\n<p>\u25cf tmp.mount &#8211; Temporary Directory (\/tmp)<br \/>\n   Loaded: loaded (\/usr\/lib\/systemd\/system\/tmp.mount; disabled; vendor preset: disabled)<br \/>\n   Active: active (mounted)<\/p>\n<p>\u6ce8\u610f disabled \u4f46 active\u2014\u2014\u8bf4\u660e\u8fd9\u4e2a\u5355\u5143\u6ca1\u6709\u88ab\u663e\u5f0f\u542f\u7528&#xff0c;\u4f46 systemd \u7684\u9ed8\u8ba4\u914d\u7f6e\u4ecd\u7136\u89e6\u53d1\u4e86\u6302\u8f7d\u3002\u8fd9\u79cd&#034;\u9690\u5f0f\u884c\u4e3a&#034;\u5f88\u5bb9\u6613\u88ab\u5ffd\u89c6\u3002<\/p>\n<h3>3. \u5bf9 Kubernetes \u8282\u70b9\u7684\u5f71\u54cd<\/h3>\n<p>\u5728 K8s \u8282\u70b9\u4e0a&#xff0c;\u5982\u679c \/tmp \u4f7f\u7528 tmpfs \u4e14\u6ca1\u6709\u8bbe\u7f6e\u5927\u5c0f\u9650\u5236&#xff0c;\u9700\u8981\u7279\u522b\u6ce8\u610f&#xff1a;<\/p>\n<ul>\n<li>\u5185\u5b58\u7ade\u4e89&#xff1a;kubelet\u3001\u7cfb\u7edf\u670d\u52a1\u548c Pod \u90fd\u5728\u4e89\u7528\u5185\u5b58\u3002\u5982\u679c\u67d0\u4e2a\u8fdb\u7a0b\u5411 \/tmp \u5199\u5165\u5927\u91cf\u4e34\u65f6\u6587\u4ef6&#xff0c;\u4f1a\u76f4\u63a5\u6324\u5360\u53ef\u7528\u5185\u5b58&#xff0c;\u53ef\u80fd\u89e6\u53d1 OOM Killer\u3002<\/li>\n<li>\u5bb9\u5668\u9694\u79bb&#xff1a;\u597d\u6d88\u606f\u662f&#xff0c;\u5bb9\u5668\u5185\u90e8\u6709\u81ea\u5df1\u72ec\u7acb\u7684 \/tmp&#xff0c;\u4e0d\u4f1a\u4f7f\u7528\u5bbf\u4e3b\u673a\u7684 \/tmp\u3002\u4f46\u5bbf\u4e3b\u673a\u4e0a\u7684\u7cfb\u7edf\u8fdb\u7a0b\u4ecd\u7136\u4f1a\u4f7f\u7528\u5b83\u3002<\/li>\n<\/ul>\n<p>\u5efa\u8bae\u65b9\u6848&#xff1a;<\/p>\n<ul>\n<li>\u5982\u679c\u5185\u5b58\u5145\u8db3&#xff0c;\u4fdd\u7559 tmpfs \u4f46\u8bbe\u7f6e\u5927\u5c0f\u9650\u5236&#xff08;\u5982 size&#061;512M&#xff09;<\/li>\n<li>\u5982\u679c\u5185\u5b58\u7d27\u5f20&#xff0c;\u6539\u4e3a\u78c1\u76d8\u6a21\u5f0f&#xff0c;\u907f\u514d \/tmp \u4e0e Pod \u4e89\u7528\u5185\u5b58<\/li>\n<\/ul>\n<h3>4. CIS \u5b89\u5168\u52a0\u56fa\u8981\u6c42<\/h3>\n<p>CIS Benchmark&#xff08;\u56fd\u9645\u4e92\u8054\u7f51\u5b89\u5168\u4e2d\u5fc3\u57fa\u51c6&#xff09;\u662f\u4e1a\u754c\u5e7f\u6cdb\u8ba4\u53ef\u7684\u5b89\u5168\u52a0\u56fa\u6807\u51c6&#xff0c;\u5176\u4e2d\u5bf9 \/tmp \u7684\u8981\u6c42\u4e3b\u8981\u6d89\u53ca\u4e09\u4e2a\u6302\u8f7d\u9009\u9879&#xff1a;<\/p>\n<table>\n<tr>\u9009\u9879\u4f5c\u7528<\/tr>\n<tbody>\n<tr>\n<td>noexec<\/td>\n<td>\u7981\u6b62\u6267\u884c \/tmp \u4e2d\u7684\u4efb\u4f55\u7a0b\u5e8f\u6216\u811a\u672c<\/td>\n<\/tr>\n<tr>\n<td>nosuid<\/td>\n<td>\u5ffd\u7565 \/tmp \u4e2d\u6587\u4ef6\u7684 SUID\/SGID \u4f4d<\/td>\n<\/tr>\n<tr>\n<td>nodev<\/td>\n<td>\u7981\u6b62\u5728 \/tmp \u4e2d\u521b\u5efa\u8bbe\u5907\u6587\u4ef6<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>\u4e3a\u4ec0\u4e48\u9700\u8981 noexec&#xff1f;<\/h4>\n<p>\/tmp \u662f\u6240\u6709\u7528\u6237\u90fd\u53ef\u4ee5\u5199\u5165\u7684\u76ee\u5f55&#xff08;\u6743\u9650\u4e3a 1777&#xff09;\u3002\u653b\u51fb\u8005\u5e38\u89c1\u7684\u624b\u6cd5\u662f&#xff1a;\u5c06\u6076\u610f\u53ef\u6267\u884c\u6587\u4ef6\u4e0a\u4f20\u5230 \/tmp&#xff0c;\u7136\u540e\u6267\u884c\u5b83\u3002noexec \u5728\u5185\u6838\u5c42\u9762\u963b\u6b62\u4e86\u8fd9\u79cd\u884c\u4e3a\u3002<\/p>\n<h4>noexec \u548c chmod \u53bb\u6389 x \u6743\u9650\u662f\u4e00\u56de\u4e8b\u5417&#xff1f;<\/h4>\n<p>\u4e0d\u662f\u3002\u8fd9\u662f\u4e24\u4e2a\u5b8c\u5168\u4e0d\u540c\u5c42\u9762\u7684\u673a\u5236&#xff1a;<\/p>\n<ul>\n<li>chmod -x \/tmp&#xff08;\u76ee\u5f55\u6743\u9650&#xff09;&#xff1a;\u53bb\u6389\u76ee\u5f55\u7684 x \u6743\u9650\u610f\u5473\u7740\u7528\u6237\u65e0\u6cd5&#034;\u8fdb\u5165&#034;\u8be5\u76ee\u5f55&#xff08;\u65e0\u6cd5 cd \/tmp&#xff09;&#xff0c;\u8fd9\u4f1a\u5bfc\u81f4\u7cfb\u7edf\u5927\u9762\u79ef\u6545\u969c&#xff0c;\u7edd\u5bf9\u4e0d\u80fd\u8fd9\u4e48\u505a\u3002<\/li>\n<li>noexec&#xff08;\u6302\u8f7d\u9009\u9879&#xff09;&#xff1a;\u5728\u5185\u6838\u5c42\u9762\u7981\u6b62\u6267\u884c\u8be5\u6302\u8f7d\u70b9\u4e0a\u7684\u4efb\u4f55\u6587\u4ef6\u3002\u6587\u4ef6\u7684\u8bfb\u5199\u4e0d\u53d7\u5f71\u54cd&#xff0c;\u53ea\u662f\u4e0d\u80fd\u4f5c\u4e3a\u7a0b\u5e8f\u8fd0\u884c\u3002\u5373\u4f7f\u6587\u4ef6\u672c\u8eab\u6709 chmod &#043;x \u7684\u6267\u884c\u6743\u9650&#xff0c;\u5185\u6838\u4e5f\u4f1a\u62d2\u7edd\u6267\u884c\u3002<\/li>\n<\/ul>\n<p><span class=\"token comment\"># noexec \u6548\u679c\u6f14\u793a<\/span><br \/>\n<span class=\"token function\">cp<\/span> \/usr\/bin\/ls \/tmp\/ls<br \/>\n<span class=\"token function\">chmod<\/span> &#043;x \/tmp\/ls<br \/>\n\/tmp\/ls<br \/>\n<span class=\"token comment\"># \u7ed3\u679c&#xff1a;Permission denied&#xff08;\u5185\u6838\u62d2\u7edd\u6267\u884c&#xff09;<\/span><\/p>\n<h3>5. \u52a0\u56fa\u64cd\u4f5c\u6b65\u9aa4<\/h3>\n<h4>\u68c0\u67e5\u5f53\u524d\u72b6\u6001<\/h4>\n<p><span class=\"token comment\"># \u67e5\u770b \/tmp \u6302\u8f7d\u4fe1\u606f<\/span><br \/>\nfindmnt \/tmp<\/p>\n<p><span class=\"token comment\"># \u67e5\u770b\u5f53\u524d\u6302\u8f7d\u9009\u9879<\/span><br \/>\n<span class=\"token function\">mount<\/span> <span class=\"token operator\">|<\/span> <span class=\"token function\">grep<\/span> \/tmp<\/p>\n<h4>\u65b9\u6848\u4e00&#xff1a;\u4fdd\u7559 tmpfs &#043; \u5b89\u5168\u9009\u9879 &#043; \u5927\u5c0f\u9650\u5236<\/h4>\n<p>\u5728 \/etc\/fstab \u4e2d\u6dfb\u52a0&#xff1a;<\/p>\n<p>tmpfs   \/tmp   tmpfs   defaults,noexec,nosuid,nodev,size&#061;512M   0 0<\/p>\n<p>\u7acb\u5373\u751f\u6548&#xff08;\u65e0\u9700\u91cd\u542f&#xff09;&#xff1a;<\/p>\n<p><span class=\"token function\">mount<\/span> <span class=\"token parameter variable\">-o<\/span> remount,noexec,nosuid,nodev \/tmp<\/p>\n<h4>\u65b9\u6848\u4e8c&#xff1a;\u78c1\u76d8\u6a21\u5f0f \u2014 \u72ec\u7acb\u5206\u533a&#xff08;\u63a8\u8350&#xff09;<\/h4>\n<p>\u5982\u679c\u9009\u62e9\u5c06 \/tmp \u653e\u5728\u78c1\u76d8\u4e0a&#xff0c;\u5f3a\u70c8\u5efa\u8bae\u4f7f\u7528\u72ec\u7acb\u5206\u533a\u800c\u4e0d\u662f\u8ba9\u5b83\u7559\u5728\u6839\u6587\u4ef6\u7cfb\u7edf\u4e2d\u3002<\/p>\n<p>\u539f\u56e0\u5f88\u7b80\u5355&#xff1a;\/tmp \u662f\u6240\u6709\u7528\u6237\u53ef\u5199\u7684\u76ee\u5f55&#xff0c;\u5982\u679c\u6ca1\u6709\u9694\u79bb&#xff0c;\u4efb\u4f55\u7528\u6237\u6216\u5931\u63a7\u8fdb\u7a0b\u90fd\u53ef\u4ee5\u5411 \/tmp \u5199\u5165\u5927\u91cf\u6570\u636e&#xff0c;\u76f4\u5230\u6491\u6ee1\u6574\u4e2a\u6839\u5206\u533a\u3002\u6839\u5206\u533a\u4e00\u65e6\u6ee1\u4e86&#xff0c;\u540e\u679c\u5f88\u4e25\u91cd\u2014\u2014\u7cfb\u7edf\u65e5\u5fd7\u65e0\u6cd5\u5199\u5165\u3001\u670d\u52a1\u65e0\u6cd5\u542f\u52a8\u3001\u751a\u81f3\u65e0\u6cd5\u901a\u8fc7 SSH \u767b\u5f55\u3002\u8fd9\u5728\u751f\u4ea7\u73af\u5883\u4e2d\u662f\u975e\u5e38\u5371\u9669\u7684\u6545\u969c\u6a21\u5f0f\u3002<\/p>\n<p>\u72ec\u7acb\u5206\u533a\u7684\u597d\u5904&#xff1a;<\/p>\n<ul>\n<li>\u7a7a\u95f4\u9694\u79bb&#xff1a;\/tmp \u5199\u6ee1\u53ea\u5f71\u54cd \/tmp \u81ea\u8eab&#xff0c;\u4e0d\u4f1a\u6ce2\u53ca\u6839\u5206\u533a\u548c\u5176\u4ed6\u5173\u952e\u76ee\u5f55&#xff08;\u5982 \/var\/log\u3001\/etc&#xff09;<\/li>\n<li>\u5bb9\u91cf\u53ef\u63a7&#xff1a;\u5206\u533a\u5927\u5c0f\u5728\u521b\u5efa\u65f6\u786e\u5b9a&#xff0c;\u5929\u7136\u9650\u5236\u4e86 \/tmp \u7684\u6700\u5927\u5360\u7528<\/li>\n<li>\u5b89\u5168\u6302\u8f7d\u9009\u9879&#xff1a;\u72ec\u7acb\u5206\u533a\u53ef\u4ee5\u76f4\u63a5\u5728 \/etc\/fstab \u4e2d\u8bbe\u7f6e noexec,nosuid,nodev<\/li>\n<\/ul>\n<p>\u64cd\u4f5c\u6b65\u9aa4&#xff1a;<\/p>\n<p>\u5982\u679c\u662f\u65b0\u88c5\u7cfb\u7edf&#xff0c;\u5728\u5b89\u88c5\u65f6\u89c4\u5212\u5206\u533a&#xff0c;\u4e3a \/tmp \u5206\u914d 1-2GB \u7684\u72ec\u7acb\u5206\u533a\u5373\u53ef\u3002<\/p>\n<p>\u5982\u679c\u662f\u5df2\u6709\u7cfb\u7edf&#xff0c;\u53ef\u4ee5\u4f7f\u7528 LVM \u521b\u5efa\u65b0\u7684\u903b\u8f91\u5377&#xff08;\u524d\u63d0\u662f VG \u4e2d\u6709\u5269\u4f59\u7a7a\u95f4&#xff09;&#xff1a;<\/p>\n<p><span class=\"token comment\"># 1. \u7981\u7528 systemd \u7684 tmpfs \u6302\u8f7d<\/span><br \/>\nsystemctl disable tmp.mount<br \/>\nsystemctl mask tmp.mount<\/p>\n<p><span class=\"token comment\"># 2. \u521b\u5efa\u903b\u8f91\u5377&#xff08;\u5047\u8bbe VG \u540d\u4e3a klas&#xff0c;\u5206\u914d 2GB&#xff09;<\/span><br \/>\nlvcreate <span class=\"token parameter variable\">-L<\/span> 2G <span class=\"token parameter variable\">-n<\/span> tmp klas<\/p>\n<p><span class=\"token comment\"># 3. \u683c\u5f0f\u5316<\/span><br \/>\nmkfs.xfs \/dev\/klas\/tmp<\/p>\n<p><span class=\"token comment\"># 4. \u6dfb\u52a0\u5230 \/etc\/fstab<\/span><br \/>\n<span class=\"token builtin class-name\">echo<\/span> <span class=\"token string\">&#039;\/dev\/mapper\/klas-tmp   \/tmp   xfs   defaults,noexec,nosuid,nodev   0 0&#039;<\/span> <span class=\"token operator\">&gt;&gt;<\/span> \/etc\/fstab<\/p>\n<p><span class=\"token comment\"># 5. \u5907\u4efd\u5f53\u524d \/tmp \u5185\u5bb9&#xff0c;\u6302\u8f7d\u65b0\u5206\u533a<\/span><br \/>\n<span class=\"token function\">cp<\/span> <span class=\"token parameter variable\">-a<\/span> \/tmp \/tmp.bak<br \/>\n<span class=\"token function\">mount<\/span> \/tmp<br \/>\n<span class=\"token function\">chmod<\/span> <span class=\"token number\">1777<\/span> \/tmp<br \/>\n<span class=\"token function\">cp<\/span> <span class=\"token parameter variable\">-a<\/span> \/tmp.bak\/* \/tmp\/ <span class=\"token operator\"><span class=\"token file-descriptor important\">2<\/span>&gt;<\/span>\/dev\/null<span class=\"token punctuation\">;<\/span> <span class=\"token function\">rm<\/span> <span class=\"token parameter variable\">-rf<\/span> \/tmp.bak<\/p>\n<h4>\u65b9\u6848\u4e09&#xff1a;\u78c1\u76d8\u6a21\u5f0f \u2014 bind mount&#xff08;\u65e0\u6cd5\u5212\u5206\u72ec\u7acb\u5206\u533a\u65f6\u7684\u66ff\u4ee3\u65b9\u6848&#xff09;<\/h4>\n<p>\u5982\u679c\u7cfb\u7edf\u5df2\u7ecf\u90e8\u7f72\u5b8c\u6bd5\u4e14 VG \u6ca1\u6709\u5269\u4f59\u7a7a\u95f4&#xff0c;\u65e0\u6cd5\u521b\u5efa\u72ec\u7acb\u5206\u533a&#xff0c;\u53ef\u4ee5\u9000\u800c\u6c42\u5176\u6b21\u4f7f\u7528 bind mount\u3002\u8fd9\u79cd\u65b9\u5f0f\u53ef\u4ee5\u6dfb\u52a0\u5b89\u5168\u6302\u8f7d\u9009\u9879&#xff0c;\u4f46\u65e0\u6cd5\u5b9e\u73b0\u7a7a\u95f4\u9694\u79bb\u2014\u2014\/tmp \u4ecd\u7136\u548c\u6839\u5206\u533a\u5171\u4eab\u78c1\u76d8\u7a7a\u95f4\u3002<\/p>\n<p><span class=\"token comment\"># \u7981\u7528 systemd \u7684 tmpfs \u6302\u8f7d<\/span><br \/>\nsystemctl disable tmp.mount<br \/>\nsystemctl mask tmp.mount<\/p>\n<p>\u5728 \/etc\/fstab \u4e2d\u6dfb\u52a0&#xff1a;<\/p>\n<p>\/tmp   \/tmp   none   bind,noexec,nosuid,nodev   0 0<\/p>\n<p>\u4f7f\u7528 bind mount \u65f6&#xff0c;\u5efa\u8bae\u914d\u5408 \u78c1\u76d8\u914d\u989d&#xff08;quota&#xff09; \u6216\u5b9a\u671f\u6e05\u7406\u8ba1\u5212\u4efb\u52a1\u6765\u9632\u6b62 \/tmp \u65e0\u9650\u589e\u957f&#xff1a;<\/p>\n<p><span class=\"token comment\"># \u6dfb\u52a0\u5b9a\u65f6\u6e05\u7406&#xff08;\u4f8b\u5982\u6e05\u7406\u8d85\u8fc7 7 \u5929\u7684\u6587\u4ef6&#xff09;<\/span><br \/>\n<span class=\"token builtin class-name\">echo<\/span> <span class=\"token string\">&#039;systemd-tmpfiles &#8211;clean&#039;<\/span> <span class=\"token operator\">&gt;<\/span> \/etc\/cron.daily\/tmp-cleanup<br \/>\n<span class=\"token function\">chmod<\/span> &#043;x \/etc\/cron.daily\/tmp-cleanup<\/p>\n<h4>\u9a8c\u8bc1<\/h4>\n<p>findmnt \/tmp<br \/>\n<span class=\"token comment\"># \u786e\u8ba4 OPTIONS \u4e2d\u5305\u542b rw,nosuid,nodev,noexec<\/span><\/p>\n<h3>6. \u6ce8\u610f\u4e8b\u9879<\/h3>\n<h4>\u517c\u5bb9\u6027\u5f71\u54cd<\/h4>\n<p>\u67d0\u4e9b\u8f6f\u4ef6\u4f1a\u5728 \/tmp \u4e2d\u5199\u5165\u5e76\u6267\u884c\u4e34\u65f6\u6587\u4ef6&#xff0c;\u6dfb\u52a0 noexec \u540e\u53ef\u80fd\u53d7\u5230\u5f71\u54cd&#xff1a;<\/p>\n<ul>\n<li>\u90e8\u5206\u8f6f\u4ef6\u5b89\u88c5\u7a0b\u5e8f&#xff08;\u5982\u67d0\u4e9b RPM \u7684 %post \u811a\u672c&#xff09;<\/li>\n<li>pip install \u7f16\u8bd1 C \u6269\u5c55\u65f6<\/li>\n<li>\u67d0\u4e9b Java \u5e94\u7528\u7684\u4e34\u65f6\u6587\u4ef6<\/li>\n<li>rpmbuild \u6784\u5efa\u8fc7\u7a0b<\/li>\n<\/ul>\n<p>\u9047\u5230\u95ee\u9898\u65f6\u53ef\u4ee5\u4e34\u65f6\u653e\u5f00\u9650\u5236&#xff1a;<\/p>\n<p><span class=\"token function\">mount<\/span> <span class=\"token parameter variable\">-o<\/span> remount,exec \/tmp<br \/>\n<span class=\"token comment\"># \u5b8c\u6210\u64cd\u4f5c\u540e\u6062\u590d<\/span><br \/>\n<span class=\"token function\">mount<\/span> <span class=\"token parameter variable\">-o<\/span> remount,noexec \/tmp<\/p>\n<h4>K8s \u8282\u70b9\u7279\u522b\u8bf4\u660e<\/h4>\n<p>\u5bf9\u4e8e K8s \u8282\u70b9&#xff0c;noexec \u901a\u5e38\u4e0d\u4f1a\u5f71\u54cd\u5bb9\u5668\u5316\u5de5\u4f5c\u8d1f\u8f7d&#xff0c;\u56e0\u4e3a\u5bb9\u5668\u4f7f\u7528\u81ea\u5df1\u7684\u6587\u4ef6\u7cfb\u7edf\u3002\u4f46\u5982\u679c\u4f60\u5728\u5bbf\u4e3b\u673a\u4e0a\u76f4\u63a5\u8fd0\u884c\u6784\u5efa\u4efb\u52a1\u6216\u5b89\u88c5\u8f6f\u4ef6&#xff0c;\u9700\u8981\u7559\u610f\u517c\u5bb9\u6027\u3002<\/p>\n<h3>7. \u603b\u7ed3<\/h3>\n<table>\n<tr>\u573a\u666f\u63a8\u8350\u65b9\u6848<\/tr>\n<tbody>\n<tr>\n<td>\u5185\u5b58\u5145\u8db3\u7684\u901a\u7528\u670d\u52a1\u5668<\/td>\n<td>tmpfs &#043; noexec,nosuid,nodev &#043; size&#061; \u9650\u5236<\/td>\n<\/tr>\n<tr>\n<td>\u5185\u5b58\u7d27\u5f20\u7684 K8s \u8282\u70b9<\/td>\n<td>\u72ec\u7acb\u5206\u533a &#043; noexec,nosuid,nodev&#xff08;\u9996\u9009&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u5df2\u90e8\u7f72\u7cfb\u7edf&#xff0c;\u65e0\u6cd5\u65b0\u5efa\u5206\u533a<\/td>\n<td>bind mount &#043; noexec,nosuid,nodev &#043; \u5b9a\u671f\u6e05\u7406<\/td>\n<\/tr>\n<tr>\n<td>\u5f00\u53d1\/\u6784\u5efa\u670d\u52a1\u5668<\/td>\n<td>\u72ec\u7acb\u5206\u533a\u6216 bind mount &#043; nosuid,nodev&#xff08;\u8003\u8651\u4e0d\u52a0 noexec&#xff09;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u65e0\u8bba\u9009\u62e9\u54ea\u79cd\u65b9\u6848&#xff0c;\u6838\u5fc3\u539f\u5219\u6709\u4e24\u4e2a&#xff1a;\u4e00\u662f\u8ba9 \/tmp \u7684\u914d\u7f6e\u663e\u5f0f\u53ef\u63a7\u2014\u2014\u4e0d\u8981\u4f9d\u8d56 systemd \u7684\u9690\u5f0f\u884c\u4e3a&#xff0c;\u5728 \/etc\/fstab \u4e2d\u660e\u786e\u5b9a\u4e49&#xff0c;\u786e\u4fdd\u91cd\u542f\u540e\u914d\u7f6e\u4e00\u81f4&#xff1b;\u4e8c\u662f\u7a7a\u95f4\u9694\u79bb\u2014\u2014\u5c3d\u91cf\u907f\u514d \/tmp \u4e0e\u6839\u5206\u533a\u5171\u4eab\u7a7a\u95f4&#xff0c;\u9632\u6b62 \/tmp \u88ab\u5199\u6ee1\u540e\u5f71\u54cd\u6574\u4e2a\u7cfb\u7edf\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Linux \u670d\u52a1\u5668 \/tmp \u76ee\u5f55&#xff1a;\u4f7f\u7528\u673a\u5236\u4e0e\u5b89\u5168\u52a0\u56fa\u672c\u6587\u57fa\u4e8e Kylin V10 SP3 \/ RHEL 8 \u7cfb\u5217\u7cfb\u7edf\u5b9e\u8df5\u6574\u7406&#xff0c;\u9002\u7528\u4e8e\u4e91\u670d\u52a1\u5668\u548c Kubernetes \u8282\u70b9\u573a\u666f\u30021. \/tmp \u7684\u4e24\u79cd\u5b58\u50a8\u540e\u7aef<br \/>\n\u5f88\u591a\u4eba\u4ee5\u4e3a \/tmp \u5c31\u662f\u78c1\u76d8\u4e0a\u7684\u4e00\u4e2a\u76ee\u5f55&#xff0c;\u4f46\u5b9e\u9645\u4e0a\u5b83\u53ef\u80fd\u8fd0\u884c\u5728\u4e24\u79cd\u5b8c\u5168\u4e0d\u540c\u7684\u5b58\u50a8\u540e\u7aef\u4e0a\u3002<br \/>\n\u57fa\u4e8e\u78c1\u76d8&#xff08;\u9ed8\u8ba4\u76ee\u5f55&#xff09;<br \/>\n\u5982\u679c \/tmp \u6ca1\u6709\u88ab\u5355\u72ec\u6302\u8f7d&#xff0c;\u5b83\u5c31\u662f\u6839\u6587\u4ef6\u7cfb\u7edf \/ \u4e0b\u7684\u4e00\u4e2a\u666e\u901a\u76ee\u5f55&amp;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[58,61,43],"topic":[],"class_list":["post-106727","post","type-post","status-publish","format-standard","hentry","category-server","tag-linux","tag-61","tag-43"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Linux \u670d\u52a1\u5668 \/tmp \u76ee\u5f55\uff1a\u4f7f\u7528\u673a\u5236\u4e0e\u5b89\u5168\u52a0\u56fa - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/106727.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Linux \u670d\u52a1\u5668 \/tmp \u76ee\u5f55\uff1a\u4f7f\u7528\u673a\u5236\u4e0e\u5b89\u5168\u52a0\u56fa - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"Linux \u670d\u52a1\u5668 \/tmp \u76ee\u5f55&#xff1a;\u4f7f\u7528\u673a\u5236\u4e0e\u5b89\u5168\u52a0\u56fa\u672c\u6587\u57fa\u4e8e Kylin V10 SP3 \/ RHEL 8 \u7cfb\u5217\u7cfb\u7edf\u5b9e\u8df5\u6574\u7406&#xff0c;\u9002\u7528\u4e8e\u4e91\u670d\u52a1\u5668\u548c Kubernetes \u8282\u70b9\u573a\u666f\u30021. \/tmp \u7684\u4e24\u79cd\u5b58\u50a8\u540e\u7aef \u5f88\u591a\u4eba\u4ee5\u4e3a \/tmp \u5c31\u662f\u78c1\u76d8\u4e0a\u7684\u4e00\u4e2a\u76ee\u5f55&#xff0c;\u4f46\u5b9e\u9645\u4e0a\u5b83\u53ef\u80fd\u8fd0\u884c\u5728\u4e24\u79cd\u5b8c\u5168\u4e0d\u540c\u7684\u5b58\u50a8\u540e\u7aef\u4e0a\u3002 \u57fa\u4e8e\u78c1\u76d8&#xff08;\u9ed8\u8ba4\u76ee\u5f55&#xff09; \u5982\u679c \/tmp \u6ca1\u6709\u88ab\u5355\u72ec\u6302\u8f7d&#xff0c;\u5b83\u5c31\u662f\u6839\u6587\u4ef6\u7cfb\u7edf \/ \u4e0b\u7684\u4e00\u4e2a\u666e\u901a\u76ee\u5f55&amp;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/106727.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-09-17T23:48:51+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/106727.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/106727.html\",\"name\":\"Linux \u670d\u52a1\u5668 \/tmp \u76ee\u5f55\uff1a\u4f7f\u7528\u673a\u5236\u4e0e\u5b89\u5168\u52a0\u56fa - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-09-17T23:48:51+00:00\",\"dateModified\":\"2026-09-17T23:48:51+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/106727.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/106727.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/106727.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Linux \u670d\u52a1\u5668 \/tmp \u76ee\u5f55\uff1a\u4f7f\u7528\u673a\u5236\u4e0e\u5b89\u5168\u52a0\u56fa\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Linux \u670d\u52a1\u5668 \/tmp \u76ee\u5f55\uff1a\u4f7f\u7528\u673a\u5236\u4e0e\u5b89\u5168\u52a0\u56fa - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/106727.html","og_locale":"zh_CN","og_type":"article","og_title":"Linux \u670d\u52a1\u5668 \/tmp \u76ee\u5f55\uff1a\u4f7f\u7528\u673a\u5236\u4e0e\u5b89\u5168\u52a0\u56fa - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"Linux \u670d\u52a1\u5668 \/tmp \u76ee\u5f55&#xff1a;\u4f7f\u7528\u673a\u5236\u4e0e\u5b89\u5168\u52a0\u56fa\u672c\u6587\u57fa\u4e8e Kylin V10 SP3 \/ RHEL 8 \u7cfb\u5217\u7cfb\u7edf\u5b9e\u8df5\u6574\u7406&#xff0c;\u9002\u7528\u4e8e\u4e91\u670d\u52a1\u5668\u548c Kubernetes \u8282\u70b9\u573a\u666f\u30021. \/tmp \u7684\u4e24\u79cd\u5b58\u50a8\u540e\u7aef \u5f88\u591a\u4eba\u4ee5\u4e3a \/tmp \u5c31\u662f\u78c1\u76d8\u4e0a\u7684\u4e00\u4e2a\u76ee\u5f55&#xff0c;\u4f46\u5b9e\u9645\u4e0a\u5b83\u53ef\u80fd\u8fd0\u884c\u5728\u4e24\u79cd\u5b8c\u5168\u4e0d\u540c\u7684\u5b58\u50a8\u540e\u7aef\u4e0a\u3002 \u57fa\u4e8e\u78c1\u76d8&#xff08;\u9ed8\u8ba4\u76ee\u5f55&#xff09; \u5982\u679c \/tmp \u6ca1\u6709\u88ab\u5355\u72ec\u6302\u8f7d&#xff0c;\u5b83\u5c31\u662f\u6839\u6587\u4ef6\u7cfb\u7edf \/ \u4e0b\u7684\u4e00\u4e2a\u666e\u901a\u76ee\u5f55&amp;","og_url":"https:\/\/www.wsisp.com\/helps\/106727.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-09-17T23:48:51+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/106727.html","url":"https:\/\/www.wsisp.com\/helps\/106727.html","name":"Linux \u670d\u52a1\u5668 \/tmp \u76ee\u5f55\uff1a\u4f7f\u7528\u673a\u5236\u4e0e\u5b89\u5168\u52a0\u56fa - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-09-17T23:48:51+00:00","dateModified":"2026-09-17T23:48:51+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/106727.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/106727.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/106727.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Linux \u670d\u52a1\u5668 \/tmp \u76ee\u5f55\uff1a\u4f7f\u7528\u673a\u5236\u4e0e\u5b89\u5168\u52a0\u56fa"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/106727","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=106727"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/106727\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=106727"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=106727"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=106727"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=106727"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}