📄 network-diskless.html
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta name="generator" content="HTML Tidy, see www.w3.org" /><title>Diskless Operation</title><meta name="GENERATOR" content="Modular DocBook HTML Stylesheet Version 1.7" /><link rel="HOME" title="FreeBSD Handbook" href="index.html" /><link rel="UP" title="Advanced Networking" href="advanced-networking.html" /><link rel="PREVIOUS" title="Bridging" href="network-bridging.html" /><link rel="NEXT" title="ISDN" href="network-isdn.html" /><link rel="STYLESHEET" type="text/css" href="docbook.css" /></head><body class="SECT1" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#840084"alink="#0000FF"><div class="NAVHEADER"><table summary="Header navigation table" width="100%" border="0" cellpadding="0"cellspacing="0"><tr><th colspan="3" align="center">FreeBSD Handbook</th></tr><tr><td width="10%" align="left" valign="bottom"><a href="network-bridging.html"accesskey="P">Prev</a></td><td width="80%" align="center" valign="bottom">Chapter 24 Advanced Networking</td><td width="10%" align="right" valign="bottom"><a href="network-isdn.html"accesskey="N">Next</a></td></tr></table><hr align="LEFT" width="100%" /></div><div class="SECT1"><h1 class="SECT1"><a id="NETWORK-DISKLESS" name="NETWORK-DISKLESS">24.6 DisklessOperation</a></h1><i class="AUTHORGROUP"><span class="CONTRIB">Updated by</span> Jean-Fran鏾is Dock鑣.</i><i class="AUTHORGROUP"><span class="CONTRIB">Reorganized and enhanced by</span> AlexDupre.</i> <p>A FreeBSD machine can boot over the network and operate without a local disk, usingfilesystems mounted from an <acronym class="ACRONYM">NFS</acronym> server. No systemmodification is necessary, beyond standard configuration files. Such a system isrelatively easy to set up because all the necessary elements are readily available:</p><ul><li><p>There are at least two possible methods to load the kernel over the network:</p><ul><li><p><acronym class="ACRONYM">PXE</acronym>: The <span class="TRADEMARK">Intel</span>®Preboot eXecution Environment system is a form of smart boot ROM built into somenetworking cards or motherboards. See <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=pxeboot&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">pxeboot</span>(8)</span></a> for moredetails.</p></li><li><p>The <b class="APPLICATION">Etherboot</b> port (<ahref="http://www.FreeBSD.org/cgi/url.cgi?ports/net/etherboot/pkg-descr"><ttclass="FILENAME">net/etherboot</tt></a>) produces ROM-able code to boot kernels over thenetwork. The code can be either burnt into a boot PROM on a network card, or loaded froma local floppy (or hard) disk drive, or from a running <spanclass="TRADEMARK">MS-DOS</span>® system. Many network cards are supported.</p></li></ul></li><li><p>A sample script (<tt class="FILENAME">/usr/share/examples/diskless/clone_root</tt>)eases the creation and maintenance of the workstation's root filesystem on the server.The script will probably require a little customization but it will get you started veryquickly.</p></li><li><p>Standard system startup files exist in <tt class="FILENAME">/etc</tt> to detect andsupport a diskless system startup.</p></li><li><p>Swapping, if needed, can be done either to an <acronym class="ACRONYM">NFS</acronym>file or to a local disk.</p></li></ul><p>There are many ways to set up diskless workstations. Many elements are involved, andmost can be customized to suit local taste. The following will describe variations on thesetup of a complete system, emphasizing simplicity and compatibility with the standardFreeBSD startup scripts. The system described has the following characteristics:</p><ul><li><p>The diskless workstations use a shared read-only <tt class="FILENAME">/</tt>filesystem, and a shared read-only <tt class="FILENAME">/usr</tt>.</p><p>The root filesystem is a copy of a standard FreeBSD root (typically the server's),with some configuration files overridden by ones specific to diskless operation or,possibly, to the workstation they belong to.</p><p>The parts of the root which have to be writable are overlaid with <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=mfs&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">mfs</span>(8)</span></a>(FreeBSD 4.X) or <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=md&sektion=4"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">md</span>(4)</span></a>(FreeBSD 5.X) filesystems. Any changes will be lost when the system reboots.</p></li><li><p>The kernel is transferred and loaded either with <b class="APPLICATION">Etherboot</b>or <acronym class="ACRONYM">PXE</acronym> as some situations may mandate the use ofeither method.</p></li></ul><div class="CAUTION"><blockquote class="CAUTION"><p><b>Caution:</b> As described, this system is insecure. It should live in a protectedarea of a network, and be untrusted by other hosts.</p></blockquote></div><p>All the information in this section has been tested using FreeBSD releases 4.9-RELEASEand 5.2.1-RELEASE. The text is primarily structured for 4.X usage. Notes have beeninserted where appropriate to indicate 5.X changes.</p><div class="SECT2"><h2 class="SECT2"><a id="AEN37085" name="AEN37085">24.6.1 Background Information</a></h2><p>Setting up diskless workstations is both relatively straightforward and prone toerrors. These are sometimes difficult to diagnose for a number of reasons. Forexample:</p><ul><li><p>Compile time options may determine different behaviors at runtime.</p></li><li><p>Error messages are often cryptic or totally absent.</p></li></ul><p>In this context, having some knowledge of the background mechanisms involved is veryuseful to solve the problems that may arise.</p><p>Several operations need to be performed for a successful bootstrap:</p><ul><li><p>The machine needs to obtain initial parameters such as its IP address, executablefilename, server name, root path. This is done using the <acronymclass="ACRONYM">DHCP</acronym> or BOOTP protocols. <acronymclass="ACRONYM">DHCP</acronym> is a compatible extension of BOOTP, and uses the same portnumbers and basic packet format.</p><p>It is possible to configure a system to use only BOOTP. The <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=bootpd&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">bootpd</span>(8)</span></a> serverprogram is included in the base FreeBSD system.</p><p>However, <acronym class="ACRONYM">DHCP</acronym> has a number of advantages over BOOTP(nicer configuration files, possibility of using <acronym class="ACRONYM">PXE</acronym>,plus many others not directly related to diskless operation), and we will describe mainlya <acronym class="ACRONYM">DHCP</acronym> configuration, with equivalent examples using<a href="http://www.FreeBSD.org/cgi/man.cgi?query=bootpd&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">bootpd</span>(8)</span></a> whenpossible. The sample configuration will use the <b class="APPLICATION">ISC DHCP</b>software package (release 3.0.1.r12 was installed on the test server).</p></li><li><p>The machine needs to transfer one or several programs to local memory. Either <acronymclass="ACRONYM">TFTP</acronym> or <acronym class="ACRONYM">NFS</acronym> are used. Thechoice between <acronym class="ACRONYM">TFTP</acronym> and <acronymclass="ACRONYM">NFS</acronym> is a compile time option in several places. A common sourceof error is to specify filenames for the wrong protocol: <acronymclass="ACRONYM">TFTP</acronym> typically transfers all files from a single directory onthe server, and would expect filenames relative to this directory. <acronymclass="ACRONYM">NFS</acronym> needs absolute file paths.</p></li><li><p>The possible intermediate bootstrap programs and the kernel need to be initialized andexecuted. There are several important variations in this area:</p><ul><li><p><acronym class="ACRONYM">PXE</acronym> will load <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=pxeboot&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">pxeboot</span>(8)</span></a>, which is amodified version of the FreeBSD third stage loader. The <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=loader&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">loader</span>(8)</span></a> will obtainmost parameters necessary to system startup, and leave them in the kernel environmentbefore transferring control. It is possible to use a <tt class="FILENAME">GENERIC</tt>kernel in this case.</p></li><li><p><b class="APPLICATION">Etherboot</b>, will directly load the kernel, with lesspreparation. You will need to build a kernel with specific options.</p></li></ul><p><acronym class="ACRONYM">PXE</acronym> and <b class="APPLICATION">Etherboot</b> workequally well with 4.X systems. Because 5.X kernels normally let the <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=loader&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">loader</span>(8)</span></a> do more workfor them, <acronym class="ACRONYM">PXE</acronym> is preferred for 5.X systems.</p><p>If your <acronym class="ACRONYM">BIOS</acronym> and network cards support <acronymclass="ACRONYM">PXE</acronym>, you should probably use it. However, it is still possibleto start a 5.X system with <b class="APPLICATION">Etherboot</b>.</p></li><li><p>Finally, the machine needs to access its filesystems. <acronymclass="ACRONYM">NFS</acronym> is used in all cases.</p></li></ul><p>See also <a href="http://www.FreeBSD.org/cgi/man.cgi?query=diskless&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">diskless</span>(8)</span></a> manualpage.</p></div><div class="SECT2"><h2 class="SECT2"><a id="AEN37154" name="AEN37154">24.6.2 Setup Instructions</a></h2><div class="SECT3"><h3 class="SECT3"><a id="AEN37156" name="AEN37156">24.6.2.1 Configuration Using <bclass="APPLICATION">ISC DHCP</b></a></h3><p>The <b class="APPLICATION">ISC DHCP</b> server can answer both BOOTP and <acronymclass="ACRONYM">DHCP</acronym> requests.</p><p>As of release 4.9, <b class="APPLICATION">ISC DHCP 3.0</b> is not part of the basesystem. You will first need to install the <ahref="http://www.FreeBSD.org/cgi/url.cgi?ports/net/isc-dhcp3-server/pkg-descr"><ttclass="FILENAME">net/isc-dhcp3-server</tt></a> port or the corresponding package.</p><p>Once <b class="APPLICATION">ISC DHCP</b> is installed, it needs a configuration fileto run, (normally named <tt class="FILENAME">/usr/local/etc/dhcpd.conf</tt>). Herefollows a commented example, where host <tt class="HOSTID">margaux</tt> uses <bclass="APPLICATION">Etherboot</b> and host <tt class="HOSTID">corbieres</tt> uses<acronym class="ACRONYM">PXE</acronym>:</p><pre class="PROGRAMLISTING">default-lease-time 600;max-lease-time 7200;authoritative;option domain-name "example.com";option domain-name-servers 192.168.4.1;option routers 192.168.4.1;subnet 192.168.4.0 netmask 255.255.255.0 { use-host-decl-names on; <a id="CO-DHCP-HOST-NAME" name="CO-DHCP-HOST-NAME"><imgsrc="./imagelib/callouts/1.png" hspace="0" vspace="0" border="0" alt="(1)" /></a> option subnet-mask 255.255.255.0; option broadcast-address 192.168.4.255; host margaux { hardware ethernet 01:23:45:67:89:ab; fixed-address margaux.example.com; next-server 192.168.4.4; <a id="CO-DHCP-NEXT-SERVER" name="CO-DHCP-NEXT-SERVER"><imgsrc="./imagelib/callouts/2.png" hspace="0" vspace="0" border="0" alt="(2)" /></a> filename "/data/misc/kernel.diskless"; <a id="CO-DHCP-FILENAME"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -