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

📄 snapshots.html

📁 这是很好的学习嵌入式LINUX的文章
💻 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>File System Snapshots</title><meta name="GENERATOR" content="Modular DocBook HTML Stylesheet Version 1.7" /><link rel="HOME" title="FreeBSD 使用手册" href="index.html" /><link rel="UP" title="存储" href="disks.html" /><link rel="PREVIOUS" title="Network, Memory, and File-Backed File Systems"href="disks-virtual.html" /><link rel="NEXT" title="文件系统配额" href="quotas.html" /><link rel="STYLESHEET" type="text/css" href="docbook.css" /><meta http-equiv="Content-Type" content="text/html; charset=GB2312" /></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 使用手册</th></tr><tr><td width="10%" align="left" valign="bottom"><a href="disks-virtual.html"accesskey="P">后退</a></td><td width="80%" align="center" valign="bottom">章 16. 存储</td><td width="10%" align="right" valign="bottom"><a href="quotas.html"accesskey="N">前进</a></td></tr></table><hr align="LEFT" width="100%" /></div><div class="SECT1"><h1 class="SECT1"><a id="SNAPSHOTS" name="SNAPSHOTS">16.13. File SystemSnapshots</a></h1><i class="AUTHORGROUP"><span class="CONTRIB">Contributed by</span> Tom Rhodes.</i> <p>FreeBSD&nbsp;5.0 offers a new feature in conjunction with <ahref="configtuning-disk.html#SOFT-UPDATES">Soft Updates</a>: File system snapshots.</p><p>Snapshots allow a user to create images of specified file systems, and treat them as afile. Snapshot files must be created in the file system that the action is performed on,and a user may create no more than 20 snapshots per file system. Active snapshots arerecorded in the superblock so they are persistent across unmount and remount operationsalong with system reboots. When a snapshot is no longer required, it can be removed withthe standard <span class="CITEREFENTRY"><span class="REFENTRYTITLE">rm</span>(1)</span>command. Snapshots may be removed in any order, however all the used space may not beacquired because another snapshot will possibly claim some of the released blocks.</p><p>During initial creation, the <var class="OPTION">schg</var> flag (see the <spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">chflags</span>(1)</span> manual page) isset to ensure that even <tt class="USERNAME">root</tt> cannot write to the snapshot. The<span class="CITEREFENTRY"><span class="REFENTRYTITLE">unlink</span>(1)</span> commandmakes an exception for snapshot files since it allows them to be removed with the <varclass="OPTION">schg</var> flag set, so it is not necessary to clear the <varclass="OPTION">schg</var> flag before removing a snapshot file.</p><p>Snapshots are created with the <span class="CITEREFENTRY"><spanclass="REFENTRYTITLE">mount</span>(8)</span> command. To place a snapshot of <ttclass="FILENAME">/var</tt> in the file <tt class="FILENAME">/var/snapshot/snap</tt> usethe following command:</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbdclass="USERINPUT">mount -u -o snapshot /var/snapshot/snap /var</kbd></pre><p>Alternatively, you can use <span class="CITEREFENTRY"><spanclass="REFENTRYTITLE">mksnap_ffs</span>(8)</span> to create a snapshot:</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbdclass="USERINPUT">mksnap_ffs /var /var/snapshot/snap</kbd></pre><p>Once a snapshot has been created, it has several uses:</p><ul><li><p>Some administrators will use a snapshot file for backup purposes, because the snapshotcan be transfered to CDs or tape.</p></li><li><p>File integrity, <span class="CITEREFENTRY"><spanclass="REFENTRYTITLE">fsck</span>(8)</span> may be ran on the snapshot. Assuming that thefile system was clean when it was mounted, you should always get a clean (and unchanging)result. This is essentially what the background <span class="CITEREFENTRY"><spanclass="REFENTRYTITLE">fsck</span>(8)</span> process does.</p></li><li><p>Run the <span class="CITEREFENTRY"><span class="REFENTRYTITLE">dump</span>(8)</span>utility on the snapshot. A dump will be returned that is consistent with the file systemand the timestamp of the snapshot. <span class="CITEREFENTRY"><spanclass="REFENTRYTITLE">dump</span>(8)</span> can also take a snapshot, create a dump imageand then remove the snapshot in one command using the <var class="OPTION">-L</var>flag.</p></li><li><p><span class="CITEREFENTRY"><span class="REFENTRYTITLE">mount</span>(8)</span> thesnapshot as a frozen image of the file system. To <span class="CITEREFENTRY"><spanclass="REFENTRYTITLE">mount</span>(8)</span> the snapshot <ttclass="FILENAME">/var/snapshot/snap</tt> run:</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbdclass="USERINPUT">mdconfig -a -t vnode -f /var/snapshot/snap -u 4</kbd><samp class="PROMPT">#</samp> <kbd class="USERINPUT">mount -r /dev/md4 /mnt</kbd></pre></li></ul><p>You can now walk the hierarchy of your frozen <tt class="FILENAME">/var</tt> filesystem mounted at <tt class="FILENAME">/mnt</tt>. Everything will be in the same state itwas during the snapshot creation time. The only exception is that any earlier snapshotswill appear as zero length files. When the use of a snapshot has delimited, it can beunmounted with:</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">umount /mnt</kbd><samp class="PROMPT">#</samp> <kbd class="USERINPUT">mdconfig -d -u 4</kbd></pre><p>For more information about <var class="OPTION">softupdates</var> and file systemsnapshots, including technical papers, you can visit Marshall Kirk McKusick's website at<a href="http://www.mckusick.com/" target="_top">http://www.mckusick.com.</a></p></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-virtual.html"accesskey="P">后退</a></td><td width="34%" align="center" valign="top"><a href="index.html"accesskey="H">起点</a></td><td width="33%" align="right" valign="top"><a href="quotas.html"accesskey="N">前进</a></td></tr><tr><td width="33%" align="left" valign="top">Network, Memory, and File-Backed FileSystems</td><td width="34%" align="center" valign="top"><a href="disks.html"accesskey="U">上一级</a></td><td width="33%" align="right" valign="top">文件系统配额</td></tr></table></div></body></html>

⌨️ 快捷键说明

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