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

📄 disks-virtual.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>Network, Memory, and File-Backed File Systems</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="Backup Basics" href="backup-basics.html" /><link rel="NEXT" title="File System Snapshots" href="snapshots.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="backup-basics.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="snapshots.html"accesskey="N">Next</a></td></tr></table><hr align="LEFT" width="100%" /></div><div class="SECT1"><h1 class="SECT1"><a id="DISKS-VIRTUAL" name="DISKS-VIRTUAL">16.12 Network, Memory, andFile-Backed File Systems</a></h1><i class="AUTHORGROUP"><span class="CONTRIB">Reorganized and enhanced by</span> MarcFonvieille.</i> <p>Aside from the disks you physically insert into your computer: floppies, CDs, harddrives, and so forth; other forms of disks are understood by FreeBSD - the <iclass="FIRSTTERM">virtual disks</i>.</p><p>These include network file systems such as the <a href="network-nfs.html">Network FileSystem</a> and Coda, memory-based file systems and file-backed file systems.</p><p>According to the FreeBSD version you run, you will have to use different tools forcreation and use of file-backed and memory-based file systems.</p><div class="NOTE"><blockquote class="NOTE"><p><b>Note:</b> The FreeBSD&nbsp;4.X users will have to use <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=MAKEDEV&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">MAKEDEV</span>(8)</span></a> to createthe required devices. FreeBSD&nbsp;5.0 and later use <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=devfs&sektion=5&manpath=FreeBSD+6-current"><span class="CITEREFENTRY"><span class="REFENTRYTITLE">devfs</span>(5)</span></a> toallocate device nodes transparently for the user.</p></blockquote></div><div class="SECT2"><h2 class="SECT2"><a id="DISKS-VNCONFIG" name="DISKS-VNCONFIG">16.12.1 File-Backed FileSystem under FreeBSD&nbsp;4.X</a></h2><p>The utility <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=vnconfig&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">vnconfig</span>(8)</span></a> configuresand enables vnode pseudo-disk devices. A <i class="FIRSTTERM">vnode</i> is arepresentation of a file, and is the focus of file activity. This means that <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=vnconfig&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">vnconfig</span>(8)</span></a> uses filesto create and operate a file system. One possible use is the mounting of floppy or CDimages kept in files.</p><p>To use <a href="http://www.FreeBSD.org/cgi/man.cgi?query=vnconfig&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">vnconfig</span>(8)</span></a>, you need<a href="http://www.FreeBSD.org/cgi/man.cgi?query=vn&sektion=4"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">vn</span>(4)</span></a> support in yourkernel configuration file:</p><pre class="PROGRAMLISTING">pseudo-device vn</pre><p>To mount an existing file system image:</p><div class="EXAMPLE"><a id="AEN25150" name="AEN25150"></a><p><b>Example 16-4. Using vnconfig to Mount an Existing File System Image underFreeBSD&nbsp;4.X</b></p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">vnconfig vn<varclass="REPLACEABLE">0</var> <var class="REPLACEABLE">diskimage</var></kbd><samp class="PROMPT">#</samp> <kbd class="USERINPUT">mount /dev/vn<varclass="REPLACEABLE">0</var>c <var class="REPLACEABLE">/mnt</var></kbd></pre></div><p>To create a new file system image with <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=vnconfig&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">vnconfig</span>(8)</span></a>:</p><div class="EXAMPLE"><a id="AEN25165" name="AEN25165"></a><p><b>Example 16-5. Creating a New File-Backed Disk with <ttclass="COMMAND">vnconfig</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">vnconfig -s labels -c vn<varclass="REPLACEABLE">0</var> <var class="REPLACEABLE">newimage</var></kbd><samp class="PROMPT">#</samp> <kbd class="USERINPUT">disklabel -r -w vn<varclass="REPLACEABLE">0</var> auto</kbd><samp class="PROMPT">#</samp> <kbd class="USERINPUT">newfs vn<varclass="REPLACEABLE">0</var>c</kbd>Warning: 2048 sector(s) in last cylinder unallocated/dev/vn0c:     10240 sectors in 3 cylinders of 1 tracks, 4096 sectors        5.0MB in 1 cyl groups (16 c/g, 32.00MB/g, 1280 i/g)super-block backups (for fsck -b #) at: 32<samp class="PROMPT">#</samp> <kbd class="USERINPUT">mount /dev/vn<varclass="REPLACEABLE">0</var>c <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/vn0c        4927        1     4532     0%    /mnt</pre></div></div><div class="SECT2"><h2 class="SECT2"><a id="DISKS-MDCONFIG" name="DISKS-MDCONFIG">16.12.2 File-Backed FileSystem under FreeBSD&nbsp;5.X</a></h2><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 used toconfigure and enable memory disks, <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=md&sektion=4"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">md</span>(4)</span></a>, underFreeBSD&nbsp;5.X. To use <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=mdconfig&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">mdconfig</span>(8)</span></a>, you haveto load <a href="http://www.FreeBSD.org/cgi/man.cgi?query=md&sektion=4"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">md</span>(4)</span></a> module or to addthe support in your kernel configuration file:</p><pre class="PROGRAMLISTING">device md</pre><p>The <a href="http://www.FreeBSD.org/cgi/man.cgi?query=mdconfig&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">mdconfig</span>(8)</span></a> commandsupports three kinds of memory backed virtual disks: memory disks allocated with <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=malloc&sektion=9"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">malloc</span>(9)</span></a>, memorydisks using a file or swap space as backing. One possible use is the mounting of floppyor CD images kept in files.</p><p>To mount an existing file system image:</p><div class="EXAMPLE"><a id="AEN25217" name="AEN25217"></a><p><b>Example 16-6. Using <tt class="COMMAND">mdconfig</tt> to Mount an Existing FileSystem Image under FreeBSD&nbsp;5.X</b></p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">mdconfig -a -t vnode -f <varclass="REPLACEABLE">diskimage</var> -u <var class="REPLACEABLE">0</var></kbd><samp class="PROMPT">#</samp> <kbd class="USERINPUT">mount /dev/md<varclass="REPLACEABLE">0</var> <var class="REPLACEABLE">/mnt</var></kbd></pre></div><p>To create a new file system image with <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=mdconfig&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">mdconfig</span>(8)</span></a>:</p><div class="EXAMPLE"><a id="AEN25233" name="AEN25233"></a><p><b>Example 16-7. Creating a New File-Backed Disk with <ttclass="COMMAND">mdconfig</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">mdconfig -a -t vnode -f <varclass="REPLACEABLE">newimage</var> -u <var class="REPLACEABLE">0</var></kbd><samp class="PROMPT">#</samp> <kbd class="USERINPUT">disklabel -r -w md<varclass="REPLACEABLE">0</var> auto</kbd><samp class="PROMPT">#</samp> <kbd class="USERINPUT">newfs md<varclass="REPLACEABLE">0</var>c</kbd>/dev/md0c: 5.0MB (10240 sectors) block size 16384, fragment size 2048    using 4 cylinder groups of 1.27MB, 81 blks, 256 inodes.super-block backups (for fsck -b #) at: 32, 2624, 5216, 7808<samp class="PROMPT">#</samp> <kbd class="USERINPUT">mount /dev/md<varclass="REPLACEABLE">0</var>c <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        4846        2     4458     0%    /mnt</pre></div><p>If you do not specify the unit number with the <var class="OPTION">-u</var> option, <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=mdconfig&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">mdconfig</span>(8)</span></a> will usethe <a href="http://www.FreeBSD.org/cgi/man.cgi?query=md&sektion=4"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">md</span>(4)</span></a> automaticallocation to select an unused device. The name of the allocated unit will be output onstdout like <tt class="DEVICENAME">md4</tt>. For more details about <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=mdconfig&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">mdconfig</span>(8)</span></a>, pleaserefer to the manual page.</p><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 example above the option

⌨️ 快捷键说明

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