{"id":392,"date":"2022-01-12T17:50:24","date_gmt":"2022-01-12T09:50:24","guid":{"rendered":"https:\/\/www.buyao007.icu\/?p=392"},"modified":"2022-01-12T21:18:21","modified_gmt":"2022-01-12T13:18:21","slug":"18-linux%e7%b3%bb%e7%bb%9f%e6%9c%8d%e5%8a%a1%e7%ae%a1%e7%90%86","status":"publish","type":"post","link":"https:\/\/www.buyao007.icu\/?p=392","title":{"rendered":"18.Linux\u7cfb\u7edf\u670d\u52a1\u7ba1\u7406"},"content":{"rendered":"\n<p class=\"has-normal-font-size\">\u5b59\u5bcc\u9633\uff0c \u6c5f\u6e56\u4eba\u79f0\u6ca1\u4eba\u79f0\u3002\u591a\u5e74\u4e92\u8054\u7f51\u8fd0\u7ef4\u5de5\u4f5c\u7ecf\u9a8c\uff0c\u66fe\u8d1f\u8d23\u8fc7\u5b59\u5e03\u65af\u5927\u89c4\u6a21\u96c6\u7fa4\u67b6\u6784\u81ea\u52a8\u5316\u8fd0\u7ef4\u7ba1\u7406\u5de5\u4f5c\u3002\u64c5\u957fWeb\u96c6\u7fa4\u67b6\u6784\u4e0e\u81ea\u52a8\u5316\u8fd0\u7ef4\uff0c\u66fe\u8d1f\u8d23\u56fd\u5185\u67d0\u5927\u578b\u535a\u5ba2\u7f51\u7ad9\u8fd0\u7ef4\u5de5\u4f5c\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"toc_0\">1.Linux\u542f\u52a8\u6d41\u7a0b<\/h2>\n\n\n\n<ul><li>BIOS\u81ea\u68c0\u3002<\/li><li>MBR\u5f15\u5bfc\u3002<\/li><li>\u5185\u6838\u7684\u5f15\u5bfc\u3002<\/li><li>\u8fd0\u884c init\u3002<\/li><li>\u7cfb\u7edf\u521d\u59cb\u5316\u3002<\/li><li>\u5efa\u7acb\u7ec8\u7aef \u3002<\/li><li>\u7528\u6237\u767b\u5f55\u7cfb\u7edf\u3002<\/li><\/ul>\n\n\n\n<p><strong>init\u7a0b\u5e8f\u7684\u7c7b\u578b\uff1a<\/strong><\/p>\n\n\n\n<ul><li><strong>SysV:<\/strong>&nbsp;init, CentOS 5\u4e4b\u524d, \u914d\u7f6e\u6587\u4ef6\uff1a \/etc\/inittab\u3002<\/li><li><strong>Upstart:<\/strong>&nbsp;init,CentOS 6, \u914d\u7f6e\u6587\u4ef6\uff1a \/etc\/inittab, \/etc\/init\/*.conf\u3002<\/li><li><strong>Systemd\uff1a<\/strong>&nbsp;systemd, CentOS 7,\u914d\u7f6e\u6587\u4ef6\uff1a \/usr\/lib\/systemd\/system\u3001 \/etc\/systemd\/system\u3002<\/li><\/ul>\n\n\n\n<p>PS:CentOS 6\u662f\u4e32\u884c\u542f\u52a8\uff0c7\u662f\u5e76\u884c\u542f\u52a8\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"toc_1\">2.Linux\u8fd0\u884c\u7ea7\u522b<\/h2>\n\n\n\n<p><em>1.\u4ec0\u4e48\u662f\u8fd0\u884c\u7ea7\u522b\uff0c\u8fd0\u884c\u7ea7\u522b\u5c31\u662f\u64cd\u4f5c\u7cfb\u7edf\u5f53\u524d\u6b63\u5728\u8fd0\u884c\u7684\u529f\u80fd\u7ea7\u522b<\/em><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>System V init\u8fd0\u884c\u7ea7\u522b<\/th><th>systemd\u76ee\u6807\u540d\u79f0<\/th><th>\u4f5c\u7528<\/th><\/tr><\/thead><tbody><tr><td>0<\/td><td>runlevel0.target, poweroff.target<\/td><td>\u5173\u673a<\/td><\/tr><tr><td>1<\/td><td>runlevel1.target, rescue.target<\/td><td>\u5355\u7528\u6237\u6a21\u5f0f<\/td><\/tr><tr><td>2<\/td><td>runlevel2.target, multi-user.target<\/td><td><\/td><\/tr><tr><td>3<\/td><td>runlevel3.target, multi-user.target<\/td><td>\u591a\u7528\u6237\u7684\u6587\u672c\u754c\u9762<\/td><\/tr><tr><td>4<\/td><td>runlevel4.target, multi-user.target<\/td><td><\/td><\/tr><tr><td>5<\/td><td>runlevel5.target, graphical.target<\/td><td>\u591a\u7528\u6237\u7684\u56fe\u5f62\u754c\u9762<\/td><\/tr><tr><td>6<\/td><td>runlevel6.target, reboot.target<\/td><td>\u91cd\u542f<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p><em>2.\u5982\u4f55\u8c03\u6574\u7cfb\u7edf\u542f\u52a8\u7684\u8fd0\u884c\u7ea7\u522b\uff1fsystemd\u4f7f\u7528'targets'\u800c\u4e0d\u662frunlevels\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u6709\u4e24\u4e2a\u4e3b\u8981\u76ee\u6807:<br>multi-user.target\uff1a\u7c7b\u4f3c\u4e8e\u8fd0\u884c\u7ea7\u522b3<br>graphical.target\uff1a \u7c7b\u4f3c\u4e8e\u8fd0\u884c\u7ea7\u522b5<\/em><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#1.\u67e5\u770b\u7cfb\u7edf\u9ed8\u8ba4\u8fd0\u884c\u7ea7\u522b\n&#91;root@student ~]# systemctl get-default\n\n#2.\u8981\u8bbe\u7f6e\u9ed8\u8ba4\u76ee\u6807\uff0c\u8bf7\u8fd0\u884c\n&#91;root@student ~]# systemctl set-default TARGET.target\n\nPS\uff1a\u6ca1\u4e8b\u522b\u4fee\u6539\u8fd0\u884c\u7ea7\u522b\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"toc_2\">3.Linux systemd<\/h2>\n\n\n\n<p><strong><em>1.systemd\u7684\u7531\u6765<\/em><\/strong><br><em>Linux\u4e00\u76f4\u4ee5\u6765\u90fd\u662f\u91c7\u7528init\u8fdb\u7a0b\u4f5c\u4e3a\u7687\u5e1d\u8fdb\u7a0b\uff0c\u4f46\u662finit\u6709\u4e24\u4e2a\u7f3a\u70b9\uff1a<br>1\u3001\u542f\u52a8\u65f6\u95f4\u957f\u3002Init\u8fdb\u7a0b\u662f\u4e32\u884c\u542f\u52a8\uff0c\u53ea\u6709\u524d\u4e00\u4e2a\u8fdb\u7a0b\u542f\u52a8\u5b8c\uff0c\u624d\u4f1a\u542f\u52a8\u4e0b\u4e00\u4e2a\u8fdb\u7a0b\u3002<br>2\u3001\u542f\u52a8\u811a\u672c\u590d\u6742\uff0c\u521d\u59cb\u5316\u5b8c\u6210\u540e\u7cfb\u7edf\u4f1a\u52a0\u8f7d\u5f88\u591a\u811a\u672c\uff0c\u811a\u672c\u90fd\u4f1a\u5904\u7406\u5404\u81ea\u7684\u60c5\u51b5\uff0c\u8fd9\u4f1a\u8ba9\u811a\u672c\u591a\u800c\u590d\u6742\u3002<br>Centos5 \u662f\u542f\u52a8\u901f\u5ea6\u6700\u6162\u7684\uff0c\u4e32\u884c\u542f\u52a8\u8fc7\u7a0b\uff0c\u65e0\u8bba\u8fdb\u7a0b\u76f8\u4e92\u4e4b\u95f4\u6709\u65e0\u4f9d\u8d56\u5173\u7cfb\u3002<br>Centos6 \u76f8\u5bf9\u542f\u52a8\u901f\u5ea6\u6709\u6240\u6539\u8fdb\u3002\u6709\u4f9d\u8d56\u7684\u8fdb\u7a0b\u4e4b\u95f4\u4f9d\u6b21\u542f\u52a8\u800c\u5176\u4ed6\u4e0e\u4e4b\u6ca1\u6709\u4f9d\u8d56\u5173\u7cfb\u7684\u5219\u5e76\u884c\u540c\u6b65\u542f\u52a8\u3002<br>Centos7 \u6240\u6709\u8fdb\u7a0b\u65e0\u8bba\u6709\u65e0\u4f9d\u8d56\u5173\u7cfb\u5219\u90fd\u662f\u5e76\u884c\u542f\u52a8\uff08\u5f53\u7136\u5f88\u591a\u65f6\u5019\u8fdb\u7a0b\u6ca1\u6709\u771f\u6b63\u542f\u52a8\u800c\u662f\u53ea\u6709\u4e00\u4e2a\u4fe1\u53f7\u6216\u8005\u8bf4\u662f\u6807\u8bb0\u800c\u5df2\uff0c\u5728\u771f\u6b63\u5229\u7528\u7684\u65f6\u5019\u624d\u4f1a\u771f\u6b63\u542f\u52a8\u3002\uff09<\/em><\/p>\n\n\n\n<p><strong><em>2.\u4ec0\u4e48\u662fsystemd<\/em><\/strong><br><em>systemd\u5373\u4e3asystem daemon\u5b88\u62a4\u8fdb\u7a0b\uff0csystemd\u4e3b\u8981\u89e3\u51b3\u4e0a\u6587\u7684\u95ee\u9898\u800c\u8bde\u751f\uff0csystemd\u7684\u76ee\u6807\u662f\uff0c\u4e3a\u7cfb\u7edf\u7684\u542f\u52a8\u548c\u7ba1\u7406\u63d0\u4f9b\u4e00\u5957\u5b8c\u6574\u7684\u89e3\u51b3\u65b9\u6848\u3002<\/em><\/p>\n\n\n\n<p><strong><em>3.systemd\u7684\u4f18\u52bf<\/em><\/strong><br><em>1\u3001\u6700\u65b0\u7cfb\u7edf\u90fd\u91c7\u7528systemd\u7ba1\u7406\uff08RedHat7,CentOS7,Ubuntu15\u7b49\uff09<br>2\u3001Centos7\u652f\u6301\u5f00\u673a\u5e76\u884c\u542f\u52a8\u670d\u52a1\uff0c\u663e\u8457\u63d0\u9ad8\u5f00\u673a\u542f\u52a8\u6548\u7387\u3002<br>3\u3001Centos7\u5173\u673a\u53ea\u5173\u95ed\u6b63\u5728\u8fd0\u884c\u7684\u670d\u52a1\uff0c\u800cCentos6\u5168\u90e8\u90fd\u5173\u95ed\u4e00\u6b21\u3002<br>4\u3001Centos7\u670d\u52a1\u7684\u542f\u52a8\u4e0e\u505c\u6b62\u4e0d\u5728\u4f7f\u7528\u811a\u672c\u8fdb\u884c\u7ba1\u7406\uff0c\u4e5f\u5c31\u662f\/etc\/init.d\u4e0b\u4e0d\u5728\u6709\u811a\u672c\u3002<br>5\u3001Centos7\u4f7f\u7528systemd\u89e3\u51b3\u539f\u6709\u6a21\u5f0f\u7f3a\u9677\uff0c\u6bd4\u5982\u539f\u6709service\u4e0d\u4f1a\u5173\u95ed\u7a0b\u5e8f\u4ea7\u751f\u7684\u5b50\u8fdb\u7a0b\u3002<\/em><\/p>\n\n\n\n<p><strong><em>3.systemd\u76f8\u5173\u914d\u7f6e\u6587\u4ef6<\/em><\/strong><br><em>\/usr\/lib\/systemd\/system\/ #\u7c7b\u4f3cCentos6\u7cfb\u7edf\u7684\u542f\u52a8\u811a\u672c\uff0c\/etc\/init.d\/<br>\/etc\/systemd\/system\/ #\u7c7b\u4f3cCentos6\u7cfb\u7edf\u7684\/etc\/rc.d\/rcN.d\/<br>\/etc\/systemd\/system\/multi-user.target.wants\/<\/em><\/p>\n\n\n\n<p><strong><em>4.systemd\u7ba1\u7406\u670d\u52a1\u76f8\u5173\u547d\u4ee4<\/em><\/strong><br><em>systemctl\u7ba1\u7406\u670d\u52a1\u7684\u542f\u52a8\u3001\u91cd\u542f\u3001\u505c\u6b62\u3001\u91cd\u8f7d\u3001\u67e5\u770b\u72b6\u6001\u7b49\u5e38\u7528\u547d\u4ee4<\/em><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>systemctl\u547d\u4ee4<\/th><th>\u4f5c\u7528<\/th><\/tr><\/thead><tbody><tr><td>systemctl start crond.service<\/td><td>\u542f\u52a8\u670d\u52a1<\/td><\/tr><tr><td>systemctl stop crond.service<\/td><td>\u505c\u6b62\u670d\u52a1<\/td><\/tr><tr><td>systemctl restart crond.service<\/td><td>\u91cd\u542f\u670d\u52a1<\/td><\/tr><tr><td>systemctl reload crond.service<\/td><td>\u91cd\u65b0\u52a0\u8f7d\u914d\u7f6e<\/td><\/tr><tr><td>systemctl status crond.servre<\/td><td>\u67e5\u770b\u670d\u52a1\u8fd0\u884c\u72b6\u6001<\/td><\/tr><tr><td>systemctl is-active sshd.service<\/td><td>\u67e5\u770b\u670d\u52a1\u662f\u5426\u5728\u8fd0\u884c\u4e2d<\/td><\/tr><tr><td>systemctl mask crond.servre<\/td><td>\u7981\u6b62\u670d\u52a1\u8fd0\u884c<\/td><\/tr><tr><td>systemctl unmask crond.servre<\/td><td>\u53d6\u6d88\u7981\u6b62\u670d\u52a1\u8fd0\u884c<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p><em>\u5f53\u6211\u4eec\u4f7f\u7528systemctl\u542f\u52a8\u4e00\u4e2a\u5b88\u62a4\u8fdb\u7a0b\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7sysytemctl status\u67e5\u770b\u6b64\u5b88\u62a4\u8fdb\u7a0b\u7684\u72b6\u6001<\/em><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>\u72b6\u6001<\/th><th>\u63cf\u8ff0<\/th><\/tr><\/thead><tbody><tr><td>loaded<\/td><td>\u670d\u52a1\u5355\u5143\u7684\u914d\u7f6e\u6587\u4ef6\u5df2\u7ecf\u88ab\u5904\u7406<\/td><\/tr><tr><td>active(running)<\/td><td>\u670d\u52a1\u6301\u7eed\u8fd0\u884c<\/td><\/tr><tr><td>active(exited)<\/td><td>\u670d\u52a1\u6210\u529f\u5b8c\u6210\u4e00\u6b21\u7684\u914d\u7f6e<\/td><\/tr><tr><td>active(waiting)<\/td><td>\u670d\u52a1\u5df2\u7ecf\u8fd0\u884c\u4f46\u5728\u7b49\u5f85\u67d0\u4e2a\u4e8b\u4ef6<\/td><\/tr><tr><td>inactive<\/td><td>\u670d\u52a1\u6ca1\u6709\u5728\u8fd0\u884c<\/td><\/tr><tr><td>enabled<\/td><td>\u670d\u52a1\u8bbe\u5b9a\u4e3a\u5f00\u673a\u8fd0\u884c<\/td><\/tr><tr><td>disabled<\/td><td>\u670d\u52a1\u8bbe\u5b9a\u4e3a\u5f00\u673a\u4e0d\u8fd0\u884c<\/td><\/tr><tr><td>static<\/td><td>\u670d\u52a1\u5f00\u673a\u4e0d\u542f\u52a8\uff0c\u4f46\u53ef\u4ee5\u88ab\u5176\u4ed6\u670d\u52a1\u8c03\u7528\u542f\u52a8<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p><em>systemctl \u8bbe\u7f6e\u670d\u52a1\u5f00\u673a\u542f\u52a8\u3001\u4e0d\u542f\u52a8\u3001\u67e5\u770b\u5404\u7ea7\u522b\u4e0b\u670d\u52a1\u542f\u52a8\u72b6\u6001\u7b49\u5e38\u7528\u547d\u4ee4<\/em><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>systemctl\u547d\u4ee4\uff087\u7cfb\u7edf\uff09<\/th><th>\u4f5c\u7528<\/th><\/tr><\/thead><tbody><tr><td>systemctl enable crond.service<\/td><td>\u5f00\u673a\u81ea\u52a8\u542f\u52a8<\/td><\/tr><tr><td>systemctl disable crond.service<\/td><td>\u5f00\u673a\u4e0d\u81ea\u52a8\u542f\u52a8<\/td><\/tr><tr><td>systemctl list-unit-files<\/td><td>\u67e5\u770b\u5404\u4e2a\u7ea7\u522b\u4e0b\u670d\u52a1\u7684\u542f\u52a8\u4e0e\u7981\u7528<\/td><\/tr><tr><td>systemctl is-enabled crond.service<\/td><td>\u67e5\u770b\u7279\u5b9a\u670d\u52a1\u662f\u5426\u4e3a\u5f00\u673a\u81ea\u542f\u52a8<\/td><\/tr><tr><td>systemctl daemon-reload<\/td><td>\u521b\u5efa\u65b0\u670d\u52a1\u6587\u4ef6\u9700\u8981\u91cd\u8f7d\u53d8\u66f4<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p><em>CentOS7\u7cfb\u7edf, \u7ba1\u7406\u5458\u53ef\u4ee5\u4f7f\u7528 systemctl \u547d\u4ee4\u6765\u7ba1\u7406\u670d\u52a1\u5668\u542f\u52a8\u4e0e\u505c\u6b62<\/em><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#\u5173\u673a\u76f8\u5173\u547d\u4ee4\nsystemctl poweroff      #\u7acb\u5373\u5173\u673a\uff0c\u5e38\u7528\n#\u91cd\u542f\u76f8\u5173\u547d\u4ee4\nsystemctl reboot        #\u91cd\u542f\u547d\u4ee4\uff0c\u5e38\u7528\n<\/code><\/pre>\n\n\n\n<p><em>systemctl\u7684journalctl\u65e5\u5fd7<\/em><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>journalctl -n 20    #\u67e5\u770b\u6700\u540e20\u884c\njournalctl -f       #\u52a8\u6001\u67e5\u770b\u65e5\u5fd7\njournalctl -p err   #\u67e5\u770b\u65e5\u5fd7\u7684\u7ea7\u522b\njournalctl -u crond #\u67e5\u770b\u67d0\u4e2a\u670d\u52a1\u7684\u5355\u5143\u7684\u65e5\u5fd7\n\nPS\uff1a\u76f8\u5f53\u4e8etail -f \/var\/log\/message\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"toc_3\">4.Linux\u5355\u7528\u6237\u6a21\u5f0f<\/h2>\n\n\n\n<p><strong><em>\u5982\u4f55\u4f7f\u7528\u5355\u7528\u6237\u6a21\u5f0f\u8fdb\u884c\u53d8\u66f4\u7cfb\u7edf\u5bc6\u7801\uff1f\u4ee5Centos7\u7cfb\u7edf\u4e3a\u4f8b\uff1a(Centos6\u7834\u89e3\u65b9\u5f0f\u8bf7\u81ea\u884c\u767e\u5ea6)<\/em><\/strong><\/p>\n\n\n\n<p>\u7b2c1\u6b65\uff1a\u91cd\u542fLinux\u7cfb\u7edf\u4e3b\u673a\u5e76\u51fa\u73b0\u5f15\u5bfc\u754c\u9762\u65f6\uff0c\u6309\u4e0b\u952e\u76d8\u4e0a\u7684e\u952e\u8fdb\u5165\u5185\u6838\u7f16\u8f91\u754c\u9762<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"589\" src=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/01\/image-1024x589.png\" alt=\"\" class=\"wp-image-400\" srcset=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/01\/image-1024x589.png 1024w, https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/01\/image-300x172.png 300w, https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/01\/image-768x442.png 768w, https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/01\/image-1536x883.png 1536w, https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/01\/image.png 1562w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>\u7b2c2\u6b65\uff1a\u5728linux16\u8fd9\u884c\u7684\u540e\u9762\u6dfb\u52a0enforcing=0 init=\/bin\/bash\uff0c\u7136\u540e\u6309\u4e0bCtrl + X\u7ec4\u5408\u952e\u6765\u8fd0\u884c\u4fee\u6539\u8fc7\u7684\u5185\u6838\u7a0b\u5e8f<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"834\" height=\"381\" src=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/01\/image-1.png\" alt=\"\" class=\"wp-image-401\" srcset=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/01\/image-1.png 834w, https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/01\/image-1-300x137.png 300w, https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/01\/image-1-768x351.png 768w\" sizes=\"(max-width: 834px) 100vw, 834px\" \/><\/figure>\n\n\n\n<p><br>\u7b2c3\u6b65\uff1a\u5927\u7ea65\u79d2\u8fc7\u540e\uff0c\u8fdb\u5165\u5230\u7cfb\u7edf\u7684\u5355\u7528\u6237\u6a21\u5f0f\uff0c\u4f9d\u6b21\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff0c\u7b49\u5f85\u7cfb\u7edf\u91cd\u542f\u64cd\u4f5c\u5b8c\u6bd5\uff0c\u7136\u540e\u5c31\u53ef\u4ee5\u4f7f\u7528\u65b0\u5bc6\u7801\u6765\u767b\u5f55Linux\u7cfb\u7edf\u4e86\u3002\u547d\u4ee4\u884c\u6267\u884c\u6548\u679c\u5982\u56fe\u6240\u793a\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"728\" height=\"192\" src=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/01\/image-2.png\" alt=\"\" class=\"wp-image-402\" srcset=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/01\/image-2.png 728w, https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/01\/image-2-300x79.png 300w\" sizes=\"(max-width: 728px) 100vw, 728px\" \/><figcaption>\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u662f\u53ea\u8bfb\u7684\uff0c\u4f7f\u7528mount -o rw,remount\u91cd\u65b0\u6302\u8f7d\u4e3a\u8bfb\u5199<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"toc_4\">5.Linux\u4e0b\u6551\u63f4\u6a21\u5f0f<\/h2>\n\n\n\n<p><strong><em>\u573a\u666f\u4e00\uff1a\u5f53\u7cfb\u7edf\u574f\u4e86\uff0c\u65e0\u6cd5\u767b\u9646\u7cfb\u7edf\uff0c\u4f46\u9700\u8981\u628a\u91cc\u9762\u7684\u6570\u636e\u590d\u5236\u51fa\u6765\uff0c\u600e\u4e48\u529e\uff1f<\/em><\/strong><\/p>\n\n\n\n<p><em>\u6b65\u9aa4\u4e00\u3001\u5148\u6302\u8f7d\u5149\u76d8\uff0c\u7136\u540e\u9009\u62e9\u5149\u76d8\u5f15\u5bfc\u4e3a\u7b2c\u4e00\u4f4d<\/em><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"638\" height=\"364\" src=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/01\/image-3.png\" alt=\"\" class=\"wp-image-404\" srcset=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/01\/image-3.png 638w, https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/01\/image-3-300x171.png 300w\" sizes=\"(max-width: 638px) 100vw, 638px\" \/><figcaption>###\u52a0\u8f7d\u8fdb\u5ea6\u6761\u7684\u65f6\u5019\u5feb\u901f\u6309\u4f4fesc\u952e\uff0c\u7136\u540e\u6309\u4e0a\u4e0b\u952e\u9009\u62e9\u5149\u76d8\u8bbe\u5907<\/figcaption><\/figure>\n\n\n\n<p><em>\u6b65\u9aa4\u4e8c\u3001\u8fdb\u5165\u6545\u969c\u6392\u9664\u6a21\u5f0f-->\u7136\u540e\u9009\u62e9\u6551\u63f4\u6a21\u5f0f<\/em><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"640\" height=\"480\" src=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/01\/image-4.png\" alt=\"\" class=\"wp-image-406\" srcset=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/01\/image-4.png 640w, https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/01\/image-4-300x225.png 300w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"640\" height=\"480\" src=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/01\/image-5.png\" alt=\"\" class=\"wp-image-407\" srcset=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/01\/image-5.png 640w, https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/01\/image-5-300x225.png 300w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/figure>\n\n\n\n<p><em>\u6b65\u9aa4\u4e09\u3001\u6302\u8f7d\u771f\u5b9e\u7cfb\u7edf\u540e\uff0c\u53d1\u73b0\u6570\u636e\u90fd\u8fd8\u5b58\u5728<\/em><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"879\" height=\"619\" src=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/01\/image-6.png\" alt=\"\" class=\"wp-image-408\" srcset=\"https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/01\/image-6.png 879w, https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/01\/image-6-300x211.png 300w, https:\/\/www.buyao007.icu\/wp-content\/uploads\/2022\/01\/image-6-768x541.png 768w\" sizes=\"(max-width: 879px) 100vw, 879px\" \/><\/figure>\n\n\n\n<p><strong><em>\u573a\u666f\u4e8c\u3001\u4fee\u590dMBR\uff0c\u4e3b\u8981\u51fa\u73b0\u5728\u5b89\u88c5\u53cc\u7cfb\u7edf\u65f6\uff0c\u540e\u5b89\u88c5\u7684\u7cfb\u7edf\u628a\u539f\u6765\u7cfb\u7edf\u7684MBR\u5220\u9664\u4e86\uff0c\u9700\u8981\u4fee\u590d\u3002<\/em><\/strong><\/p>\n\n\n\n<p><em>\u6b65\u9aa4\u4e00\u3001\u7834\u574f\u786c\u76d8\u7684\u524d446\u5b57\u8282\uff0c\u6a21\u62dfMBR\u5f15\u53f7\u635f\u574f\uff0c\u4f1a\u53d1\u73b0\u91cd\u542f\u65e0\u6cd5\u542f\u52a8\u7cfb\u7edf<\/em><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@m01 ~]# dd if=\/dev\/zero of=\/dev\/sda bs=1 count=446\n<\/code><\/pre>\n\n\n\n<p><br><em>\u6b65\u9aa4\u4e8c\u3001\u91cd\u542f\u7cfb\u7edf\uff0c\u7136\u540e\u6309\u7167\u4e4b\u524d\u7684\u64cd\u4f5c\u8fdb\u5165\u6551\u63f4\u6a21\u5f0f\uff0c\u7136\u540e\u5206\u914d\u4e00\u4e2ashell\u7ec8\u7aef\uff0c\u6302\u8f7d\u771f\u5b9e\u7684\u64cd\u4f5c\u7cfb\u7edf\u8fdb\u884c\u4fee\u590d<\/em><br><em>\u6b65\u9aa4\u4e09\u3001\u4fee\u590dMBR\u5f15\u5bfc\uff0c\u7136\u540e\u91cd\u542f\u8fde\u63a5\u670d\u52a1\u5668<\/em><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#1.\u4f7f\u7528grub\u4fee\u590d\n# grub2-install \/dev\/sda\n\n#2.\u7136\u540e\u9000\u51fa\n# exit\n\n#3.\u6700\u540e\u91cd\u542f\u8fdb\u5165\u7cfb\u7edf\n# reboot\n<\/code><\/pre>\n\n\n\n<p><strong><em>\u573a\u666f\u4e09\u3001Centos7\u8bef\u5220\u9664grub\u6587\u4ef6\u5982\u4f55\u8fdb\u884c\u4fee\u590d\u3002<\/em><\/strong><br><em>\u6b65\u9aa4\u4e00\u3001\u6a21\u62df\u8bef\u5220\u6545\u969c<\/em><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#1.\u5220\u9664grub2 \n&#91;root@m01 ~]# rm -rf  \/boot\/grub2 \n#2.\u91cd\u542f\u8ba1\u7b97\u673a \n&#91;root@m01 ~]# reboot <\/code><\/pre>\n\n\n\n<p><em>\u6b65\u9aa4\u4e8c\u3001\u91cd\u542f\u7cfb\u7edf\uff0c\u7136\u540e\u6309\u7167\u4e4b\u524d\u7684\u64cd\u4f5c\u8fdb\u5165\u6551\u63f4\u6a21\u5f0f\uff0c\u7136\u540e\u5206\u914d\u4e00\u4e2ashell\u7ec8\u7aef\uff0c\u6302\u8f7d\u771f\u5b9e\u7684\u64cd\u4f5c\u7cfb\u7edf\u8fdb\u884c\u4fee\u590d<\/em><br><em>\u6b65\u9aa4\u4e09\u3001\u4f7f\u7528grub2-install\u3001grub2-mkconfig\u6062\u590d\u914d\u7f6e\u6587\u4ef6<\/em><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#1.\u4f7f\u7528grub\u4fee\u590d\n# grub2-install \/dev\/sda\n\n#2.\u7136\u540e\u6062\u590dgrub\u7684\u914d\u7f6e\u6587\u4ef6\ngrub2-mkconfig -o \/boot\/grub2\/grub.cfg\n\n#3.\u7136\u540e\u9000\u51fa\n# exit\n\n#4.\u6700\u540e\u91cd\u542f\u8fdb\u5165\u7cfb\u7edf\n# reboot<\/code><\/pre>\n\n\n\n<p><strong><em>PS: \u6700\u540e\u522b\u5fd8\u8bb0\u4fee\u6539 BIOS \u5f15\u5bfc\uff0c\u8ba9\u786c\u76d8\u56de\u5f52\u5230\u7b2c\u4e00\u5f15\u5bfc<\/em><\/strong><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b59\u5bcc\u9633\uff0c \u6c5f\u6e56\u4eba\u79f0\u6ca1\u4eba\u79f0\u3002\u591a\u5e74\u4e92\u8054\u7f51\u8fd0\u7ef4\u5de5\u4f5c\u7ecf\u9a8c\uff0c\u66fe\u8d1f\u8d23\u8fc7\u5b59\u5e03\u65af\u5927\u89c4\u6a21\u96c6\u7fa4\u67b6\u6784\u81ea\u52a8\u5316\u8fd0\u7ef4\u7ba1\u7406\u5de5\u4f5c\u3002\u64c5\u957fWeb\u96c6 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":246,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"_links":{"self":[{"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=\/wp\/v2\/posts\/392"}],"collection":[{"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=392"}],"version-history":[{"count":7,"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=\/wp\/v2\/posts\/392\/revisions"}],"predecessor-version":[{"id":411,"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=\/wp\/v2\/posts\/392\/revisions\/411"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=\/wp\/v2\/media\/246"}],"wp:attachment":[{"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=392"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=392"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.buyao007.icu\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=392"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}