Linux中国
1.71K subscribers
777 photos
6.34K links
Linux 中国官方 Telegram 频道
Download Telegram
如何构建一台网络引导服务器(三)

<a href="https://dn-linuxcn.qbox.me/data/attachment/album/201901/01/172110uwb7tt3x0gapas33.jpg">Media</a>&#22312; <a href="https://linux.cn/article-10379-1.html">&#22914;&#20309;&#26500;&#24314;&#19968;&#21488;&#32593;&#32476;&#24341;&#23548;&#26381;&#21153;&#22120;&#65288;&#19968;&#65289;</a> &#20013;&#65292;&#25105;&#20204;&#25552;&#20379;&#20102;&#19968;&#20010;&#26497;&#31616;&#30340; <a href="https://ipxe.org/">iPXE</a> &#24341;&#23548;&#33050;&#26412;&#26469;&#24341;&#23548;&#20320;&#30340;&#32593;&#32476;&#24341;&#23548;&#38236;&#20687;&#12290;&#35768;&#22810;&#29992;&#25143;&#38500;&#20102;&#20351;&#29992;&#32593;&#32476;&#24341;&#23548;&#38236;&#20687;&#22806;&#65292;&#21487;&#33021;&#22312;&#26426;&#22120;&#26412;&#22320;&#20063;&#26377;&#19968;&#20010;&#25805;&#20316;&#31995;&#32479;&#12290;&#20294;&#26159;&#20351;&#29992;&#24120;&#35265;&#30340;&#24037;&#20316;&#31449;&#30340; BIOS &#21435;&#20999;&#25442;&#24341;&#23548;&#21152;&#36733;&#22120;&#26159;&#24456;&#31528;&#25305;&#30340;&#12290;&#22312;&#26412;&#31995;&#21015;&#25991;&#20214;&#30340;&#31532;&#19977;&#37096;&#20998;&#65292;&#25105;&#20204;&#23558;&#21521;&#20320;&#23637;&#31034;&#22914;&#20309;&#35774;&#32622;&#19968;&#20010;&#26356;&#22797;&#26434;&#30340; iPXE &#37197;&#32622;&#12290;&#23427;&#23558;&#20801;&#35768;&#32456;&#31471;&#29992;&#25143;&#20197;&#26356;&#23481;&#26131;&#30340;&#26041;&#24335;&#21435;&#36873;&#25321;&#24341;&#23548;&#21738;&#20010;&#25805;&#20316;&#31995;&#32479;&#12290;&#23427;&#20063;&#21487;&#20197;&#37197;&#32622;&#20026;&#35753;&#31995;&#32479;&#31649;&#29702;&#21592;&#20174;&#19968;&#21488;&#20013;&#22830;&#26381;&#21153;&#22120;&#26469;&#32479;&#19968;&#31649;&#29702;&#24341;&#23548;&#33756;&#21333;&#12290;&#19968;&#20010;&#20132;&#20114;&#24335; iPXE &#24341;&#23548;&#33756;&#21333;&#19979;&#38754;&#36825;&#20123;&#21629;&#20196;&#37325;&#23450;&#20041;&#20102;&#32593;&#32476;&#24341;&#23548;&#38236;&#20687;&#30340; boot.cfg &#26469;&#20316;&#20026;&#19968;&#20010;&#20132;&#20114;&#24335;&#30340; iPXE &#24341;&#23548;&#33756;&#21333;&#65292;&#24182;&#20351;&#29992;&#20102;&#19968;&#20010; 5 &#31186;&#20498;&#35745;&#26102;&#30340;&#23450;&#26102;&#22120;&#65306;<pre class="prettyprint linenums">$ MY_FVER=29$ MY_KRNL=$(ls -c /fc$MY_FVER/lib/modules | head -n 1)$ MY_DNS1=192.0.2.91$ MY_DNS2=192.0.2.92$ MY_NAME=server-01.example.edu$ MY_EMAN=$(echo $MY_NAME | tr '.' "\n" | tac | tr "\n" '.' | cut -b -${#MY_NAME})$ MY_ADDR=$(host -t A $MY_NAME | awk '{print $4}')$ cat << END > $HOME/esp/linux/boot.cfg#!ipxeset timeout 5000:menumenu iPXE Boot Menuitem --key 1 lcl 1. Microsoft Windows 10item --key 2 f$MY_FVER 2. RedHat Fedora $MY_FVERchoose --timeout \${timeout} --default lcl selected || goto shellset timeout 0goto \${selected}:failedecho boot failed, dropping to shell...goto shell:shellecho type 'exit' to get the back to the menuset timeout 0shellgoto menu:lclexit:f$MY_FVERkernel --name kernel.efi \${prefix}/vmlinuz-$MY_KRNL initrd=initrd.img ro ip=dhcp rd.peerdns=0 nameserver=$MY_DNS1 nameserver=$MY_DNS2 root=/dev/disk/by-path/ip-$MY_ADDR:3260-iscsi-iqn.$MY_EMAN:fc$MY_FVER-lun-1 netroot=iscsiMediaMY_ADDR::::iqn.$MY_EMAN:fc$MY_FVER console=tty0 console=ttyS0,115200n8 audit=0 selinux=0 quietinitrd --name initrd.img \${prefix}/initramfs-$MY_KRNL.imgboot || goto failedEND</pre>&#19978;&#36848;&#33756;&#21333;&#26377;&#20116;&#20010;&#33410;&#65306;menu &#23450;&#20041;&#20102;&#26174;&#31034;&#22312;&#23631;&#24149;&#19978;&#30340;&#23454;&#38469;&#33756;&#21333;&#20869;&#23481;&#12290;failed &#25552;&#31034;&#29992;&#25143;&#21457;&#29983;&#20102;&#38169;&#35823;&#65292;&#24182;&#23558;&#29992;&#25143;&#24102;&#21040; shell &#20197;&#38169;&#35823;&#38169;&#35823;&#12290;shell &#25552;&#20379;&#20102;&#20132;&#20114;&#24335;&#21629;&#20196;&#25552;&#31034;&#31526;&#12290;&#20320;&#21487;&#20197;&…