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

📄 disks-adding.html

📁 FreeBSD操作系统的详细使用手册
💻 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>Adding Disks</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="Storage" href="disks.html" /><link rel="PREVIOUS" title="Device Names" href="disks-naming.html" /><link rel="NEXT" title="RAID" href="raid.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="disks-naming.html"accesskey="P">Prev</a></td><td width="80%" align="center" valign="bottom">Chapter 16 Storage</td><td width="10%" align="right" valign="bottom"><a href="raid.html"accesskey="N">Next</a></td></tr></table><hr align="LEFT" width="100%" /></div><div class="SECT1"><h1 class="SECT1"><a id="DISKS-ADDING" name="DISKS-ADDING">16.3 Adding Disks</a></h1><i class="AUTHORGROUP"><span class="CONTRIB">Originally contributed by</span> DavidO'Brien.</i> <p>Lets say we want to add a new SCSI disk to a machine that currently only has a singledrive. First turn off the computer and install the drive in the computer following theinstructions of the computer, controller, and drive manufacturer. Due to the widevariations of procedures to do this, the details are beyond the scope of thisdocument.</p><p>Login as user <tt class="USERNAME">root</tt>. After you have installed the drive,inspect <tt class="FILENAME">/var/run/dmesg.boot</tt> to ensure the new disk was found.Continuing with our example, the newly added drive will be <ttclass="DEVICENAME">da1</tt> and we want to mount it on <tt class="FILENAME">/1</tt> (ifyou are adding an IDE drive, the device name will be <tt class="DEVICENAME">wd1</tt> inpre-4.0 systems, or <tt class="DEVICENAME">ad1</tt> in most 4.X systems).</p><p>Because FreeBSD runs on IBM-PC compatible computers, it must take into account the PCBIOS partitions. These are different from the traditional BSD partitions. A PC disk hasup to four BIOS partition entries. If the disk is going to be truly dedicated to FreeBSD,you can use the <span class="emphasis"><i class="EMPHASIS">dedicated</i></span> mode.Otherwise, FreeBSD will have to live within one of the PC BIOS partitions. FreeBSD callsthe PC BIOS partitions <span class="emphasis"><i class="EMPHASIS">slices</i></span> so asnot to confuse them with traditional BSD partitions. You may also use slices on a diskthat is dedicated to FreeBSD, but used in a computer that also has another operatingsystem installed. This is to not confuse the <tt class="COMMAND">fdisk</tt> utility ofthe other operating system.</p><p>In the slice case the drive will be added as <tt class="FILENAME">/dev/da1s1e</tt>.This is read as: SCSI disk, unit number 1 (second SCSI disk), slice 1 (PC BIOS partition1), and <tt class="FILENAME">e</tt> BSD partition. In the dedicated case, the drive willbe added simply as <tt class="FILENAME">/dev/da1e</tt>.</p><p>Due to the use of 32-bit integers to store the number of sectors <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=bsdlabel&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">bsdlabel</span>(8)</span></a> (called <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=disklabel&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">disklabel</span>(8)</span></a> inFreeBSD&nbsp;4.X) is limited to 2^32-1 sectors per disk or 2TB in most cases. The <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=fdisk&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">fdisk</span>(8)</span></a> format allowsa starting sector of no more than 2^32-1 and a length of no more than 2^32-1, limitingpartitions to 2TB and disks to 4TB in most cases. The <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=sunlabel&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">sunlabel</span>(8)</span></a> format islimited to 2^32-1 sectors per partition and 8 partitions for a total of 16TB. For largerdisks, <a href="http://www.FreeBSD.org/cgi/man.cgi?query=gpt&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">gpt</span>(8)</span></a> partitions maybe used.</p><div class="SECT2"><h2 class="SECT2"><a id="AEN23365" name="AEN23365">16.3.1 Using <spanclass="CITEREFENTRY">sysinstall(8)</span></a></h2><div class="PROCEDURE"><ol type="1"><li><p><b>Navigating Sysinstall</b></p><p>You may use <tt class="COMMAND">/stand/sysinstall</tt> to partition and label a newdisk using its easy to use menus. Either login as user <tt class="USERNAME">root</tt> oruse the <tt class="COMMAND">su</tt> command. Run <ttclass="COMMAND">/stand/sysinstall</tt> and enter the <var class="LITERAL">Configure</var>menu. Within the <var class="LITERAL">FreeBSD Configuration Menu</var>, scroll down andselect the <var class="LITERAL">Fdisk</var> option.</p></li><li><p><b>fdisk Partition Editor</b></p><p>Once inside <b class="APPLICATION">fdisk</b>, we can type <kbdclass="USERINPUT">A</kbd> to use the entire disk for FreeBSD. When asked if you want to``remain cooperative with any future possible operating systems'', answer <varclass="LITERAL">YES</var>. Write the changes to the disk using <kbdclass="USERINPUT">W</kbd>. Now exit the FDISK editor by typing <kbdclass="USERINPUT">q</kbd>. Next you will be asked about the Master Boot Record. Since youare adding a disk to an already running system, choose <varclass="LITERAL">None</var>.</p></li><li><p><b>Disk Label Editor</b></p><p>Next, you need to exit <b class="APPLICATION">sysinstall</b> and start it again.Follow the directions above, although this time choose the <varclass="LITERAL">Label</var> option. This will enter the <var class="LITERAL">Disk LabelEditor</var>. This is where you will create the traditional BSD partitions. A disk canhave up to eight partitions, labeled <var class="LITERAL">a-h</var>. A few of thepartition labels have special uses. The <var class="LITERAL">a</var> partition is usedfor the root partition (<tt class="FILENAME">/</tt>). Thus only your system disk (e.g,the disk you boot from) should have an <var class="LITERAL">a</var> partition. The <varclass="LITERAL">b</var> partition is used for swap partitions, and you may have manydisks with swap partitions. The <var class="LITERAL">c</var> partition addresses theentire disk in dedicated mode, or the entire FreeBSD slice in slice mode. The otherpartitions are for general use.</p><p><b class="APPLICATION">sysinstall</b>'s Label editor favors the <varclass="LITERAL">e</var> partition for non-root, non-swap partitions. Within the Labeleditor, create a single file system by typing <kbd class="USERINPUT">C</kbd>. Whenprompted if this will be a FS (file system) or swap, choose <var class="LITERAL">FS</var>and type in a mount point (e.g, <tt class="FILENAME">/mnt</tt>). When adding a disk inpost-install mode, <b class="APPLICATION">sysinstall</b> will not create entries in <ttclass="FILENAME">/etc/fstab</tt> for you, so the mount point you specify is notimportant.</p><p>You are now ready to write the new label to the disk and create a file system on it.Do this by typing <kbd class="USERINPUT">W</kbd>. Ignore any errors from <bclass="APPLICATION">sysinstall</b> that it could not mount the new partition. Exit theLabel Editor and <b class="APPLICATION">sysinstall</b> completely.</p></li><li><p><b>Finish</b></p><p>The last step is to edit <tt class="FILENAME">/etc/fstab</tt> to add an entry for yournew disk.</p></li></ol></div></div><div class="SECT2"><h2 class="SECT2"><a id="AEN23429" name="AEN23429">16.3.2 Using Command LineUtilities</a></h2><div class="SECT3"><h3 class="SECT3"><a id="AEN23431" name="AEN23431">16.3.2.1 Using Slices</a></h3><p>This setup will allow your disk to work correctly with other operating systems thatmight be installed on your computer and will not confuse other operating systems' <ttclass="COMMAND">fdisk</tt> utilities. It is recommended to use this method for new diskinstalls. Only use <var class="LITERAL">dedicated</var> mode if you have a good reason todo so!</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbdclass="USERINPUT">dd if=/dev/zero of=/dev/da1 bs=1k count=1</kbd><samp class="PROMPT">#</samp> <kbdclass="USERINPUT">fdisk -BI da1</kbd> #Initialize your new disk<samp class="PROMPT">#</samp> <kbdclass="USERINPUT">disklabel -B -w -r da1s1 auto</kbd> #Label it.<samp class="PROMPT">#</samp> <kbdclass="USERINPUT">disklabel -e da1s1</kbd> # Edit the disklabel just created and add any partitions.<samp class="PROMPT">#</samp> <kbd class="USERINPUT">mkdir -p /1</kbd><samp class="PROMPT">#</samp> <kbdclass="USERINPUT">newfs /dev/da1s1e</kbd> # Repeat this for every partition you created.<samp class="PROMPT">#</samp> <kbdclass="USERINPUT">mount /dev/da1s1e /1</kbd> # Mount the partition(s)<samp class="PROMPT">#</samp> <kbdclass="USERINPUT">vi /etc/fstab</kbd> # Add the appropriate entry/entries to your <ttclass="FILENAME">/etc/fstab</tt>.</pre><p>If you have an IDE disk, substitute <tt class="FILENAME">ad</tt> for <ttclass="FILENAME">da</tt>. On pre-4.X systems use <tt class="FILENAME">wd</tt>.</p></div><div class="SECT3"><h3 class="SECT3"><a id="AEN23458" name="AEN23458">16.3.2.2 Dedicated</a></h3><p>If you will not be sharing the new drive with another operating system, you may usethe <var class="LITERAL">dedicated</var> mode. Remember this mode can confuse Microsoftoperating systems; however, no damage will be done by them. IBM's <spanclass="TRADEMARK">OS/2</span>&reg; however, will ``appropriate'' any partition it findswhich it does not understand.</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbdclass="USERINPUT">dd if=/dev/zero of=/dev/da1 bs=1k count=1</kbd><samp class="PROMPT">#</samp> <kbd class="USERINPUT">disklabel -Brw da1 auto</kbd><samp class="PROMPT">#</samp> <kbdclass="USERINPUT">disklabel -e da1</kbd>               # create the `e' partition<samp class="PROMPT">#</samp> <kbd class="USERINPUT">newfs -d0 /dev/da1e</kbd><samp class="PROMPT">#</samp> <kbd class="USERINPUT">mkdir -p /1</kbd><samp class="PROMPT">#</samp> <kbdclass="USERINPUT">vi /etc/fstab</kbd>               # add an entry for /dev/da1e<samp class="PROMPT">#</samp> <kbd class="USERINPUT">mount /1</kbd></pre><p>An alternate method is:</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbdclass="USERINPUT">dd if=/dev/zero of=/dev/da1 count=2</kbd><samp class="PROMPT">#</samp> <kbdclass="USERINPUT">disklabel /dev/da1 | disklabel -BrR da1 /dev/stdin</kbd><samp class="PROMPT">#</samp> <kbd class="USERINPUT">newfs /dev/da1e</kbd><samp class="PROMPT">#</samp> <kbd class="USERINPUT">mkdir -p /1</kbd><samp class="PROMPT">#</samp> <kbdclass="USERINPUT">vi /etc/fstab</kbd>                   # add an entry for /dev/da1e<samp class="PROMPT">#</samp> <kbd class="USERINPUT">mount /1</kbd></pre><div class="NOTE"><blockquote class="NOTE"><p><b>Note:</b> Since FreeBSD&nbsp;5.1-RELEASE, the <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=bsdlabel&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">bsdlabel</span>(8)</span></a> utilityreplaces the old <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=disklabel&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">disklabel</span>(8)</span></a> program.With <a href="http://www.FreeBSD.org/cgi/man.cgi?query=bsdlabel&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">bsdlabel</span>(8)</span></a> a numberof obsolete options and parameters have been retired; in the examples above the option<var class="OPTION">-r</var> should be removed with <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=bsdlabel&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">bsdlabel</span>(8)</span></a>. For moreinformation, please refer to the <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=bsdlabel&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">bsdlabel</span>(8)</span></a> manualpage.</p></blockquote></div></div></div></div><div class="NAVFOOTER"><hr align="LEFT" width="100%" /><table summary="Footer navigation table" width="100%" border="0" cellpadding="0"cellspacing="0"><tr><td width="33%" align="left" valign="top"><a href="disks-naming.html"accesskey="P">Prev</a></td><td width="34%" align="center" valign="top"><a href="index.html"accesskey="H">Home</a></td><td width="33%" align="right" valign="top"><a href="raid.html"accesskey="N">Next</a></td></tr><tr><td width="33%" align="left" valign="top">Device Names</td><td width="34%" align="center" valign="top"><a href="disks.html"accesskey="U">Up</a></td><td width="33%" align="right" valign="top">RAID</td></tr></table></div><p align="center"><small>This, and other documents, can be downloaded from <ahref="ftp://ftp.FreeBSD.org/pub/FreeBSD/doc/">ftp://ftp.FreeBSD.org/pub/FreeBSD/doc/</a>.</small></p><p align="center"><small>For questions about FreeBSD, read the <ahref="http://www.FreeBSD.org/docs.html">documentation</a> before contacting &#60;<ahref="mailto:questions@FreeBSD.org">questions@FreeBSD.org</a>&#62;.<br />For questions about this documentation, e-mail &#60;<ahref="mailto:doc@FreeBSD.org">doc@FreeBSD.org</a>&#62;.</small></p></body></html>

⌨️ 快捷键说明

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