📄 network-diskless.html
字号:
name="CO-DHCP-FILENAME"><img src="./imagelib/callouts/3.png" hspace="0" vspace="0"border="0" alt="(3)" /></a> option root-path "192.168.4.4:/data/misc/diskless"; <a id="CO-DHCP-ROOT-PATH"name="CO-DHCP-ROOT-PATH"><img src="./imagelib/callouts/4.png" hspace="0" vspace="0"border="0" alt="(4)" /></a> } host corbieres { hardware ethernet 00:02:b3:27:62:df; fixed-address corbieres.example.com; next-server 192.168.4.4; filename "pxeboot"; option root-path "192.168.4.4:/data/misc/diskless"; }} </pre><div class="CALLOUTLIST"><dl compact="COMPACT"><dt><a href="network-diskless.html#CO-DHCP-HOST-NAME"><imgsrc="./imagelib/callouts/1.png" hspace="0" vspace="0" border="0" alt="(1)" /></a></dt><dd>This option tells <b class="APPLICATION">dhcpd</b> to send the value in the <varclass="LITERAL">host</var> declarations as the hostname for the diskless host. Analternate way would be to add an <var class="LITERAL">option host-name <varclass="REPLACEABLE">margaux</var></var> inside the <var class="LITERAL">host</var>declarations.</dd><dt><a href="network-diskless.html#CO-DHCP-NEXT-SERVER"><imgsrc="./imagelib/callouts/2.png" hspace="0" vspace="0" border="0" alt="(2)" /></a></dt><dd>The <var class="LITERAL">next-server</var> directive designates the <acronymclass="ACRONYM">TFTP</acronym> or <acronym class="ACRONYM">NFS</acronym> server to usefor loading loader or kernel file (the default is to use the same host as the <acronymclass="ACRONYM">DHCP</acronym> server).</dd><dt><a href="network-diskless.html#CO-DHCP-FILENAME"><img src="./imagelib/callouts/3.png"hspace="0" vspace="0" border="0" alt="(3)" /></a></dt><dd>The <var class="LITERAL">filename</var> directive defines the file that <bclass="APPLICATION">Etherboot</b> or <acronym class="ACRONYM">PXE</acronym> will load forthe next execution step. It must be specified according to the transfer method used. <bclass="APPLICATION">Etherboot</b> can be compiled to use <acronymclass="ACRONYM">NFS</acronym> or <acronym class="ACRONYM">TFTP</acronym>. The FreeBSDport configures <acronym class="ACRONYM">NFS</acronym> by default. <acronymclass="ACRONYM">PXE</acronym> uses <acronym class="ACRONYM">TFTP</acronym>, which is whya relative filename is used here (this may depend on the <acronymclass="ACRONYM">TFTP</acronym> server configuration, but would be fairly typical). Also,<acronym class="ACRONYM">PXE</acronym> loads <tt class="FILENAME">pxeboot</tt>, not thekernel. There are other interesting possibilities, like loading <ttclass="FILENAME">pxeboot</tt> from a FreeBSD CD-ROM <tt class="FILENAME">/boot</tt>directory (as <a href="http://www.FreeBSD.org/cgi/man.cgi?query=pxeboot&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">pxeboot</span>(8)</span></a> can load a<tt class="FILENAME">GENERIC</tt> kernel, this makes it possible to use <acronymclass="ACRONYM">PXE</acronym> to boot from a remote CD-ROM).</dd><dt><a href="network-diskless.html#CO-DHCP-ROOT-PATH"><imgsrc="./imagelib/callouts/4.png" hspace="0" vspace="0" border="0" alt="(4)" /></a></dt><dd>The <var class="LITERAL">root-path</var> option defines the path to the rootfilesystem, in usual <acronym class="ACRONYM">NFS</acronym> notation. When using <acronymclass="ACRONYM">PXE</acronym>, it is possible to leave off the host's IP as long as youdo not enable the kernel option BOOTP. The <acronym class="ACRONYM">NFS</acronym> serverwill then be the same as the <acronym class="ACRONYM">TFTP</acronym> one.</dd></dl></div></div><div class="SECT3"><h3 class="SECT3"><a id="AEN37222" name="AEN37222">24.6.2.2 Configuration UsingBOOTP</a></h3><p>Here follows an equivalent <b class="APPLICATION">bootpd</b> configuration (reduced toone client). This would be found in <tt class="FILENAME">/etc/bootptab</tt>.</p><p>Please note that <b class="APPLICATION">Etherboot</b> must be compiled with thenon-default option <var class="LITERAL">NO_DHCP_SUPPORT</var> in order to use BOOTP, andthat <acronym class="ACRONYM">PXE</acronym> <span class="emphasis"><iclass="EMPHASIS">needs</i></span> <acronym class="ACRONYM">DHCP</acronym>. The onlyobvious advantage of <b class="APPLICATION">bootpd</b> is that it exists in the basesystem.</p><pre class="PROGRAMLISTING">.def100:\ :hn:ht=1:sa=192.168.4.4:vm=rfc1048:\ :sm=255.255.255.0:\ :ds=192.168.4.1:\ :gw=192.168.4.1:\ :hd="/tftpboot":\ :bf="/kernel.diskless":\ :rp="192.168.4.4:/data/misc/diskless":margaux:ha=0123456789ab:tc=.def100 </pre></div><div class="SECT3"><h3 class="SECT3"><a id="AEN37238" name="AEN37238">24.6.2.3 Preparing a Boot Program with<b class="APPLICATION">Etherboot</b></a></h3><p><a href="http://etherboot.sourceforge.net" target="_top">Etherboot's Web site</a>contains <a href="http://etherboot.sourceforge.net/doc/html/userman/t1.html"target="_top">extensive documentation</a> mainly intended for Linux systems, butnonetheless containing useful information. The following will just outline how you woulduse <b class="APPLICATION">Etherboot</b> on a FreeBSD system.</p><p>You must first install the <ahref="http://www.FreeBSD.org/cgi/url.cgi?ports/net/etherboot/pkg-descr"><ttclass="FILENAME">net/etherboot</tt></a> package or port.</p><p>You can change the <b class="APPLICATION">Etherboot</b> configuration (i.e. to use<acronym class="ACRONYM">TFTP</acronym> instead of <acronymclass="ACRONYM">NFS</acronym>) by editing the <tt class="FILENAME">Config</tt> file inthe <b class="APPLICATION">Etherboot</b> source directory.</p><p>For our setup, we shall use a boot floppy. For other methods (PROM, or <spanclass="TRADEMARK">MS-DOS</span> program), please refer to the <bclass="APPLICATION">Etherboot</b> documentation.</p><p>To make a boot floppy, insert a floppy in the drive on the machine where you installed<b class="APPLICATION">Etherboot</b>, then change your current directory to the <ttclass="FILENAME">src</tt> directory in the <b class="APPLICATION">Etherboot</b> tree andtype:</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">gmake bin32/<varclass="REPLACEABLE">devicetype</var>.fd0</kbd> </pre><p><var class="REPLACEABLE">devicetype</var> depends on the type of the Ethernet card inthe diskless workstation. Refer to the <tt class="FILENAME">NIC</tt> file in the samedirectory to determine the right <var class="REPLACEABLE">devicetype</var>.</p></div><div class="SECT3"><h3 class="SECT3"><a id="AEN37270" name="AEN37270">24.6.2.4 Booting with <acronymclass="ACRONYM">PXE</acronym></a></h3><p>By default, the <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=pxeboot&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">pxeboot</span>(8)</span></a> loaderloads the kernel via <acronym class="ACRONYM">NFS</acronym>. It can be compiled to use<acronym class="ACRONYM">TFTP</acronym> instead by specifying the <varclass="LITERAL">LOADER_TFTP_SUPPORT</var> option in <ttclass="FILENAME">/etc/make.conf</tt>. See the comments in <ttclass="FILENAME">/etc/defaults/make.conf</tt> (or <ttclass="FILENAME">/usr/share/examples/etc/make.conf</tt> for 5.X systems) forinstructions.</p><p>There are two other undocumented <tt class="FILENAME">make.conf</tt> options which maybe useful for setting up a serial console diskless machine: <varclass="LITERAL">BOOT_PXELDR_PROBE_KEYBOARD</var>, and <varclass="LITERAL">BOOT_PXELDR_ALWAYS_SERIAL</var> (the latter only exists onFreeBSD 5.X).</p><p>To use <acronym class="ACRONYM">PXE</acronym> when the machine starts, you willusually need to select the <var class="LITERAL">Boot from network</var> option in your<acronym class="ACRONYM">BIOS</acronym> setup, or type a function key during the PCinitialization.</p></div><div class="SECT3"><h3 class="SECT3"><a id="AEN37291" name="AEN37291">24.6.2.5 Configuring the <acronymclass="ACRONYM">TFTP</acronym> and <acronym class="ACRONYM">NFS</acronym>Servers</a></h3><p>If you are using <acronym class="ACRONYM">PXE</acronym> or <bclass="APPLICATION">Etherboot</b> configured to use <acronymclass="ACRONYM">TFTP</acronym>, you need to enable <b class="APPLICATION">tftpd</b> onthe file server:</p><div class="PROCEDURE"><ol type="1"><li><p>Create a directory from which <b class="APPLICATION">tftpd</b> will serve the files,e.g. <tt class="FILENAME">/tftpboot</tt>.</p></li><li><p>Add this line to your <tt class="FILENAME">/etc/inetd.conf</tt>:</p><pre class="PROGRAMLISTING">tftp dgram udp wait root /usr/libexec/tftpd tftpd -l -s /tftpboot</pre><div class="NOTE"><blockquote class="NOTE"><p><b>Note:</b> It appears that at least some <acronym class="ACRONYM">PXE</acronym>versions want the <acronym class="ACRONYM">TCP</acronym> version of <acronymclass="ACRONYM">TFTP</acronym>. In this case, add a second line, replacing <varclass="LITERAL">dgram udp</var> with <var class="LITERAL">stream tcp</var>.</p></blockquote></div></li><li><p>Tell <b class="APPLICATION">inetd</b> to reread its configuration file:</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbdclass="USERINPUT">kill -HUP `cat /var/run/inetd.pid`</kbd></pre></li></ol></div><p>You can place the <tt class="FILENAME">tftpboot</tt> directory anywhere on the server.Make sure that the location is set in both <tt class="FILENAME">inetd.conf</tt> and <ttclass="FILENAME">dhcpd.conf</tt>.</p><p>In all cases, you also need to enable <acronym class="ACRONYM">NFS</acronym> andexport the appropriate filesystem on the <acronym class="ACRONYM">NFS</acronym>server.</p><div class="PROCEDURE"><ol type="1"><li><p>Add this to <tt class="FILENAME">/etc/rc.conf</tt>:</p><pre class="PROGRAMLISTING">nfs_server_enable="YES"</pre></li><li><p>Export the filesystem where the diskless root directory is located by adding thefollowing to <tt class="FILENAME">/etc/exports</tt> (adjust the volume mount point andreplace <var class="REPLACEABLE">margaux corbieres</var> with the names of the disklessworkstations):</p><pre class="PROGRAMLISTING"><var class="REPLACEABLE">/data/misc</var> -alldirs -ro <varclass="REPLACEABLE">margaux corbieres</var></pre></li><li><p>Tell <b class="APPLICATION">mountd</b> to reread its configuration file. If youactually needed to enable <acronym class="ACRONYM">NFS</acronym> in <ttclass="FILENAME">/etc/rc.conf</tt> at the first step, you probably want to rebootinstead.</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbdclass="USERINPUT">kill -HUP `cat /var/run/mountd.pid`</kbd></pre></li></ol></div></div><div class="SECT3"><h3 class="SECT3"><a id="AEN37355" name="AEN37355">24.6.2.6 Building a DisklessKernel</a></h3><p>If using <b class="APPLICATION">Etherboot</b>, you need to create a kernelconfiguration file for the diskless client with the following options (in addition to theusual ones):</p><pre class="PROGRAMLISTING">options BOOTP # Use BOOTP to obtain IP address/hostnameoptions BOOTP_NFSROOT # NFS mount root filesystem using BOOTP info </pre><p>You may also want to use <var class="LITERAL">BOOTP_NFSV3</var>, <varclass="LITERAL">BOOT_COMPAT</var> and <var class="LITERAL">BOOTP_WIRED_TO</var> (refer to<tt class="FILENAME">LINT</tt> in 4.X or <tt class="FILENAME">NOTES</tt> on 5.X).</p><p>These option names are historical and slightly misleading as they actually enableindifferent use of <acronym class="ACRONYM">DHCP</acronym> and BOOTP inside the kernel(it is also possible to force strict BOOTP or <acronym class="ACRONYM">DHCP</acronym>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -