📄 disks-virtual.html
字号:
<var class="OPTION">-r</var> should be removed. For more information, please refer to the<a href="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><p>The utility <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=mdconfig&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">mdconfig</span>(8)</span></a> is veryuseful, however it asks many command lines to create a file-backed file system.FreeBSD 5.0 also comes with a tool called <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=mdmfs&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">mdmfs</span>(8)</span></a>, this programconfigures a <a href="http://www.FreeBSD.org/cgi/man.cgi?query=md&sektion=4"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">md</span>(4)</span></a> disk using <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=mdconfig&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">mdconfig</span>(8)</span></a>, puts aUFS file system on it using <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=newfs&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">newfs</span>(8)</span></a>, and mountsit using <a href="http://www.FreeBSD.org/cgi/man.cgi?query=mount&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">mount</span>(8)</span></a>. For example,if you want to create and mount the same file system image as above, simply type thefollowing:</p><div class="EXAMPLE"><a id="AEN25304" name="AEN25304"></a><p><b>Example 16-8. Configure and Mount a File-Backed Disk with <ttclass="COMMAND">mdmfs</tt></b></p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">dd if=/dev/zero of=<varclass="REPLACEABLE">newimage</var> bs=1k count=<var class="REPLACEABLE">5</var>k</kbd>5120+0 records in5120+0 records out<samp class="PROMPT">#</samp> <kbd class="USERINPUT">mdmfs -F <varclass="REPLACEABLE">newimage</var> -s <var class="REPLACEABLE">5</var>m md<varclass="REPLACEABLE">0</var> <var class="REPLACEABLE">/mnt</var></kbd><samp class="PROMPT">#</samp> <kbd class="USERINPUT">df <varclass="REPLACEABLE">/mnt</var></kbd>Filesystem 1K-blocks Used Avail Capacity Mounted on/dev/md0 4846 2 4458 0% /mnt</pre></div><p>If you use the option <var class="OPTION">md</var> without unit number, <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=mdmfs&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">mdmfs</span>(8)</span></a> will use <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=md&sektion=4"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">md</span>(4)</span></a> auto-unitfeature to automatically select an unused device. For more details about <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=mdmfs&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">mdmfs</span>(8)</span></a>, please referto the manual page.</p></div><div class="SECT2"><h2 class="SECT2"><a id="DISKS-MD-FREEBSD4" name="DISKS-MD-FREEBSD4">16.12.3 Memory-BasedFile System under FreeBSD 4.X</a></h2><p>The <a href="http://www.FreeBSD.org/cgi/man.cgi?query=md&sektion=4"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">md</span>(4)</span></a> driver is asimple, efficient means to create memory file systems under FreeBSD 4.X. <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=malloc&sektion=9"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">malloc</span>(9)</span></a> is used toallocate the memory.</p><p>Simply take a file system you have prepared with, for example, <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=vnconfig&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">vnconfig</span>(8)</span></a>, and:</p><div class="EXAMPLE"><a id="AEN25348" name="AEN25348"></a><p><b>Example 16-9. md Memory Disk under FreeBSD 4.X</b></p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">dd if=<varclass="REPLACEABLE">newimage</var> of=/dev/md<var class="REPLACEABLE">0</var></kbd>5120+0 records in5120+0 records out<samp class="PROMPT">#</samp> <kbd class="USERINPUT">mount /dev/md<varclass="REPLACEABLE">0c</var> <var class="REPLACEABLE">/mnt</var></kbd><samp class="PROMPT">#</samp> <kbd class="USERINPUT">df <varclass="REPLACEABLE">/mnt</var></kbd>Filesystem 1K-blocks Used Avail Capacity Mounted on/dev/md0c 4927 1 4532 0% /mnt</pre></div><p>For more details, please refer to <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=md&sektion=4"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">md</span>(4)</span></a> manual page.</p></div><div class="SECT2"><h2 class="SECT2"><a id="DISKS-MD-FREEBSD5" name="DISKS-MD-FREEBSD5">16.12.4 Memory-BasedFile System under FreeBSD 5.X</a></h2><p>The same tools are used for memory-based and file-backed file systems: <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=mdconfig&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">mdconfig</span>(8)</span></a> or <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=mdmfs&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">mdmfs</span>(8)</span></a>. The storagefor memory-based file system is allocated with <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=malloc&sektion=9"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">malloc</span>(9)</span></a>.</p><div class="EXAMPLE"><a id="AEN25381" name="AEN25381"></a><p><b>Example 16-10. Creating a New Memory-Based Disk with <ttclass="COMMAND">mdconfig</tt></b></p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">mdconfig -a -t malloc -s <varclass="REPLACEABLE">5</var>m -u <var class="REPLACEABLE">1</var></kbd><samp class="PROMPT">#</samp> <kbd class="USERINPUT">newfs -U md<varclass="REPLACEABLE">1</var></kbd>/dev/md1: 5.0MB (10240 sectors) block size 16384, fragment size 2048 using 4 cylinder groups of 1.27MB, 81 blks, 256 inodes. with soft updatessuper-block backups (for fsck -b #) at: 32, 2624, 5216, 7808<samp class="PROMPT">#</samp> <kbd class="USERINPUT">mount /dev/md<varclass="REPLACEABLE">1</var> <var class="REPLACEABLE">/mnt</var></kbd><samp class="PROMPT">#</samp> <kbd class="USERINPUT">df <varclass="REPLACEABLE">/mnt</var></kbd>Filesystem 1K-blocks Used Avail Capacity Mounted on/dev/md1 4846 2 4458 0% /mnt</pre></div><div class="EXAMPLE"><a id="AEN25399" name="AEN25399"></a><p><b>Example 16-11. Creating a New Memory-Based Disk with <ttclass="COMMAND">mdmfs</tt></b></p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">mdmfs -M -s <varclass="REPLACEABLE">5</var>m md<var class="REPLACEABLE">2</var> <varclass="REPLACEABLE">/mnt</var></kbd><samp class="PROMPT">#</samp> <kbd class="USERINPUT">df <varclass="REPLACEABLE">/mnt</var></kbd>Filesystem 1K-blocks Used Avail Capacity Mounted on/dev/md2 4846 2 4458 0% /mnt</pre></div><p>Instead of using a <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=malloc&sektion=9"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">malloc</span>(9)</span></a> backed filesystem, it is possible to use swap, for that just replace <varclass="OPTION">malloc</var> with <var class="OPTION">swap</var> in the command line of <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=mdconfig&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">mdconfig</span>(8)</span></a>. The <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=mdmfs&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">mdmfs</span>(8)</span></a> utility bydefault (without <var class="OPTION">-M</var>) creates a swap-based disk. For moredetails, please refer to <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=mdconfig&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">mdconfig</span>(8)</span></a> and <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=mdmfs&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">mdmfs</span>(8)</span></a> manualpages.</p></div><div class="SECT2"><h2 class="SECT2"><a id="AEN25430" name="AEN25430">16.12.5 Detaching a Memory Disk fromthe System</a></h2><p>When a memory-based or file-based file system is not used, you should release allresources to the system. The first thing to do is to unmount the file system, then use <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=mdconfig&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">mdconfig</span>(8)</span></a> to detachthe disk from the system and release the resources.</p><p>For example to detach and free all resources used by <ttclass="FILENAME">/dev/md4</tt>:</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">mdconfig -d -u <varclass="REPLACEABLE">4</var></kbd></pre><p>It is possible to list information about configured <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=md&sektion=4"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">md</span>(4)</span></a> devices in usingthe command <tt class="COMMAND">mdconfig -l</tt>.</p><p>For FreeBSD 4.X, <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=vnconfig&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">vnconfig</span>(8)</span></a> is used todetach the device. For example to detach and free all resources used by <ttclass="FILENAME">/dev/vn4</tt>:</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">vnconfig -u vn<varclass="REPLACEABLE">4</var></kbd></pre></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="backup-basics.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="snapshots.html"accesskey="N">Next</a></td></tr><tr><td width="33%" align="left" valign="top">Backup Basics</td><td width="34%" align="center" valign="top"><a href="disks.html"accesskey="U">Up</a></td><td width="33%" align="right" valign="top">File System Snapshots</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 <<ahref="mailto:questions@FreeBSD.org">questions@FreeBSD.org</a>>.<br />For questions about this documentation, e-mail <<ahref="mailto:doc@FreeBSD.org">doc@FreeBSD.org</a>>.</small></p></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -