{"id":7060,"date":"2022-06-29T10:23:20","date_gmt":"2022-06-29T02:23:20","guid":{"rendered":"http:\/\/lrxjmw.cn\/?p=7060"},"modified":"2022-06-29T21:10:38","modified_gmt":"2022-06-29T13:10:38","slug":"centos6-pxe-kickstart","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/centos6-pxe-kickstart.html","title":{"rendered":"CentOS6 PXE+Kickstart\u65e0\u4eba\u503c\u5b88\u5b89\u88c5"},"content":{"rendered":"
\u672c\u6587\u7531lrxjmw.cn\u56e2\u961f\u6210\u5458\u9004\u589e\u5b9d<\/span>\u6574\u7406\u53d1\u5e03\uff0c\u539f\u6587\u6765\u81ea\uff1aDavid Camp<\/a>\u3002<\/p>\n<\/div>\n PXE(Pre-boot Execution Environment\uff0c\u9884\u542f\u52a8\u6267\u884c\u73af\u5883)\u662f\u7531Intel\u516c\u53f8\u5f00\u53d1\u7684\u6700\u65b0\u6280\u672f\uff0c\u5de5\u4f5c\u4e8eClient\/Server\u7684\u7f51\u7edc\u6a21\u5f0f\uff0c\u652f\u6301\u5de5\u4f5c\u7ad9\u901a\u8fc7\u7f51\u7edc\u4ece\u8fdc\u7aef\u670d\u52a1\u5668\u4e0b\u8f7d\u6620\u50cf\uff0c\u5e76\u7531\u6b64\u652f\u6301\u901a\u8fc7\u7f51\u7edc\u542f\u52a8\u64cd\u4f5c\u7cfb\u7edf\uff0c\u5728\u542f\u52a8\u8fc7\u7a0b\u4e2d\uff0c\u7ec8\u7aef\u8981\u6c42\u670d\u52a1\u5668\u5206\u914dIP\u5730\u5740\uff0c\u518d\u7528TFTP\u534f\u8bae\u4e0b\u8f7d\u4e00\u4e2a\u542f\u52a8\u8f6f\u4ef6\u5305\u5230\u672c\u673a\u5185\u5b58\u4e2d\u6267\u884c\uff0c\u7531\u8fd9\u4e2a\u542f\u52a8\u8f6f\u4ef6\u5305\u5b8c\u6210\u7ec8\u7aef\u57fa\u672c\u8f6f\u4ef6\u8bbe\u7f6e\uff0c\u4ece\u800c\u5f15\u5bfc\u9884\u5148\u5b89\u88c5\u5728\u670d\u52a1\u5668\u4e2d\u7684\u7ec8\u7aef\u64cd\u4f5c\u7cfb\u7edf\u3002<\/p>\n \u4e25\u683c\u6765\u8bf4\uff0cPXE \u5e76\u4e0d\u662f\u4e00\u79cd\u5b89\u88c5\u65b9\u5f0f\uff0c\u800c\u662f\u4e00\u79cd\u5f15\u5bfc\u65b9\u5f0f\u3002\u8fdb\u884c PXE \u5b89\u88c5\u7684\u5fc5\u8981\u6761\u4ef6\u662f\u5728\u8981\u5b89\u88c5\u7684\u8ba1\u7b97\u673a\u4e2d\u5fc5\u987b\u5305\u542b\u4e00\u4e2a PXE \u652f\u6301\u7684\u7f51\u5361\uff08NIC\uff09\uff0c\u5373\u7f51\u5361\u4e2d\u5fc5\u987b\u8981\u6709 PXE Client\u3002PXE \u534f\u8bae\u53ef\u4ee5\u4f7f\u8ba1\u7b97\u673a\u901a\u8fc7\u7f51\u7edc\u542f\u52a8\u3002\u6b64\u534f\u8bae\u5206\u4e3a Client\u7aef\u548c Server \u7aef\uff0c\u800cPXE Client\u5219\u5728\u7f51\u5361\u7684 ROM \u4e2d\u3002\u5f53\u8ba1\u7b97\u673a\u5f15\u5bfc\u65f6\uff0cBIOS \u628a PXE Client \u8c03\u5165\u5185\u5b58\u4e2d\u6267\u884c\uff0c\u7136\u540e\u7531 PXE Client \u5c06\u653e\u7f6e\u5728\u8fdc\u7aef\u7684\u6587\u4ef6\u901a\u8fc7\u7f51\u7edc\u4e0b\u8f7d\u5230\u672c\u5730\u8fd0\u884c\u3002\u8fd0\u884c PXE \u534f\u8bae\u9700\u8981\u8bbe\u7f6e DHCP \u670d\u52a1\u5668\u548c TFTP \u670d\u52a1\u5668\u3002DHCP \u670d\u52a1\u5668\u4f1a\u7ed9 PXE Client\uff08\u5c06\u8981\u5b89\u88c5\u7cfb\u7edf\u7684\u4e3b\u673a\uff09\u5206\u914d\u4e00\u4e2a IP \u5730\u5740\uff0c\u7531\u4e8e\u662f\u7ed9 PXE Client \u5206\u914d IP \u5730\u5740\uff0c\u6240\u4ee5\u5728\u914d\u7f6e DHCP \u670d\u52a1\u5668\u65f6\u9700\u8981\u589e\u52a0\u76f8\u5e94\u7684 PXE \u8bbe\u7f6e\u3002\u6b64\u5916\uff0c\u5728 PXE Client \u7684 ROM \u4e2d\uff0c\u5df2\u7ecf\u5b58\u5728\u4e86 TFTP Client\uff0c\u90a3\u4e48\u5b83\u5c31\u53ef\u4ee5\u901a\u8fc7 TFTP \u534f\u8bae\u5230 TFTP Server \u4e0a\u4e0b\u8f7d\u6240\u9700\u7684\u6587\u4ef6\u4e86\u3002<\/p>\n PXE\u7684\u5de5\u4f5c\u8fc7\u7a0b\uff1a<\/strong><\/span><\/p>\n 1. PXE Client \u4ece\u81ea\u5df1\u7684PXE\u7f51\u5361\u542f\u52a8\uff0c\u5411\u672c\u7f51\u7edc\u4e2d\u7684DHCP\u670d\u52a1\u5668\u7d22\u53d6IP\uff1b \u8be6\u7ec6\u5de5\u4f5c\u6d41\u7a0b\uff0c\u8bf7\u53c2\u8003\u4e0b\u9762\u8fd9\u5e45\u56fe\uff1a Kickstart\u662f\u4e00\u79cd\u65e0\u4eba\u503c\u5b88\u7684\u5b89\u88c5\u65b9\u5f0f\u3002\u5b83\u7684\u5de5\u4f5c\u539f\u7406\u662f\u5728\u5b89\u88c5\u8fc7\u7a0b\u4e2d\u8bb0\u5f55\u5178\u578b\u7684\u9700\u8981\u4eba\u5de5\u5e72\u9884\u586b\u5199\u7684\u5404\u79cd\u53c2\u6570\uff0c\u5e76\u751f\u6210\u4e00\u4e2a\u540d\u4e3aks.cfg\u7684\u6587\u4ef6\u3002\u5982\u679c\u5728\u5b89\u88c5\u8fc7\u7a0b\u4e2d\uff08\u4e0d\u53ea\u5c40\u9650\u4e8e\u751f\u6210Kickstart\u5b89\u88c5\u6587\u4ef6\u7684\u673a\u5668\uff09\u51fa\u73b0\u8981\u586b\u5199\u53c2\u6570\u7684\u60c5\u51b5\uff0c\u5b89\u88c5\u7a0b\u5e8f\u9996\u5148\u4f1a\u53bb\u67e5\u627eKickstart\u751f\u6210\u7684\u6587\u4ef6\uff0c\u5982\u679c\u627e\u5230\u5408\u9002\u7684\u53c2\u6570\uff0c\u5c31\u91c7\u7528\u6240\u627e\u5230\u7684\u53c2\u6570\uff1b\u5982\u679c\u6ca1\u6709\u627e\u5230\u5408\u9002\u7684\u53c2\u6570\uff0c\u4fbf\u9700\u8981\u5b89\u88c5\u8005\u624b\u5de5\u5e72\u9884\u4e86\u3002\u6240\u4ee5\uff0c\u5982\u679cKickstart\u6587\u4ef6\u6db5\u76d6\u4e86\u5b89\u88c5\u8fc7\u7a0b\u4e2d\u53ef\u80fd\u51fa\u73b0\u7684\u6240\u6709\u9700\u8981\u586b\u5199\u7684\u53c2\u6570\uff0c\u90a3\u4e48\u5b89\u88c5\u8005\u5b8c\u5168\u53ef\u4ee5\u53ea\u544a\u8bc9\u5b89\u88c5\u7a0b\u5e8f\u4ece\u4f55\u5904\u53d6ks.cfg\u6587\u4ef6\uff0c\u7136\u540e\u5c31\u53bb\u5fd9\u81ea\u5df1\u7684\u4e8b\u60c5\u3002\u7b49\u5b89\u88c5\u5b8c\u6bd5\uff0c\u5b89\u88c5\u7a0b\u5e8f\u4f1a\u6839\u636eks.cfg\u4e2d\u7684\u8bbe\u7f6e\u91cd\u542f\u7cfb\u7edf\uff0c\u5e76\u7ed3\u675f\u5b89\u88c5\u3002<\/p>\n PXE+Kickstart \u65e0\u4eba\u503c\u5b88\u5b89\u88c5\u64cd\u4f5c\u7cfb\u7edf\u5b8c\u6574\u8fc7\u7a0b\u5982\u4e0b\uff1a \u5b9e\u9a8c\u73af\u5883\uff1aVMware Workstation 10<\/span><\/p>\n \u7cfb\u7edf\u5e73\u53f0\uff1aCentOS release 6.5 (\u6700\u5c0f\u5316\u5b89\u88c5)<\/span><\/p>\n \u7f51\u7edc\u6a21\u5f0f\uff1aNAT\u6a21\u5f0f\uff08\u5171\u4eab\u4e3b\u673a\u7684IP\u5730\u5740\uff09<\/span><\/p>\n DHCP \/ TFTP IP\uff1a192.168.111.130<\/span><\/p>\n HTTP \/ FTP \/ NFS IP\uff1a192.168.111.130<\/span><\/p>\n \u5173\u95edIptables\u548cSELINUX<\/span><\/p>\n \u751f\u6210ks.cfg \u6587\u4ef6\u9700\u8981system-config-kickstart \u5de5\u5177\uff0c\u800c\u6b64\u5de5\u5177\u4f9d\u8d56\u4e8eX Windows\uff0c\u6240\u4ee5\u6211\u4eec\u9700\u8981\u5b89\u88c5X Windows \u548cDesktop \u5e76\u91cd\u542f\u7cfb\u7edf\uff0c\u64cd\u4f5c\u5982\u4e0b\uff1a<\/strong><\/span><\/p>\n \u5728\u865a\u62df\u673a\u4e2d\u8bbe\u7f6e\u52a0\u8f7dISO\u955c\u50cf\uff1a<\/span> # vi \/etc\/xinetd.d\/tftp<\/span><\/p>\n \u56e0\u4e3atftp\u670d\u52a1\u662f\u6302\u8f7d\u5728\u8d85\u7ea7\u8fdb\u7a0bxinetd \u4e0b\u7684\uff0c\u6240\u4ee5\u901a\u8fc7\u542f\u52a8xinetd \u6765\u542f\u52a8tftp\u670d\u52a1\uff0c\u5e76\u5f00\u673a\u81ea\u542f\u52a8xinetd\uff1a<\/span><\/p>\n \u8bf4\u660e\uff1asyslinux\u662f\u4e00\u4e2a\u529f\u80fd\u5f3a\u5927\u7684\u5f15\u5bfc\u52a0\u8f7d\u7a0b\u5e8f\uff0c\u800c\u4e14\u517c\u5bb9\u5404\u79cd\u4ecb\u8d28\u3002\u66f4\u52a0\u786e\u5207\u5730\u8bf4\uff1aSYSLINUX\u662f\u4e00\u4e2a\u5c0f\u578b\u7684Linux\u64cd\u4f5c\u7cfb\u7edf\uff0c\u5b83\u7684\u76ee\u7684\u662f\u7b80\u5316\u9996\u6b21\u5b89\u88c5Linux\u7684\u65f6\u95f4\uff0c\u5e76\u5efa\u7acb\u4fee\u62a4\u6216\u5176\u5b83\u7279\u6b8a\u7528\u9014\u7684\u542f\u52a8\u76d8\u3002<\/p>\n # vi \/var\/lib\/tftpboot\/pxelinux.cfg\/default<\/p>\n \u542f\u52a8X Windows \u73af\u5883<\/span><\/p>\n \u914d\u7f6eKickstart<\/span><\/p>\n A. \u8bbe\u7f6e\u8bed\u8a00\uff0c\u952e\u76d8\uff0c\u65f6\u533a\uff0cRoot\u5bc6\u7801\uff0c\u5b89\u88c5\u5b8c\u6bd5\u540e\u91cd\u542f\u7b49\u3002<\/span> <\/p>\n C. \u5b89\u88c5MBR<\/span><\/p>\n <\/p>\n D. \u8bbe\u7f6e\u5206\u533a<\/span><\/p>\n <\/p>\n E. \u5206\u533a\u603b\u89c8<\/span><\/p>\n <\/p>\n F. \u914d\u7f6e\u7f51\u7edc<\/span><\/p>\n <\/p>\n G. \u8ba4\u8bc1\u914d\u7f6e<\/span><\/p>\n <\/p>\n H. SELinux \u548c\u9632\u706b\u5899\u914d\u7f6e<\/span><\/p>\n <\/p>\n J. \u8f6f\u4ef6\u5305\u5b89\u88c5\u9009\u62e9<\/span><\/p>\n <\/p>\n K. \u9884\u89c8<\/span><\/p>\n <\/p>\n L. \u751f\u6210ks.cfg \u6587\u4ef6\uff0c\u4fdd\u5b58\u5728\/var\/www\/html\/ \u6587\u4ef6\u5939\u4e0b<\/span><\/p>\n <\/p>\n 1. \u521b\u5efa\u4e00\u53f0\u865a\u62df\u673a<\/span> \u539f\u6587\u6765\u81ea\uff1ahttp:\/\/www.cnblogs.com\/mchina\/p\/3790147.html<\/a><\/p>\n
\n2. DHCP \u670d\u52a1\u5668\u8fd4\u56de\u5206\u914d\u7ed9\u5ba2\u6237\u673a\u7684IP \u4ee5\u53caPXE\u6587\u4ef6\u7684\u653e\u7f6e\u4f4d\u7f6e(\u8be5\u6587\u4ef6\u4e00\u822c\u662f\u653e\u5728\u4e00\u53f0TFTP\u670d\u52a1\u5668\u4e0a) \uff1b
\n3. PXE Client \u5411\u672c\u7f51\u7edc\u4e2d\u7684TFTP\u670d\u52a1\u5668\u7d22\u53d6pxelinux.0 \u6587\u4ef6\uff1b
\n4. PXE Client \u53d6\u5f97pxelinux.0 \u6587\u4ef6\u540e\u4e4b\u6267\u884c\u8be5\u6587\u4ef6\uff1b
\n5. \u6839\u636epxelinux.0 \u7684\u6267\u884c\u7ed3\u679c\uff0c\u901a\u8fc7TFTP\u670d\u52a1\u5668\u52a0\u8f7d\u5185\u6838\u548c\u6587\u4ef6\u7cfb\u7edf \uff1b
\n6. \u8fdb\u5165\u5b89\u88c5\u753b\u9762, \u6b64\u65f6\u53ef\u4ee5\u901a\u8fc7\u9009\u62e9HTTP\u3001FTP\u3001NFS \u65b9\u5f0f\u4e4b\u4e00\u8fdb\u884c\u5b89\u88c5\uff1b<\/p>\n
\n<\/p>\n
\n<\/p>\n# yum groupinstall \"X Window System\"\r\n# yum groupinstall Desktop\r\n# yum groupinstall Fonts\r\n# reboot\r\n<\/pre>\n
# yum install httpd \u2013y\r\n# \/etc\/init.d\/httpd start\r\n# chkconfig --level 35 httpd on\r\n<\/pre>\n
\n
\n\u5c06iso\u6587\u4ef6\u6302\u8f7d\u81f3\/mnt\/cdrom\uff1a<\/span>
\n<\/p>\n# cp -r \/mnt\/cdrom\/ \/var\/www\/html\/\r\n<\/pre>\n
# yum install tftp-server \u2013y\r\n<\/pre>\n
service tftp \r\n{ \r\n socket_type = dgram \r\n protocol = udp \r\n wait = yes \r\n user = root \r\n server = \/usr\/sbin\/in.tftpd \r\n server_args = -s \/var\/lib\/tftpboot \r\n disable = no<\/span> \r\n per_source = 11 \r\n cps = 100 2 \r\n flags = IPv4 \r\n}\r\n<\/pre>\n
# \/etc\/init.d\/xinetd restart\r\n# chkconfig xinetd on\r\n<\/pre>\n
# cp \/usr\/share\/syslinux\/pxelinux.0 \/var\/lib\/tftpboot\r\n<\/pre>\n
# cp \/var\/www\/html\/cdrom\/images\/pxeboot\/{initrd.img,vmlinuz} \/var\/lib\/tftpboot\/\r\n<\/pre>\n
\n<\/strong><\/span><\/div>\n# cp \/var\/www\/html\/cdrom\/isolinux\/*.msg \/var\/lib\/tftpboot\/\r\n<\/pre>\n
# mkdir \/var\/lib\/tftpboot\/pxelinux.cfg\r\n<\/pre>\n
# cp \/var\/www\/html\/cdrom\/isolinux\/isolinux.cfg \/var\/lib\/tftpboot\/pxelinux.cfg\/default\r\n<\/pre>\n
default ks \u3000\u3000\u3000\u3000#\u9ed8\u8ba4\u542f\u52a8\u7684\u662f 'label ks' \u4e2d\u6807\u8bb0\u7684\u542f\u52a8\u5185\u6838<\/span>\r\nprompt 1 #\u663e\u793a 'boot: ' \u63d0\u793a\u7b26\u3002\u4e3a '0' \u65f6\u5219\u4e0d\u63d0\u793a\uff0c\u5c06\u4f1a\u76f4\u63a5\u542f\u52a8 'default' \u53c2\u6570\u4e2d\u6307\u5b9a\u7684\u5185\u5bb9\u3002<\/span>\r\ntimeout 6 \u3000\u3000\u3000\u3000 #\u5728\u7528\u6237\u8f93\u5165\u4e4b\u524d\u7684\u8d85\u65f6\u65f6\u95f4\uff0c\u5355\u4f4d\u4e3a 1\/10 \u79d2\u3002<\/span>\r\ndisplay boot.msg #\u663e\u793a\u67d0\u4e2a\u6587\u4ef6\u7684\u5185\u5bb9\uff0c\u6ce8\u610f\u6587\u4ef6\u7684\u8def\u5f84\u3002\u9ed8\u8ba4\u662f\u5728\/var\/lib\/tftpboot\/ \u76ee\u5f55\u4e0b\u3002\u4e5f\u53ef\u4ee5\u6307\u5b9a\u4f4d\u7c7b\u4f3c '\/install\/boot.msg'\u8fd9\u6837\u7684\uff0c\u8def\u5f84+\u6587\u4ef6\u540d\u3002<\/span>\r\nF1 boot.msg \u3000\u3000\u3000 #\u6309\u4e0b 'F1' \u8fd9\u6837\u7684\u952e\u540e\u663e\u793a\u7684\u6587\u4ef6\u3002<\/span>\r\nF2 options.msg \r\nF3 general.msg \r\nF4 param.msg \r\nF5 rescue.msg \r\nlabel linux #'label' \u6307\u5b9a\u4f60\u5728 'boot:' \u63d0\u793a\u7b26\u4e0b\u8f93\u5165\u7684\u5173\u952e\u5b57\uff0c\u6bd4\u5982boot: linux[ENTER]\uff0c\u8fd9\u4e2a\u4f1a\u542f\u52a8'label linux' \u4e0b\u6807\u8bb0\u7684kernel \u548cinitrd.img \u6587\u4ef6\u3002<\/span>\r\n kernel vmlinuz #kernel \u53c2\u6570\u6307\u5b9a\u8981\u542f\u52a8\u7684\u5185\u6838\u3002<\/span>\r\n append initrd=initrd.img #append \u6307\u5b9a\u8ffd\u52a0\u7ed9\u5185\u6838\u7684\u53c2\u6570\uff0c\u80fd\u591f\u5728grub \u91cc\u4f7f\u7528\u7684\u8ffd\u52a0\u7ed9\u5185\u6838\u7684\u53c2\u6570\uff0c\u5728\u8fd9\u91cc\u4e5f\u90fd\u53ef\u4ee5\u4f7f\u7528\u3002<\/span>\r\nlabel text \r\n kernel vmlinuz \r\n append initrd=initrd.img text \r\nlabel ks \r\n kernel vmlinuz \r\n append ks=http:\/\/192.168.111.130\/ks.cfg initrd=initrd.img #\u544a\u8bc9\u7cfb\u7edf\uff0c\u4ece\u54ea\u91cc\u83b7\u53d6ks.cfg\u6587\u4ef6<\/span> \r\nlabel local \r\n localboot 1 \r\nlabel memtest86 \r\n kernel memtest \r\n append -\r\n<\/pre>\n
# yum -y install dhcp\r\n<\/pre>\n
# cp -f \/usr\/share\/doc\/dhcp-4.1.1\/dhcpd.conf.sample \/etc\/dhcp\/dhcpd.conf\r\n<\/pre>\n
ddns-update-style interim; \r\nignore client-updates; \r\nfilename \"pxelinux.0\"; \u3000\u3000#pxelinux \u542f\u52a8\u6587\u4ef6\u4f4d\u7f6e;\r\nnext-server 192.168.111.130;\u3000\u3000#TFTP Server \u7684IP\u5730\u5740;\r\n\r\nsubnet 192.168.111.0 netmask 255.255.255.0 {\r\n\r\n option routers 192.168.111.130; \r\n option subnet-mask 255.255.255.0;\r\n\r\n range dynamic-bootp 192.168.111.100 192.168.111.200; \r\n default-lease-time 21600; \r\n max-lease-time 43200;\r\n}\r\n<\/pre>\n
# \/etc\/init.d\/dhcpd start\r\n<\/pre>\n
# yum install system-config-kickstart\r\n<\/pre>\n
# startx\r\n<\/pre>\n
# system-config-kickstart\r\n<\/pre>\n
\n
\nB. \u8bbe\u7f6e\u5b89\u88c5\u65b9\u5f0f\uff0c\u8fd9\u7bc7\u6587\u7ae0\u4ecb\u7ecd\u7684\u662fHTTP\u65b9\u5f0f\u7684\u5b89\u88c5\uff0c\u6545\u9009\u62e9HTTP<\/span><\/p>\n
\nI. \u56fe\u5f62\u73af\u5883\u914d\u7f6e<\/span><\/p>\n
\n 2. \u542f\u52a8\u865a\u62df\u673a\uff0c\u9009\u62e9\u4ece\u7f51\u5361\u542f\u52a8\uff0cDHCP \u670d\u52a1\u5668\u6b63\u5728\u7ed9\u5ba2\u6237\u673a\u5206\u914dIP\u5730\u5740\u3002<\/span>
\n
\n3. \u5f00\u59cb\u4e0b\u8f7dvmlinuz \u548cinitrd.img<\/span>
\n
\n4. \u5b89\u88c5\u8fc7\u7a0b...<\/span>
\n<\/p>\n\n