📄 makeworld.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>Rebuilding world</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="The Cutting Edge" href="cutting-edge.html" /><link rel="PREVIOUS" title="Synchronizing Your Source" href="synching.html" /><link rel="NEXT" title="Tracking for Multiple Machines" href="small-lan.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="synching.html"accesskey="P">Prev</a></td><td width="80%" align="center" valign="bottom">Chapter 19 The Cutting Edge</td><td width="10%" align="right" valign="bottom"><a href="small-lan.html"accesskey="N">Next</a></td></tr></table><hr align="LEFT" width="100%" /></div><div class="SECT1"><h1 class="SECT1"><a id="MAKEWORLD" name="MAKEWORLD">19.4 Rebuilding ``world''</a></h1><p>Once you have synchronized your local source tree against a particular version ofFreeBSD (FreeBSD-STABLE, FreeBSD-CURRENT, and so on) you can then use the source tree torebuild the system.</p><div class="WARNING"><blockquote class="WARNING"><p><b>Take a Backup:</b> It cannot be stressed enough how important it is to take abackup of your system <span class="emphasis"><i class="EMPHASIS">before</i></span> you dothis. While rebuilding the world is (as long as you follow these instructions) an easytask to do, there will inevitably be times when you make mistakes, or when mistakes madeby others in the source tree render your system unbootable.</p><p>Make sure you have taken a backup. And have a fixit floppy or bootable CD at hand. Youwill probably never have to use it, but it is better to be safe than sorry!</p></blockquote></div><div class="WARNING"><blockquote class="WARNING"><p><b>Subscribe to the Right Mailing List:</b> The FreeBSD-STABLE and FreeBSD-CURRENTbranches are, by their nature, <span class="emphasis"><i class="EMPHASIS">indevelopment</i></span>. People that contribute to FreeBSD are human, and mistakesoccasionally happen.</p><p>Sometimes these mistakes can be quite harmless, just causing your system to print anew diagnostic warning. Or the change may be catastrophic, and render your systemunbootable or destroy your file systems (or worse).</p><p>If problems like these occur, a ``heads up'' is posted to the appropriate mailinglist, explaining the nature of the problem and which systems it affects. And an ``allclear'' announcement is posted when the problem has been solved.</p><p>If you try to track FreeBSD-STABLE or FreeBSD-CURRENT and do not read the <ahref="http://lists.FreeBSD.org/mailman/listinfo/freebsd-stable"target="_top">FreeBSD-STABLE mailing list</a> or the <ahref="http://lists.FreeBSD.org/mailman/listinfo/freebsd-current"target="_top">FreeBSD-CURRENT mailing list</a> respectively, then you are asking fortrouble.</p></blockquote></div><div class="WARNING"><blockquote class="WARNING"><p><b>Do not use <tt class="COMMAND">make world</tt>:</b> A lot of older documentationrecommends using <tt class="COMMAND">make world</tt> for this. Doing that skips someimportant steps and should only be used if you are sure of what you are doing. For almostall circumstances <tt class="COMMAND">make world</tt> is the wrong thing to do, and theprocedure described here should be used instead.</p></blockquote></div><div class="SECT2"><h2 class="SECT2"><a id="AEN27468" name="AEN27468">19.4.1 The Canonical Way to UpdateYour System</a></h2><p>To update your system, you should use the following procedure:</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">make buildworld</kbd><samp class="PROMPT">#</samp> <kbd class="USERINPUT">make buildkernel</kbd><samp class="PROMPT">#</samp> <kbd class="USERINPUT">make installkernel</kbd><samp class="PROMPT">#</samp> <kbd class="USERINPUT">reboot</kbd></pre><p>You should boot in single user mode (using <tt class="COMMAND">boot -s</tt> fromloader prompt for example). Then run:</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">mergemaster -p</kbd><samp class="PROMPT">#</samp> <kbd class="USERINPUT">make installworld</kbd><samp class="PROMPT">#</samp> <kbd class="USERINPUT">mergemaster</kbd><samp class="PROMPT">#</samp> <kbd class="USERINPUT">reboot</kbd></pre><div class="WARNING"><blockquote class="WARNING"><p><b>Read Further Explanations:</b> The sequence described above is only a short resumeto help you getting started. You should however read the following sections to clearlyunderstand each step, especially if you want to use a custom kernel configuration.</p></blockquote></div></div><div class="SECT2"><h2 class="SECT2"><a id="AEN27494" name="AEN27494">19.4.2 Read <ttclass="FILENAME">/usr/src/UPDATING</tt></a></h2><p>Before you do anything else, read <tt class="FILENAME">/usr/src/UPDATING</tt> (or theequivalent file wherever you have a copy of the source code). This file should containimportant information about problems you might encounter, or specify the order in whichyou might have to run certain commands. If <tt class="FILENAME">UPDATING</tt> contradictssomething you read here, <tt class="FILENAME">UPDATING</tt> takes precedence.</p><div class="IMPORTANT"><blockquote class="IMPORTANT"><p><b>Important:</b> Reading <tt class="FILENAME">UPDATING</tt> is not an acceptablesubstitute for subscribing to the correct mailing list, as described previously. The tworequirements are complementary, not exclusive.</p></blockquote></div></div><div class="SECT2"><h2 class="SECT2"><a id="AEN27504" name="AEN27504">19.4.3 Check <ttclass="FILENAME">/etc/make.conf</tt></a></h2><p>Examine the files <tt class="FILENAME">/usr/share/examples/etc/make.conf</tt> (called<tt class="FILENAME">/etc/defaults/make.conf</tt> in FreeBSD 4.X) and <ttclass="FILENAME">/etc/make.conf</tt>. The first contains some default defines - most ofwhich are commented out. To make use of them when you rebuild your system from source,add them to <tt class="FILENAME">/etc/make.conf</tt>. Keep in mind that anything you addto <tt class="FILENAME">/etc/make.conf</tt> is also used every time you run <ttclass="COMMAND">make</tt>, so it is a good idea to set them to something sensible foryour system.</p><p>A typical user will probably want to copy the <tt class="MAKEVAR">CFLAGS</tt> and <ttclass="MAKEVAR">NOPROFILE</tt> lines found in <ttclass="FILENAME">/usr/share/examples/etc/make.conf</tt> (or in <ttclass="FILENAME">/etc/defaults/make.conf</tt> on FreeBSD 4.X) to <ttclass="FILENAME">/etc/make.conf</tt> and uncomment them.</p><p>Examine the other definitions (<tt class="MAKEVAR">COPTFLAGS</tt>, <ttclass="MAKEVAR">NOPORTDOCS</tt> and so on) and decide if they are relevant to you.</p></div><div class="SECT2"><h2 class="SECT2"><a id="AEN27526" name="AEN27526">19.4.4 Update the Files in <ttclass="FILENAME">/etc</tt></a></h2><p>The <tt class="FILENAME">/etc</tt> directory contains a large part of your system'sconfiguration information, as well as scripts that are run at system startup. Some ofthese scripts change from version to version of FreeBSD.</p><p>Some of the configuration files are also used in the day to day running of the system.In particular, <tt class="FILENAME">/etc/group</tt>.</p><p>There have been occasions when the installation part of ``make installworld'' hasexpected certain usernames or groups to exist. When performing an upgrade it is likelythat these users or groups did not exist. This caused problems when upgrading. In somecases ``make buildworld'' will check to see if these users or groups exist.</p><p>A recent example of this is when the <tt class="USERNAME">smmsp</tt> user was added.Users had the installation process fail for them when <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=mtree&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">mtree</span>(8)</span></a> was trying tocreate <tt class="FILENAME">/var/spool/clientmqueue</tt>.</p><p>The solution is to examine <tt class="FILENAME">/usr/src/etc/group</tt> and compareits list of groups with your own. If there are any groups in the new file that are not inyour file then copy them over. Similarly, you should rename any groups in <ttclass="FILENAME">/etc/group</tt> which have the same GID but a different name to those in<tt class="FILENAME">/usr/src/etc/group</tt>.</p><p>Since 4.6-RELEASE you can run <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=mergemaster&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">mergemaster</span>(8)</span></a> inpre-buildworld mode by providing the <var class="OPTION">-p</var> option. This willcompare only those files that are essential for the success of <ttclass="MAKETARGET">buildworld</tt> or <tt class="MAKETARGET">installworld</tt>. If yourold version of <tt class="COMMAND">mergemaster</tt> does not support <varclass="OPTION">-p</var>, use the new version in the source tree when running for thefirst time:</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbdclass="USERINPUT">cd /usr/src/usr.sbin/mergemaster</kbd><samp class="PROMPT">#</samp> <kbd class="USERINPUT">./mergemaster.sh -p</kbd></pre><div class="TIP"><blockquote class="TIP"><p><b>Tip:</b> If you are feeling particularly paranoid, you can check your system to seewhich files are owned by the group you are renaming or deleting:</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">find / -group <varclass="REPLACEABLE">GID</var> -print</kbd></pre><p>will show all files owned by group <var class="REPLACEABLE">GID</var> (which can beeither a group name or a numeric group ID).</p></blockquote></div></div><div class="SECT2"><h2 class="SECT2"><a id="MAKEWORLD-SINGLEUSER" name="MAKEWORLD-SINGLEUSER">19.4.5 Drop toSingle User Mode</a></h2><p>You may want to compile the system in single user mode. Apart from the obvious benefitof making things go slightly faster, reinstalling the system will touch a lot ofimportant system files, all the standard system binaries, libraries, include files and soon. Changing these on a running system (particularly if you have active users on thesystem at the time) is asking for trouble.</p><p>Another method is to compile the system in multi-user mode, and then drop into singleuser mode for the installation. If you would like to do it this way, simply hold off onthe following steps until the build has completed. You can postpone dropping to singleuser mode until you have to <tt class="MAKETARGET">installkernel</tt> or <ttclass="MAKETARGET">installworld</tt>.</p><p>As the superuser, you can execute:</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">shutdown now</kbd></pre><p>from a running system, which will drop it to single user mode.</p><p>Alternatively, reboot the system, and at the boot prompt, enter the <varclass="OPTION">-s</var> flag. The system will then boot single user. At the shell promptyou should then run:</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">fsck -p</kbd><samp class="PROMPT">#</samp> <kbd class="USERINPUT">mount -u /</kbd><samp class="PROMPT">#</samp> <kbd class="USERINPUT">mount -a -t ufs</kbd><samp class="PROMPT">#</samp> <kbd class="USERINPUT">swapon -a</kbd></pre><p>This checks the file systems, remounts <tt class="FILENAME">/</tt> read/write, mountsall the other UFS file systems referenced in <tt class="FILENAME">/etc/fstab</tt> andthen turns swapping on.</p><div class="NOTE"><blockquote class="NOTE"><p><b>Note:</b> If your CMOS clock is set to local time and not to GMT (this is true ifthe output of the <a href="http://www.FreeBSD.org/cgi/man.cgi?query=date&sektion=1"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">date</span>(1)</span></a> command doesnot show the correct time and zone), you may also need to run the following command:</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">adjkerntz -i</kbd></pre><p>This will make sure that your local time-zone settings get set up correctly -- withoutthis, you may later run into some problems.</p></blockquote></div></div><div class="SECT2"><h2 class="SECT2"><a id="AEN27606" name="AEN27606">19.4.6 Remove <ttclass="FILENAME">/usr/obj</tt></a></h2><p>As parts of the system are rebuilt they are placed in directories which (by default)go under <tt class="FILENAME">/usr/obj</tt>. The directories shadow those under <ttclass="FILENAME">/usr/src</tt>.</p><p>You can speed up the ``make buildworld'' process, and possibly save yourself somedependency headaches by removing this directory as well.</p><p>Some files below <tt class="FILENAME">/usr/obj</tt> may have the immutable flag set(see <a href="http://www.FreeBSD.org/cgi/man.cgi?query=chflags&sektion=1"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">chflags</span>(1)</span></a> for moreinformation) which must be removed first.</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">cd /usr/obj</kbd><samp class="PROMPT">#</samp> <kbd class="USERINPUT">chflags -R noschg *</kbd><samp class="PROMPT">#</samp> <kbd class="USERINPUT">rm -rf *</kbd></pre></div><div class="SECT2"><h2 class="SECT2"><a id="AEN27626" name="AEN27626">19.4.7 Recompile the Source</a></h2><div class="SECT3"><h3 class="SECT3"><a id="AEN27628" name="AEN27628">19.4.7.1 Saving the Output</a></h3><p>It is a good idea to save the output you get from running <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=make&sektion=1"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">make</span>(1)</span></a> to anotherfile. If something goes wrong you will have a copy of the error message. While this mightnot help you in diagnosing what has gone wrong, it can help others if you post yourproblem to one of the FreeBSD mailing lists.</p><p>The easiest way to do this is to use the <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=script&sektion=1"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">script</span>(1)</span></a> command,with a parameter that specifies the name of the file to save all output to. You would dothis immediately before rebuilding the world, and then type <kbdclass="USERINPUT">exit</kbd> when the process has finished.</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">script /var/tmp/mw.out</kbd>Script started, output file is /var/tmp/mw.out <samp class="PROMPT">#</samp> <kbd class="USERINPUT">make TARGET</kbd><span class="emphasis"><iclass="EMPHASIS">... compile, compile, compile ...</i></span> <samp class="PROMPT">#</samp> <kbd class="USERINPUT">exit</kbd>Script done, ...</pre><p>If you do this, <span class="emphasis"><i class="EMPHASIS">do not</i></span> save theoutput in <tt class="FILENAME">/tmp</tt>. This directory may be cleared next time youreboot. A better place to store it is in <tt class="FILENAME">/var/tmp</tt> (as in theprevious example) or in <tt class="USERNAME">root</tt>'s home directory.</p></div><div class="SECT3"><h3 class="SECT3"><a id="MAKE-BUILDWORLD" name="MAKE-BUILDWORLD">19.4.7.2 Compile the
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -