⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vinum-root.html

📁 FreeBSD操作系统的详细使用手册
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<!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>Using Vinum for the Root Filesystem</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 Vinum Volume Manager" href="vinum-vinum.html" /><link rel="PREVIOUS" title="Configuring Vinum" href="vinum-config.html" /><link rel="NEXT" title="Localization - I18N/L10N Usage and Setup" href="l10n.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="vinum-config.html"accesskey="P">Prev</a></td><td width="80%" align="center" valign="bottom">Chapter 17 The Vinum Volume Manager</td><td width="10%" align="right" valign="bottom"><a href="l10n.html"accesskey="N">Next</a></td></tr></table><hr align="LEFT" width="100%" /></div><div class="SECT1"><h1 class="SECT1"><a id="VINUM-ROOT" name="VINUM-ROOT">17.9 Using Vinum for the RootFilesystem</a></h1><p>For a machine that has fully-mirrored filesystems using Vinum, it is desirable to alsomirror the root filesystem. Setting up such a configuration is less trivial thanmirroring an arbitrary filesystem because:</p><ul><li><p>The root filesystem must be available very early during the boot process, so the Vinuminfrastructure must already be available at this time.</p></li><li><p>The volume containing the root filesystem also contains the system bootstrap and thekernel, which must be read using the host system's native utilities (e. g. the BIOS onPC-class machines) which often cannot be taught about the details of Vinum.</p></li></ul><p>In the following sections, the term ``root volume'' is generally used to describe theVinum volume that contains the root filesystem. It is probably a good idea to use thename <var class="LITERAL">"root"</var> for this volume, but this is not technicallyrequired in any way. All command examples in the following sections assume this namethough.</p><div class="SECT2"><h2 class="SECT2"><a id="AEN26359" name="AEN26359">17.9.1 Starting up Vinum Early Enoughfor the Root Filesystem</a></h2><p>There are several measures to take for this to happen:</p><ul><li><p>Vinum must be available in the kernel at boot-time. Thus, the method to start Vinumautomatically described in <a href="vinum-config.html#VINUM-RC-STARTUP">Section17.8.1.1</a> is not applicable to accomplish this task, and the <varclass="LITERAL">start_vinum</var> parameter must actually <span class="emphasis"><iclass="EMPHASIS">not</i></span> be set when the following setup is being arranged. Thefirst option would be to compile Vinum statically into the kernel, so it is available allthe time, but this is usually not desirable. There is another option as well, to have <ttclass="FILENAME">/boot/loader</tt> (<a href="boot-blocks.html#BOOT-LOADER">Section12.3.3</a>) load the vinum kernel module early, before starting the kernel. This can beaccomplished by putting the line:</p><pre class="PROGRAMLISTING">vinum_load="YES"</pre><p>into the file <tt class="FILENAME">/boot/loader.conf</tt>.</p></li><li><p>Vinum must be initialized early since it needs to supply the volume for the rootfilesystem. By default, the Vinum kernel part is not looking for drives that mightcontain Vinum volume information until the administrator (or one of the startup scripts)issues a <tt class="COMMAND">vinum start</tt> command.</p><div class="NOTE"><blockquote class="NOTE"><p><b>Note:</b> The following paragraphs are outlining the steps needed for FreeBSD 5.xand above. The setup required for FreeBSD 4.x differs, and is described below in <ahref="vinum-root.html#VINUM-ROOT-4X">Section 17.9.5</a>.</p></blockquote></div><p>By placing the line:</p><pre class="PROGRAMLISTING">vinum.autostart="YES"</pre><p>into <tt class="FILENAME">/boot/loader.conf</tt>, Vinum is instructed to automaticallyscan all drives for Vinum information as part of the kernel startup.</p><p>Note that it is not necessary to instruct the kernel where to look for the rootfilesystem. <tt class="FILENAME">/boot/loader</tt> looks up the name of the root devicein <tt class="FILENAME">/etc/fstab</tt>, and passes this information on to the kernel.When it comes to mount the root filesystem, the kernel figures out from the devicenameprovided which driver to ask to translate this into the internal device ID (major/minornumber).</p></li></ul></div><div class="SECT2"><h2 class="SECT2"><a id="AEN26386" name="AEN26386">17.9.2 Making a Vinum-based RootVolume Accessible to the Bootstrap</a></h2><p>Since the current FreeBSD bootstrap is only 7.5 KB of code, and already has the burdenof reading files (like <tt class="FILENAME">/boot/loader</tt>) from the UFS filesystem,it is sheer impossible to also teach it about internal Vinum structures so it could parsethe Vinum configuration data, and figure out about the elements of a boot volume itself.Thus, some tricks are necessary to provide the bootstrap code with the illusion of astandard <var class="LITERAL">"a"</var> partition that contains the root filesystem.</p><p>For this to be possible at all, the following requirements must be met for the rootvolume:</p><ul><li><p>The root volume must not be striped or RAID-5.</p></li><li><p>The root volume must not contain more than one concatenated subdisk per plex.</p></li></ul><p>Note that it is desirable and possible that there are multiple plexes, each containingone replica of the root filesystem. The bootstrap process will, however, only use one ofthese replica for finding the bootstrap and all the files, until the kernel willeventually mount the root filesystem itself. Each single subdisk within these plexes willthen need its own <var class="LITERAL">"a"</var> partition illusion, for the respectivedevice to become bootable. It is not strictly needed that each of these faked <varclass="LITERAL">"a"</var> partitions is located at the same offset within its device,compared with other devices containing plexes of the root volume. However, it is probablya good idea to create the Vinum volumes that way so the resulting mirrored devices aresymmetric, to avoid confusion.</p><p>In order to set up these <var class="LITERAL">"a"</var> partitions, for each devicecontaining part of the root volume, the following needs to be done:</p><div class="PROCEDURE"><ol type="1"><li><p>The location (offset from the beginning of the device) and size of this device'ssubdisk that is part of the root volume need to be examined, using the command:</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">vinum l -rv root</kbd></pre><p>Note that Vinum offsets and sizes are measured in bytes. They must be divided by 512in order to obtain the block numbers that are to be used in the <ttclass="COMMAND">disklabel</tt> command.</p></li><li><p>Run the command:</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">disklabel -e <varclass="REPLACEABLE">devname</var></kbd></pre><p>for each device that participates in the root volume. <varclass="REPLACEABLE">devname</var> must be either the name of the disk (like <ttclass="DEVICENAME">da0</tt>) for disks without a slice (aka. fdisk) table, or the name ofthe slice (like <tt class="DEVICENAME">ad0s1</tt>).</p><p>If there is already an <var class="LITERAL">"a"</var> partition on the device(presumably, containing a pre-Vinum root filesystem), it should be renamed to somethingelse, so it remains accessible (just in case), but will no longer be used by default tobootstrap the system. Note that active partitions (like a root filesystem currentlymounted) cannot be renamed, so this must be executed either when being booted from a``Fixit'' medium, or in a two-step process, where (in a mirrored situation) the disk thathas not been currently booted is being manipulated first.</p><p>Then, the offset the Vinum partition on this device (if any) must be added to theoffset of the respective root volume subdisk on this device. The resulting value willbecome the <var class="LITERAL">"offset"</var> value for the new <varclass="LITERAL">"a"</var> partition. The <var class="LITERAL">"size"</var> value for thispartition can be taken verbatim from the calculation above. The <varclass="LITERAL">"fstype"</var> should be <var class="LITERAL">4.2BSD</var>. The <varclass="LITERAL">"fsize"</var>, <var class="LITERAL">"bsize"</var>, and <varclass="LITERAL">"cpg"</var> values should best be chosen to match the actual filesystem,though they are fairly unimportant within this context.</p><p>That way, a new <var class="LITERAL">"a"</var> partition will be established thatoverlaps the Vinum partition on this device. Note that the <ttclass="COMMAND">disklabel</tt> will only allow for this overlap if the Vinum partitionhas properly been marked using the <var class="LITERAL">"vinum"</var> fstype.</p></li><li><p>That's all! A faked <var class="LITERAL">"a"</var> partition does exist now on eachdevice that has one replica of the root volume. It is highly recommendable to verify theresult again, using a command like:</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">fsck -n /dev/<varclass="REPLACEABLE">devname</var>a</kbd></pre></li></ol></div><p>It should be remembered that all files containing control information must be relativeto the root filesystem in the Vinum volume which, when setting up a new Vinum rootvolume, might not match the root filesystem that is currently active. So in particular,the files <tt class="FILENAME">/etc/fstab</tt> and <ttclass="FILENAME">/boot/loader.conf</tt> need to be taken care of.</p><p>At next reboot, the bootstrap should figure out the appropriate control informationfrom the new Vinum-based root filesystem, and act accordingly. At the end of the kernelinitialization process, after all devices have been announced, the prominent notice thatshows the success of this setup is a message like:</p>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -