{"id":45328,"date":"2024-10-06T22:05:17","date_gmt":"2024-10-06T14:05:17","guid":{"rendered":"https:\/\/server.hk\/cnblog\/45328\/"},"modified":"2024-10-06T22:05:17","modified_gmt":"2024-10-06T14:05:17","slug":"%e4%bd%bf%e7%94%a8-pxe-%e5%ae%89%e8%a3%9d-centos-7-2","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/45328\/","title":{"rendered":"\u4f7f\u7528 PXE \u5b89\u88dd CentOS 7.2"},"content":{"rendered":"<h1 id=\"%e4%bd%bf%e7%94%a8-pxe-%e5%ae%89%e8%a3%9d-centos-7-2-QMvAKGrmyl\">\u4f7f\u7528 PXE \u5b89\u88dd CentOS 7.2<\/h1>\n<p>\u5728\u4f3a\u670d\u5668\u7ba1\u7406\u548c\u7cfb\u7d71\u90e8\u7f72\u4e2d\uff0cPXE\uff08Preboot Execution Environment\uff09\u662f\u4e00\u7a2e\u975e\u5e38\u6709\u6548\u7684\u6280\u8853\uff0c\u80fd\u5920\u901a\u904e\u7db2\u7d61\u555f\u52d5\u548c\u5b89\u88dd\u64cd\u4f5c\u7cfb\u7d71\u3002\u672c\u6587\u5c07\u4ecb\u7d39\u5982\u4f55\u4f7f\u7528 PXE \u5b89\u88dd CentOS 7.2\uff0c\u4e26\u63d0\u4f9b\u8a73\u7d30\u7684\u6b65\u9a5f\u548c\u5fc5\u8981\u7684\u914d\u7f6e\u3002<\/p>\n<h2 id=\"%e4%bb%80%e9%ba%bc%e6%98%af-pxe%ef%bc%9f-QMvAKGrmyl\">\u4ec0\u9ebc\u662f PXE\uff1f<\/h2>\n<p>PXE \u662f\u4e00\u7a2e\u7db2\u7d61\u555f\u52d5\u5354\u8b70\uff0c\u5141\u8a31\u8a08\u7b97\u6a5f\u5728\u6c92\u6709\u672c\u5730\u5b58\u5132\u8a2d\u5099\u7684\u60c5\u6cc1\u4e0b\uff0c\u901a\u904e\u7db2\u7d61\u52a0\u8f09\u64cd\u4f5c\u7cfb\u7d71\u3002\u9019\u5c0d\u65bc\u5927\u898f\u6a21\u90e8\u7f72\u548c\u7ba1\u7406\u4f3a\u670d\u5668\u7279\u5225\u6709\u7528\uff0c\u56e0\u70ba\u5b83\u53ef\u4ee5\u7c21\u5316\u5b89\u88dd\u904e\u7a0b\u4e26\u6e1b\u5c11\u4eba\u70ba\u932f\u8aa4\u3002<\/p>\n<h2 id=\"%e6%ba%96%e5%82%99%e5%b7%a5%e4%bd%9c-QMvAKGrmyl\">\u6e96\u5099\u5de5\u4f5c<\/h2>\n<p>\u5728\u958b\u59cb\u4e4b\u524d\uff0c\u60a8\u9700\u8981\u6e96\u5099\u4ee5\u4e0b\u5e7e\u6a23\u6771\u897f\uff1a<\/p>\n<ul>\n<li>\u4e00\u53f0\u904b\u884c CentOS 7.2 \u7684\u4f3a\u670d\u5668\u4f5c\u70ba PXE \u4f3a\u670d\u5668\u3002<\/li>\n<li>\u4e00\u53f0\u9700\u8981\u5b89\u88dd CentOS \u7684\u5ba2\u6236\u7aef\u6a5f\u5668\u3002<\/li>\n<li>\u7db2\u7d61\u9023\u63a5\uff0c\u78ba\u4fdd PXE \u4f3a\u670d\u5668\u548c\u5ba2\u6236\u7aef\u5728\u540c\u4e00\u7db2\u7d61\u4e2d\u3002<\/li>\n<\/ul>\n<h2 id=\"%e6%ad%a5%e9%a9%9f%e4%b8%80%ef%bc%9a%e8%a8%ad%e7%bd%ae-pxe-%e4%bc%ba%e6%9c%8d%e5%99%a8-QMvAKGrmyl\">\u6b65\u9a5f\u4e00\uff1a\u8a2d\u7f6e PXE \u4f3a\u670d\u5668<\/h2>\n<p>\u9996\u5148\uff0c\u60a8\u9700\u8981\u5728 PXE \u4f3a\u670d\u5668\u4e0a\u5b89\u88dd\u5fc5\u8981\u7684\u8edf\u4ef6\u5305\u3002\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88dd DHCP \u548c TFTP \u670d\u52d9\uff1a<\/p>\n<pre><code>sudo yum install dhcp tftp-server syslinux<\/code><\/pre>\n<p>\u63a5\u4e0b\u4f86\uff0c\u60a8\u9700\u8981\u914d\u7f6e DHCP \u4f3a\u670d\u5668\u3002\u7de8\u8f2f \/etc\/dhcp\/dhcpd.conf \u6587\u4ef6\uff0c\u6dfb\u52a0\u4ee5\u4e0b\u5167\u5bb9\uff1a<\/p>\n<pre><code>subnet 192.168.1.0 netmask 255.255.255.0 {\n    range 192.168.1.10 192.168.1.100;\n    option routers 192.168.1.1;\n    option domain-name-servers 192.168.1.1;\n    option broadcast-address 192.168.1.255;\n    option domain-name \"example.com\";\n    filename \"pxelinux.0\";\n}<\/code><\/pre>\n<p>\u78ba\u4fdd\u5c07 IP \u5730\u5740\u548c\u7db2\u7d61\u8a2d\u7f6e\u6839\u64da\u60a8\u7684\u74b0\u5883\u9032\u884c\u8abf\u6574\u3002<\/p>\n<h2 id=\"%e6%ad%a5%e9%a9%9f%e4%ba%8c%ef%bc%9a%e9%85%8d%e7%bd%ae-tftp-%e4%bc%ba%e6%9c%8d%e5%99%a8-QMvAKGrmyl\">\u6b65\u9a5f\u4e8c\uff1a\u914d\u7f6e TFTP \u4f3a\u670d\u5668<\/h2>\n<p>\u63a5\u4e0b\u4f86\uff0c\u60a8\u9700\u8981\u914d\u7f6e TFTP \u4f3a\u670d\u5668\u3002\u7de8\u8f2f \/etc\/xinetd.d\/tftp \u6587\u4ef6\uff0c\u5c07 disable \u8a2d\u7f6e\u70ba no\uff1a<\/p>\n<pre><code>service tftp\n{\n    socket_type     = dgram\n    protocol        = udp\n    wait            = yes\n    user            = root\n    server          = \/usr\/sbin\/in.tftpd\n    server_args     = -s \/var\/lib\/tftpboot\n    disable         = no\n    per_source      = 11\n    cps             = 100 2\n    flags           = IPv4\n}<\/code><\/pre>\n<p>\u7136\u5f8c\uff0c\u91cd\u555f xinetd \u670d\u52d9\uff1a<\/p>\n<pre><code>sudo systemctl restart xinetd<\/code><\/pre>\n<h2 id=\"%e6%ad%a5%e9%a9%9f%e4%b8%89%ef%bc%9a%e6%ba%96%e5%82%99%e5%95%9f%e5%8b%95%e6%96%87%e4%bb%b6-QMvAKGrmyl\">\u6b65\u9a5f\u4e09\uff1a\u6e96\u5099\u555f\u52d5\u6587\u4ef6<\/h2>\n<p>\u5c07 syslinux \u7684\u555f\u52d5\u6587\u4ef6\u8907\u88fd\u5230 TFTP \u6839\u76ee\u9304\uff1a<\/p>\n<pre><code>sudo cp \/usr\/share\/syslinux\/pxelinux.0 \/var\/lib\/tftpboot\/<\/code><\/pre>\n<p>\u63a5\u4e0b\u4f86\uff0c\u5275\u5efa\u4e00\u500b\u76ee\u9304\u4f86\u5b58\u653e\u555f\u52d5\u914d\u7f6e\u6587\u4ef6\uff1a<\/p>\n<pre><code>sudo mkdir \/var\/lib\/tftpboot\/pxelinux.cfg<\/code><\/pre>\n<p>\u5728\u8a72\u76ee\u9304\u4e2d\u5275\u5efa\u4e00\u500b\u540d\u70ba default \u7684\u6587\u4ef6\uff0c\u4e26\u6dfb\u52a0\u4ee5\u4e0b\u5167\u5bb9\uff1a<\/p>\n<pre><code>DEFAULT menu.c32\nPROMPT 0\nTIMEOUT 300\nLABEL linux\n    MENU LABEL Install CentOS 7.2\n    KERNEL centos7\/vmlinuz\n    APPEND initrd=centos7\/initrd.img inst.repo=http:\/\/192.168.1.2\/centos7\n<\/code><\/pre>\n<p>\u78ba\u4fdd\u5c07 KERNEL \u548c APPEND \u884c\u4e2d\u7684\u8def\u5f91\u6839\u64da\u60a8\u7684\u74b0\u5883\u9032\u884c\u8abf\u6574\u3002<\/p>\n<h2 id=\"%e6%ad%a5%e9%a9%9f%e5%9b%9b%ef%bc%9a%e5%ae%89%e8%a3%9d-centos-7-2-QMvAKGrmyl\">\u6b65\u9a5f\u56db\uff1a\u5b89\u88dd CentOS 7.2<\/h2>\n<p>\u73fe\u5728\uff0c\u60a8\u9700\u8981\u5c07 CentOS 7.2 \u7684\u5b89\u88dd\u6587\u4ef6\u653e\u7f6e\u5728 PXE \u4f3a\u670d\u5668\u4e0a\u3002\u60a8\u53ef\u4ee5\u5f9e CentOS \u5b98\u65b9\u7db2\u7ad9\u4e0b\u8f09 ISO \u6587\u4ef6\uff0c\u7136\u5f8c\u5c07\u5176\u639b\u8f09\u5230\u4f3a\u670d\u5668\u4e0a\uff1a<\/p>\n<pre><code>sudo mount -o loop CentOS-7-x86_64-DVD-1611.iso \/mnt<\/code><\/pre>\n<p>\u7136\u5f8c\u5c07\u5b89\u88dd\u6587\u4ef6\u8907\u88fd\u5230 TFTP \u4f3a\u670d\u5668\u7684\u76f8\u61c9\u76ee\u9304\uff1a<\/p>\n<pre><code>sudo cp -r \/mnt\/* \/var\/www\/html\/centos7\/<\/code><\/pre>\n<p>\u6700\u5f8c\uff0c\u91cd\u555f DHCP \u548c TFTP \u670d\u52d9\u4ee5\u61c9\u7528\u66f4\u6539\uff1a<\/p>\n<pre><code>sudo systemctl restart dhcpd\nsudo systemctl restart xinetd<\/code><\/pre>\n<h2 id=\"%e6%ad%a5%e9%a9%9f%e4%ba%94%ef%bc%9a%e5%95%9f%e5%8b%95%e5%ae%a2%e6%88%b6%e7%ab%af-QMvAKGrmyl\">\u6b65\u9a5f\u4e94\uff1a\u555f\u52d5\u5ba2\u6236\u7aef<\/h2>\n<p>\u5728\u5ba2\u6236\u7aef\u6a5f\u5668\u4e0a\uff0c\u9032\u5165 BIOS \u8a2d\u7f6e\uff0c\u5c07\u555f\u52d5\u9806\u5e8f\u8a2d\u7f6e\u70ba\u5f9e\u7db2\u7d61\u555f\u52d5\u3002\u4fdd\u5b58\u8a2d\u7f6e\u4e26\u91cd\u555f\u6a5f\u5668\u3002\u5ba2\u6236\u7aef\u61c9\u8a72\u80fd\u5920\u901a\u904e PXE \u555f\u52d5\u4e26\u958b\u59cb\u5b89\u88dd CentOS 7.2\u3002<\/p>\n<h2 id=\"%e7%b8%bd%e7%b5%90-QMvAKGrmyl\">\u7e3d\u7d50<\/h2>\n<p>\u4f7f\u7528 PXE \u5b89\u88dd CentOS 7.2 \u662f\u4e00\u500b\u9ad8\u6548\u4e14\u9748\u6d3b\u7684\u89e3\u6c7a\u65b9\u6848\uff0c\u7279\u5225\u9069\u5408\u65bc\u5927\u898f\u6a21\u90e8\u7f72\u3002\u901a\u904e\u4e0a\u8ff0\u6b65\u9a5f\uff0c\u60a8\u53ef\u4ee5\u8f15\u9b06\u8a2d\u7f6e PXE \u4f3a\u670d\u5668\u4e26\u5b89\u88dd\u64cd\u4f5c\u7cfb\u7d71\u3002\u5982\u679c\u60a8\u9700\u8981\u66f4\u591a\u6709\u95dc <a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a> \u7684\u8cc7\u8a0a\uff0c\u8acb\u8a2a\u554f\u6211\u5011\u7684\u7db2\u7ad9\u4ee5\u7372\u53d6\u66f4\u591a\u8cc7\u6e90\u548c\u652f\u6301\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4f7f\u7528 PXE \u5b89\u88dd CentOS 7.2\uff0c\u5feb\u901f\u90e8\u7f72\u7cfb\u7d71\uff0c\u7c21\u5316\u5b89\u88dd\u904e\u7a0b\uff0c\u9069\u5408\u5927\u898f\u6a21\u74b0\u5883\u548c\u7121\u9700\u5149\u789f\u7684\u5b89\u88dd\u9700\u6c42\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-45328","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/45328","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=45328"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/45328\/revisions"}],"predecessor-version":[{"id":45329,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/45328\/revisions\/45329"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=45328"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=45328"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=45328"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}