{"id":44138,"date":"2024-10-06T13:10:13","date_gmt":"2024-10-06T05:10:13","guid":{"rendered":"https:\/\/server.hk\/cnblog\/44138\/"},"modified":"2024-10-06T13:10:13","modified_gmt":"2024-10-06T05:10:13","slug":"centos-%e7%b3%bb%e7%b5%b1%e5%95%9f%e5%8b%95%e6%b5%81%e7%a8%8b%e7%b0%a1%e5%96%ae%e4%bb%8b%e7%b4%b9","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/44138\/","title":{"rendered":"CentOS \u7cfb\u7d71\u555f\u52d5\u6d41\u7a0b\u7c21\u55ae\u4ecb\u7d39"},"content":{"rendered":"<h1 id=\"centos-%e7%b3%bb%e7%b5%b1%e5%95%9f%e5%8b%95%e6%b5%81%e7%a8%8b%e7%b0%a1%e5%96%ae%e4%bb%8b%e7%b4%b9-SbyqgasHgL\">CentOS \u7cfb\u7d71\u555f\u52d5\u6d41\u7a0b\u7c21\u55ae\u4ecb\u7d39<\/h1>\n<p>CentOS\uff08Community ENTerprise Operating System\uff09\u662f\u4e00\u500b\u57fa\u65bcRed Hat Enterprise Linux\uff08RHEL\uff09\u7684\u958b\u6e90\u64cd\u4f5c\u7cfb\u7d71\uff0c\u5ee3\u6cdb\u61c9\u7528\u65bc\u4f3a\u670d\u5668\u74b0\u5883\u4e2d\u3002\u4e86\u89e3CentOS\u7684\u555f\u52d5\u6d41\u7a0b\u5c0d\u65bc\u7cfb\u7d71\u7ba1\u7406\u54e1\u548c\u958b\u767c\u8005\u4f86\u8aaa\u81f3\u95dc\u91cd\u8981\uff0c\u56e0\u70ba\u9019\u6709\u52a9\u65bc\u6545\u969c\u6392\u9664\u548c\u7cfb\u7d71\u512a\u5316\u3002\u672c\u6587\u5c07\u7c21\u55ae\u4ecb\u7d39CentOS\u7684\u7cfb\u7d71\u555f\u52d5\u6d41\u7a0b\u3002<\/p>\n<h2 id=\"1-bios-uefi-%e9%9a%8e%e6%ae%b5-SbyqgasHgL\">1. BIOS\/UEFI \u968e\u6bb5<\/h2>\n<p>\u7cfb\u7d71\u555f\u52d5\u7684\u7b2c\u4e00\u6b65\u662fBIOS\uff08\u57fa\u672c\u8f38\u5165\u8f38\u51fa\u7cfb\u7d71\uff09\u6216UEFI\uff08\u7d71\u4e00\u53ef\u64f4\u5c55\u97cc\u9ad4\u4ecb\u9762\uff09\u7684\u555f\u52d5\u3002\u7576\u96fb\u8166\u958b\u6a5f\u6642\uff0cBIOS\/UEFI\u6703\u9032\u884c\u81ea\u6aa2\uff0c\u6aa2\u67e5\u786c\u9ad4\u8a2d\u5099\u7684\u6b63\u5e38\u904b\u4f5c\u3002\u5b8c\u6210\u81ea\u6aa2\u5f8c\uff0cBIOS\/UEFI\u6703\u5c0b\u627e\u555f\u52d5\u8a2d\u5099\uff0c\u901a\u5e38\u662f\u786c\u789f\u3001USB\u6216\u5149\u789f\uff0c\u4e26\u52a0\u8f09\u5176\u555f\u52d5\u6247\u5340\u3002<\/p>\n<h2 id=\"2-mbr-gpt-%e9%9a%8e%e6%ae%b5-SbyqgasHgL\">2. MBR\/GPT \u968e\u6bb5<\/h2>\n<p>\u5728\u627e\u5230\u555f\u52d5\u8a2d\u5099\u5f8c\uff0c\u7cfb\u7d71\u6703\u8b80\u53d6\u4e3b\u5f15\u5c0e\u8a18\u9304\uff08MBR\uff09\u6216GUID\u5206\u5340\u8868\uff08GPT\uff09\u3002\u9019\u4e9b\u8a18\u9304\u5305\u542b\u4e86\u555f\u52d5\u5206\u5340\u7684\u4fe1\u606f\uff0c\u4e26\u6307\u5411\u555f\u52d5\u52a0\u8f09\u5668\u7684\u4f4d\u7f6e\u3002MBR\u7684\u5927\u5c0f\u70ba512\u5b57\u7bc0\uff0c\u800cGPT\u5247\u652f\u6301\u66f4\u5927\u7684\u786c\u789f\u548c\u66f4\u591a\u7684\u5206\u5340\u3002<\/p>\n<h2 id=\"3-%e5%95%9f%e5%8b%95%e5%8a%a0%e8%bc%89%e5%99%a8%ef%bc%88grub%ef%bc%89-SbyqgasHgL\">3. \u555f\u52d5\u52a0\u8f09\u5668\uff08GRUB\uff09<\/h2>\n<p>\u4e00\u65e6\u627e\u5230\u555f\u52d5\u5206\u5340\uff0c\u7cfb\u7d71\u6703\u52a0\u8f09\u555f\u52d5\u52a0\u8f09\u5668\uff0c\u901a\u5e38\u662fGRUB\uff08GRand Unified Bootloader\uff09\u3002GRUB\u7684\u4e3b\u8981\u529f\u80fd\u662f\u63d0\u4f9b\u4e00\u500b\u9078\u55ae\uff0c\u8b93\u7528\u6236\u9078\u64c7\u8981\u555f\u52d5\u7684\u64cd\u4f5c\u7cfb\u7d71\u6216\u5167\u6838\u7248\u672c\u3002GRUB\u6703\u8b80\u53d6\u5176\u914d\u7f6e\u6587\u4ef6\uff08\u901a\u5e38\u4f4d\u65bc\/boot\/grub\/grub.cfg\uff09\uff0c\u4e26\u6839\u64da\u7528\u6236\u7684\u9078\u64c7\u52a0\u8f09\u76f8\u61c9\u7684\u5167\u6838\u3002<\/p>\n<h3 id=\"grub-%e9%85%8d%e7%bd%ae%e7%a4%ba%e4%be%8b-SbyqgasHgL\">GRUB \u914d\u7f6e\u793a\u4f8b<\/h3>\n<pre><code>set default=0\nset timeout=5\n\nmenuentry 'CentOS Linux 7 (3.10.0-1127.el7.x86_64)' {\n    linux \/vmlinuz-3.10.0-1127.el7.x86_64 root=\/dev\/mapper\/centos-root ro\n    initrd \/initramfs-3.10.0-1127.el7.x86_64.img\n}\n<\/code><\/pre>\n<h2 id=\"4-%e5%85%a7%e6%a0%b8%e5%8a%a0%e8%bc%89-SbyqgasHgL\">4. \u5167\u6838\u52a0\u8f09<\/h2>\n<p>\u9078\u64c7\u5167\u6838\u5f8c\uff0cGRUB\u6703\u5c07\u63a7\u5236\u6b0a\u8f49\u4ea4\u7d66\u5167\u6838\u3002\u5167\u6838\u6703\u52a0\u8f09\u5fc5\u8981\u7684\u9a45\u52d5\u7a0b\u5f0f\u548c\u6a21\u7d44\uff0c\u4e26\u521d\u59cb\u5316\u7cfb\u7d71\u786c\u9ad4\u3002\u9019\u4e00\u904e\u7a0b\u4e2d\uff0c\u5167\u6838\u6703\u6aa2\u67e5\u7cfb\u7d71\u7684\u786c\u9ad4\u914d\u7f6e\uff0c\u4e26\u8a2d\u7f6e\u7cfb\u7d71\u7684\u57fa\u672c\u904b\u884c\u74b0\u5883\u3002<\/p>\n<h2 id=\"5-init-%e9%9a%8e%e6%ae%b5-SbyqgasHgL\">5. init \u968e\u6bb5<\/h2>\n<p>\u5167\u6838\u52a0\u8f09\u5b8c\u6210\u5f8c\uff0c\u6703\u555f\u52d5\u7b2c\u4e00\u500b\u7528\u6236\u7a7a\u9593\u9032\u7a0b\uff0c\u5373init\u3002CentOS\u4f7f\u7528systemd\u4f5c\u70ba\u5176\u521d\u59cb\u5316\u7cfb\u7d71\uff0c\u9019\u662f\u4e00\u500b\u7528\u65bc\u555f\u52d5\u548c\u7ba1\u7406\u7cfb\u7d71\u670d\u52d9\u7684\u5de5\u5177\u3002systemd\u6703\u6839\u64da\u5176\u914d\u7f6e\u6587\u4ef6\uff08\u901a\u5e38\u4f4d\u65bc\/etc\/systemd\/system\uff09\u555f\u52d5\u5404\u7a2e\u670d\u52d9\u548c\u5b88\u8b77\u9032\u7a0b\u3002<\/p>\n<h3 id=\"systemd-%e6%9c%8d%e5%8b%99%e7%a4%ba%e4%be%8b-SbyqgasHgL\">systemd \u670d\u52d9\u793a\u4f8b<\/h3>\n<pre><code>[Unit]\nDescription=My Custom Service\n\n[Service]\nExecStart=\/usr\/bin\/my-service\n\n[Install]\nWantedBy=multi-user.target\n<\/code><\/pre>\n<h2 id=\"6-%e7%99%bb%e9%8c%84%e9%9a%8e%e6%ae%b5-SbyqgasHgL\">6. \u767b\u9304\u968e\u6bb5<\/h2>\n<p>\u7576\u6240\u6709\u5fc5\u8981\u7684\u670d\u52d9\u555f\u52d5\u5f8c\uff0c\u7cfb\u7d71\u6703\u986f\u793a\u767b\u9304\u63d0\u793a\uff0c\u5141\u8a31\u7528\u6236\u8f38\u5165\u7528\u6236\u540d\u548c\u5bc6\u78bc\u3002\u6210\u529f\u767b\u9304\u5f8c\uff0c\u7528\u6236\u5c07\u9032\u5165\u5176\u4e3b\u74b0\u5883\uff0c\u4e26\u53ef\u4ee5\u958b\u59cb\u4f7f\u7528\u7cfb\u7d71\u3002<\/p>\n<h2 id=\"%e7%b8%bd%e7%b5%90-SbyqgasHgL\">\u7e3d\u7d50<\/h2>\n<p>\u4e86\u89e3CentOS\u7684\u555f\u52d5\u6d41\u7a0b\u5c0d\u65bc\u7cfb\u7d71\u7ba1\u7406\u548c\u6545\u969c\u6392\u9664\u81f3\u95dc\u91cd\u8981\u3002\u5f9eBIOS\/UEFI\u5230GRUB\uff0c\u518d\u5230\u5167\u6838\u548cinit\u968e\u6bb5\uff0c\u6bcf\u4e00\u6b65\u90fd\u5728\u78ba\u4fdd\u7cfb\u7d71\u7684\u6b63\u5e38\u904b\u884c\u3002\u5c0d\u65bc\u9700\u8981\u7a69\u5b9a\u548c\u9ad8\u6548\u904b\u884c\u7684\u4f3a\u670d\u5668\u74b0\u5883\uff0c\u9078\u64c7\u5408\u9069\u7684\u64cd\u4f5c\u7cfb\u7d71\u548c\u914d\u7f6e\u662f\u975e\u5e38\u91cd\u8981\u7684\u3002\u5982\u679c\u60a8\u6b63\u5728\u5c0b\u627e\u53ef\u9760\u7684 <a href=\"https:\/\/server.hk\">VPS<\/a> \u89e3\u6c7a\u65b9\u6848\uff0cServer.HK \u63d0\u4f9b\u591a\u7a2e\u9078\u64c7\u4ee5\u6eff\u8db3\u60a8\u7684\u9700\u6c42\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e86\u89e3 CentOS \u7cfb\u7d71\u555f\u52d5\u6d41\u7a0b\uff0c\u5305\u62ec BIOS\u3001GRUB\u3001\u5167\u6838\u52a0\u8f09\u53ca\u521d\u59cb\u5316\u904e\u7a0b\uff0c\u52a9\u60a8\u5feb\u901f\u638c\u63e1\u7cfb\u7d71\u555f\u52d5\u7684\u57fa\u672c\u6982\u5ff5\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4924],"tags":[],"class_list":["post-44138","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/44138","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=44138"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/44138\/revisions"}],"predecessor-version":[{"id":44139,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/44138\/revisions\/44139"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=44138"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=44138"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=44138"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}