<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh">
	<id>https://arolstar52-zhtest.hf.space/index.php?action=history&amp;feed=atom&amp;title=Dd_%28Unix%29</id>
	<title>Dd (Unix) - 版本历史</title>
	<link rel="self" type="application/atom+xml" href="https://arolstar52-zhtest.hf.space/index.php?action=history&amp;feed=atom&amp;title=Dd_%28Unix%29"/>
	<link rel="alternate" type="text/html" href="https://arolstar52-zhtest.hf.space/index.php?title=Dd_(Unix)&amp;action=history"/>
	<updated>2026-07-08T10:29:02Z</updated>
	<subtitle>在这个wiki上该页的修订历史</subtitle>
	<generator>MediaWiki 1.43.8</generator>
	<entry>
		<id>https://arolstar52-zhtest.hf.space/index.php?title=Dd_(Unix)&amp;diff=2120201&amp;oldid=prev</id>
		<title>imported&gt;InternetArchiveBot：​Reformat 1 URL (Wayback Medic 2.5)) #IABot (v2.0.9.5) (GreenC bot</title>
		<link rel="alternate" type="text/html" href="https://arolstar52-zhtest.hf.space/index.php?title=Dd_(Unix)&amp;diff=2120201&amp;oldid=prev"/>
		<updated>2023-09-16T07:14:37Z</updated>

		<summary type="html">&lt;p&gt;Reformat 1 URL (&lt;a href=&quot;/index.php?title=En:User:GreenC/WaybackMedic_2.5&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;En:User:GreenC/WaybackMedic 2.5（页面不存在）&quot;&gt;Wayback Medic 2.5&lt;/a&gt;)) #IABot (v2.0.9.5) (&lt;a href=&quot;/index.php?title=User:GreenC_bot&amp;amp;action=edit&amp;amp;redlink=1&quot; class=&quot;new&quot; title=&quot;User:GreenC bot（页面不存在）&quot;&gt;GreenC bot&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新页面&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{howto|time=2018-07-15T08:13:07+00:00}}&lt;br /&gt;
{{noteTA&lt;br /&gt;
|G1=IT&lt;br /&gt;
}}&lt;br /&gt;
{{lowercase}}&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;dd&amp;#039;&amp;#039;&amp;#039;是一个[[Unix]]和[[类Unix系统|类Unix]][[操作系统|系统]]上的命令，主要功能为转换和复制文件。&amp;lt;ref name=&amp;quot;Unix-V7-man&amp;quot;&amp;gt;{{cite web | url=http://www.orangetide.com/Unix/V7/usr/man/man1/dd.1 | title=dd man page | author=Bell Laboratories | accessdate=2009-02-25 | deadurl=yes | archiveurl=https://web.archive.org/web/20110208160759/http://www.orangetide.com/Unix/V7/usr/man/man1/dd.1 | archivedate=2011-02-08 }}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
在Unix上，硬件的设备驱动（如[[硬盘]]）和特殊[[设备文件系统|设备文件]]（如[[/dev/zero]]和[[/dev/random]]）就像普通文件一样，出现在文件系统中；只要在各自的驱动程序中实现了对应的功能，&amp;lt;code&amp;gt;dd&amp;lt;/code&amp;gt;也可以读取自和/或写入到这些文件。这样，&amp;lt;code&amp;gt;dd&amp;lt;/code&amp;gt;也可以用在备份硬件的[[引导扇区]]、取得一定数量的随机数据等任务中。&amp;lt;code&amp;gt;dd&amp;lt;/code&amp;gt;程序也可以在复制时处理数据，例如转换[[字节序]]、或在[[ASCII]]与[[EBCDIC]]编码间互换。&amp;lt;ref name=&amp;quot;tfl-dd&amp;quot;&amp;gt;{{cite web | url=http://www.codecoffee.com/tipsforlinux/articles/036.html | title=How and when to use the dd command? | author=Sam Chessman | publisher=CodeCoffee | accessdate=2008-02-19 | archive-date=2008-02-14 | archive-url=https://web.archive.org/web/20080214125249/http://www.codecoffee.com/tipsforlinux/articles/036.html | dead-url=yes }}&amp;lt;/ref&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;dd&amp;lt;/code&amp;gt;的名字可能来源于[[IBM]]的[[工作控制语言]]（JCL）中的DD语句，&amp;lt;ref name=&amp;quot;jargon-dd&amp;quot;&amp;gt;{{cite web | url=http://www.catb.org/jargon/html/D/dd.html | title=dd | author=Eric S. Raymond | accessdate=2008-02-19 | archive-date=2018-12-13 | archive-url=https://web.archive.org/web/20181213051044/https://www.catb.org/jargon/html/D/dd.html | dead-url=no }}&amp;lt;/ref&amp;gt;意为“Data Description”（数据描述）的缩写。&amp;lt;ref&amp;gt;参见旧讨论{{cite web | url=http://www.djmnet.org/lore/dd-origin.txt | title=The Unix &amp;quot;dd&amp;quot; command | publisher=alt.folklore.computers | accessdate=2011-07-05 | deadurl=yes | archiveurl=https://web.archive.org/web/20110709114314/http://www.djmnet.org/lore/dd-origin.txt | archivedate=2011-07-09 }}&amp;lt;/ref&amp;gt;该命令的语句与JCL中的相似，而与其他Unix命令较不同，因此这可能是个玩笑。&amp;lt;ref name=&amp;quot;jargon-dd&amp;quot;/&amp;gt;另一种解释是“cc”（根据命令自身的描述，为“convert and copy”（转换和复制））已经被C语言编译器（C compiler）所占。{{citation needed|date=2012年10月}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;dd&amp;lt;/code&amp;gt;命令由[[单一UNIX规范]]的一部分，[[电气电子工程师学会|IEEE]]标准1003.1-2008所规定。&lt;br /&gt;
&lt;br /&gt;
== 用法 ==&lt;br /&gt;
&amp;lt;code&amp;gt;dd&amp;lt;/code&amp;gt;的[[命令行界面|命令行]]语句与其他的Unix程序不同，因为它的命令行选项格式为&amp;lt;code&amp;gt;&amp;#039;&amp;#039;选项&amp;#039;&amp;#039;=&amp;#039;&amp;#039;值&amp;#039;&amp;#039;&amp;lt;/code&amp;gt;，而不是更标准的&amp;lt;code&amp;gt;--&amp;#039;&amp;#039;选项 值&amp;#039;&amp;#039;&amp;lt;/code&amp;gt;或&amp;lt;code&amp;gt;-&amp;#039;&amp;#039;选项&amp;#039;&amp;#039;=&amp;#039;&amp;#039;值&amp;#039;&amp;#039;&amp;lt;/code&amp;gt;。&amp;lt;code&amp;gt;dd&amp;lt;/code&amp;gt;默认从[[标准输入]]中读取，并写入到[[标准输出]]中，但可以用选项&amp;lt;code&amp;gt;if&amp;lt;/code&amp;gt;（input file，输入文件）和&amp;lt;code&amp;gt;of&amp;lt;/code&amp;gt;（output file，输出文件）改变。&lt;br /&gt;
&lt;br /&gt;
由于[[操作系统]]的不同，用法会有出入。另外，&amp;lt;code&amp;gt;dd&amp;lt;/code&amp;gt;的一些特定功能取决于计算机系统的能力，例如直接访问内存。向运行中的&amp;lt;code&amp;gt;dd&amp;lt;/code&amp;gt;进程发送[[SIGINFO]]信号（Linux上为USR1）可以使它将I/O统计信息打印到[[标准流#标准错误输出 (stderr)|标准错误]]一次，然后继续复制（注意在OS X上，信号可能导致进程终止）。&amp;lt;code&amp;gt;dd&amp;lt;/code&amp;gt;可以从键盘中读取[[标准流#标准输入 (stdin)|标准输入]]。到达[[文件结尾]]时，&amp;lt;code&amp;gt;dd&amp;lt;/code&amp;gt;将会退出。信号和EOF是由软件决定。例如，移植到[[Microsoft Windows|Windows]]的Unix工具使用不同的EOF：[[Cygwin]]使用&amp;lt;ctrl-d&amp;gt; （通常的Unix EOF），而[[MKS工具箱]]使用&amp;lt;ctrl-z&amp;gt;（通常的Windows EOF）。&lt;br /&gt;
&lt;br /&gt;
正如[[Unix哲学]]一样，&amp;lt;code&amp;gt;dd&amp;lt;/code&amp;gt;只做好一件事（并被认为做得“好”&amp;lt;!-- 当然，这取决于实现 --&amp;gt;）。与复杂的和高度抽象的实用程序不同，除了为不同的选项做底层决定，&amp;lt;code&amp;gt;dd&amp;lt;/code&amp;gt;没有其它的算法。一般在每一次运行时，会改变&amp;lt;code&amp;gt;dd&amp;lt;/code&amp;gt;的选项以分步处理一个计算机问题。&lt;br /&gt;
&lt;br /&gt;
== 输出消息 ==&lt;br /&gt;
Linux上GNU coreutils提供的变种没有描述运行结束时，&amp;lt;code&amp;gt;dd&amp;lt;/code&amp;gt;输出到标准输出消息的格式。然而，其他的实现描述了它，例如BSD上的。&lt;br /&gt;
&lt;br /&gt;
“记录读入”和“记录写出”行显示了已完整传输的块数+不完整的块数，例如物理介质以不完整的块结尾，或是一个物理错误使得一个完整的块无法被读取。&lt;br /&gt;
&lt;br /&gt;
== 块大小 ==&lt;br /&gt;
[[块 (数据存储)|块]]是衡量一次读取、写入和转换[[字节]]的单位。命令行选项可以为输入/读取（&amp;lt;code&amp;gt;ibs&amp;lt;/code&amp;gt;）和输出/写入（&amp;lt;code&amp;gt;obs&amp;lt;/code&amp;gt;）指定一个不同的块大小，尽管块大小（&amp;lt;code&amp;gt;bs&amp;lt;/code&amp;gt;）选项会覆盖&amp;lt;code&amp;gt;ibs&amp;lt;/code&amp;gt;和&amp;lt;code&amp;gt;obs&amp;lt;/code&amp;gt;选项。输入和输出的默认块大小为512字节（传统的磁盘块及POSIX规定的“块”大小）复制的&amp;lt;code&amp;gt;count&amp;lt;/code&amp;gt;选项、读取的&amp;lt;code&amp;gt;skip&amp;lt;/code&amp;gt;选项和写入的&amp;lt;code&amp;gt;seek&amp;lt;/code&amp;gt;选项都是以块为单位。转换操作也受“转换块大小”（&amp;lt;code&amp;gt;cbs&amp;lt;/code&amp;gt;）影响。&lt;br /&gt;
&lt;br /&gt;
在&amp;lt;code&amp;gt;dd&amp;lt;/code&amp;gt;的一些用途中，块大小可能会影响表现。例如，当转换硬盘中数据时，较小的块大小通常会导致更多的字节被转换。发出许多小块的读取是一种开销的浪费，且可能会对执行性能有负面影响。较大的块大小可能会提高复制速度。但是，由于要复制的字节量是由bs×count给出的，因此不可能在一次&amp;lt;code&amp;gt;dd&amp;lt;/code&amp;gt;命令中复制[[素数]]个字节，除非使用两个糟糕选项之一：&amp;lt;code&amp;gt;bs=N count=1&amp;lt;/code&amp;gt;（消耗内存）或&amp;lt;code&amp;gt;bs=1 count=N&amp;lt;/code&amp;gt;（大量读请求开销）。替代程序（见下文）允许指定字节，而不是块。在用作网络传输时，根据使用的[[网络传输协议|网络协议]]，块大小可能会与[[分组|包]]大小冲突。&lt;br /&gt;
&lt;br /&gt;
提供给块大小的值会被解释成十进制整数，也可以加入后缀指定倍数。后缀&amp;lt;code&amp;gt;w&amp;lt;/code&amp;gt;表示2倍，&amp;lt;code&amp;gt;b&amp;lt;/code&amp;gt;表示512倍，&amp;lt;code&amp;gt;k&amp;lt;/code&amp;gt;表示1024倍，&amp;lt;code&amp;gt;M&amp;lt;/code&amp;gt;表示1024 × 1024倍，&amp;lt;code&amp;gt;G&amp;lt;/code&amp;gt;表示1024 × 1024 × 1024倍，等等。另外，在块大小和计数参数中，一些实现也可以使用&amp;lt;code&amp;gt;x&amp;lt;/code&amp;gt;表示乘运算。&lt;br /&gt;
&lt;br /&gt;
例如，块大小&amp;lt;code&amp;gt;bs=2x80x18b&amp;lt;/code&amp;gt;表示2 × 80 × 18 × 512 = 1474560字节，也就是一张1440 KiB[[软盘]]的确切大小。&lt;br /&gt;
&lt;br /&gt;
== 用途 ==&lt;br /&gt;
&amp;lt;code&amp;gt;dd&amp;lt;/code&amp;gt;命令可用于各种用途。&lt;br /&gt;
&lt;br /&gt;
=== 数据转换 ===&lt;br /&gt;
&amp;lt;code&amp;gt;dd&amp;lt;/code&amp;gt;可以在文件、设备、分区和卷之间复制数据。数据可以从其中任何地方输入或输出；但输出到分区时有重要差异。此外在传输过程中，数据可以用&amp;lt;code&amp;gt;conv&amp;lt;/code&amp;gt;选项修改以适应介质。&lt;br /&gt;
&lt;br /&gt;
如果最后一个块有意外长度，试图使用&amp;lt;code&amp;gt;[[cp (Unix)|cp]]&amp;lt;/code&amp;gt;复制整个磁盘可能会忽略掉它{{Citation needed|date=2011年2月}}；然而&amp;lt;code&amp;gt;dd&amp;lt;/code&amp;gt;却可能成功。源和目标磁盘应该具有相同的大小。&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+不同情况的&amp;lt;code&amp;gt;dd&amp;lt;/code&amp;gt;格式&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dd if=/dev/sr0 of=myCD.iso bs=2048 conv=noerror,sync&amp;lt;/code&amp;gt; || 从CD-ROM中创建[[ISO]][[磁盘镜像]]。&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dd if=/dev/sda2 of=/dev/sdb2 bs=4096 conv=noerror&amp;lt;/code&amp;gt; || [[硬盘克隆|克隆]]一个[[分区]]到另一个。&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;dd if=/dev/ad0 of=/dev/ad1 bs=1M conv=noerror&amp;lt;/code&amp;gt; || 克隆硬盘“ad0”到“ad1”。&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;noerror&amp;lt;/code&amp;gt;选项意味着如果发生错误，程序也将继续运行。&amp;lt;code&amp;gt;sync&amp;lt;/code&amp;gt;选项表示填充每个块到指定字节。&lt;br /&gt;
&lt;br /&gt;
=== 备份和恢复主引导记录 ===&lt;br /&gt;
可以修复主引导记录。主引导记录可以转移到文件，或从中转移出来。&lt;br /&gt;
&lt;br /&gt;
要复制软盘的前两个扇区：&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
dd if=/dev/fd0 of=MBRboot.img bs=512 count=2&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
要创建整个x86[[主引导记录]]的镜像（包括MS-DOS[[分区表]]和MBR魔法字节）：&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
dd if=/dev/sda of=MBR.img bs=512 count=1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
要创建仅含[[主引导记录]]引导代码的镜像（不包括[[分区表]]和开机所需的魔法字节）：&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
dd if=/dev/sda of=MBR_boot.img bs=446 count=1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 数据修改 ===&lt;br /&gt;
&amp;lt;code&amp;gt;dd&amp;lt;/code&amp;gt;可以原地修改数据。&lt;br /&gt;
&lt;br /&gt;
用空字节覆盖文件的前512个字节：&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
dd if=/dev/zero of=path/to/file bs=512 count=1 conv=notrunc&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
转换选项&amp;lt;code&amp;gt;notrunc&amp;lt;/code&amp;gt;意味着不缩减输出文件，也就是说，如果输出文件已经存在，只改变指定的字节，然后退出，并保留输出文件的剩余部分。没有这个选项，&amp;lt;code&amp;gt;dd&amp;lt;/code&amp;gt;将创建一个512字节长的文件。&lt;br /&gt;
&lt;br /&gt;
在不同的分区中复制磁盘分区到磁盘映像文件中：&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
dd if=/dev/sdb2 of=partition.image bs=4096 conv=noerror&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 磁盘擦除 ===&lt;br /&gt;
{{main|数据擦除}}&lt;br /&gt;
出于安全方面的考虑，有时需要擦除丢弃的磁盘。&lt;br /&gt;
&lt;br /&gt;
检查驱动器上是否有数据，并将其输出到标准输出：&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
dd if=/dev/sda &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
用零擦除磁盘：&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
dd if=/dev/zero of=/dev/sda bs=4k&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
相较于[[#数据修改|上面]]数据修改的例子，不需要使用转换选项&amp;lt;code&amp;gt;notrunc&amp;lt;/code&amp;gt;，因为当&amp;lt;tt&amp;gt;dd&amp;lt;/tt&amp;gt;的输出文件为块设备时，它没有效果。&amp;lt;ref&amp;gt;{{cite web |url=http://stackoverflow.com/questions/20526198/why-using-conv-notrunc-when-cloning-a-disk-with-dd |title=linux - Why using conv=notrunc when cloning a disk with dd? |publisher=Stack Overflow |date=2013-12-11 |accessdate=2014-03-24 |archive-date=2014-03-24 |archive-url=https://web.archive.org/web/20140324201126/http://stackoverflow.com/questions/20526198/why-using-conv-notrunc-when-cloning-a-disk-with-dd |dead-url=no }}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;bs=4k&amp;lt;/code&amp;gt;选项使&amp;lt;code&amp;gt;dd&amp;lt;/code&amp;gt;一次读取或写入4[[千字节]]。在现代系统中，由于传输容量（如RAID系统），一个更大的块大小可能更有利。注意用随机数据填充磁盘总是比用零慢的多，因为随机数据必须先由CPU和/或[[硬件随机数发生器|HWRNG]]生成，且不同的设计有不同的性能特点。（后面PRNG的/dev/urandom可能比libc中的要慢。）在大多数较现代的磁盘中，用零擦除会使其中的数据永久丢失。&amp;lt;ref&amp;gt;{{cite journal|last1=Wright|first1=Craig|last2=Kleiman|first2=Dave|last3=Sundhar R.S.|first3=Shyaam|title=Overwriting Hard Drive Data: The Great Wiping Controversy|journal=Lecture Notes in Computer Science|year=2008|volume=5352|series=Information Systems Security|pages=243–257|doi=10.1007/978-3-540-89862-7_21|url=http://www.springerlink.com/content/408263ql11460147/|accessdate=2012-03-07|author=|archive-url=https://web.archive.org/web/20190924231659/https://rd.springer.com/chapter/10.1007/978-3-540-89862-7_21|archive-date=2019-09-24|dead-url=yes}}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
用零擦除磁盘会使它的数据无法被软件恢复。然而数据仍可能用[[数据剩磁|特殊的实验室技术]]恢复。&lt;br /&gt;
&lt;br /&gt;
[[shred (Unix)|shred]]程序提供了完成相同任务的替代方法，最后，目前许多Linux发行版还提供了一个精心制作的工具&amp;lt;tt&amp;gt;wipe&amp;lt;/tt&amp;gt;&amp;lt;ref&amp;gt;{{cite web|url=http://wipe.sf.net/ |title=Wipe: Secure File Deletion |publisher=Wipe.sf.net |date= |accessdate=2014-03-24}}&amp;lt;/ref&amp;gt;（做得“好”，如上面的Unix哲学），提供了更多方法擦除。&lt;br /&gt;
&lt;br /&gt;
=== 数据恢复 ===&lt;br /&gt;
1984年，GNU &amp;lt;code&amp;gt;dd&amp;lt;/code&amp;gt;开启了[[开源软件]]（OSS）[[数据恢复|恢复]]数据、文件、驱动器和分区的历史。&amp;lt;code&amp;gt;dd&amp;lt;/code&amp;gt;进程一次处理一个块，它的算法只是在用户界面显示运行状态。1999年10月，一个C语言的程序&amp;lt;code&amp;gt;&amp;#039;&amp;#039;[http://www.garloff.de/kurt/linux/ddrescue/ dd_rescue]&amp;#039;&amp;#039;&amp;lt;/code&amp;gt;发布了。它的算法一次能处理两个块。但改进&amp;lt;code&amp;gt;dd_rescue&amp;lt;/code&amp;gt;的数据恢复算法、2003年的shell脚本&amp;lt;code&amp;gt;[http://www.kalysto.org/utilities/dd_rhelp/index.en.html dd_rhelp]&amp;lt;/code&amp;gt;作者现在推荐&amp;lt;code&amp;gt;[http://www.gnu.org/software/ddrescue/ddrescue.html GNU ddrescue]&amp;lt;/code&amp;gt;。&amp;lt;ref&amp;gt;{{cite web|url=http://www.kalysto.org/utilities/dd_rhelp/index.en.html|title=dd_rhelp author&amp;#039;s repository|last1=|author=LAB Valentin|date=2011-09-19|quote=Important note : For some times, dd_rhelp was the only tool (AFAIK) that did this type of job, but since a few years, it is not true anymore: Antonio Diaz did write a ideal replacement for my tool: GNU &amp;#039;ddrescue&amp;#039;.|accessdate=2013-04-20|archive-date=2008-05-16|archive-url=https://web.archive.org/web/20080516231947/http://www.kalysto.org/utilities/dd_rhelp/index.en.html|dead-url=no}}&amp;lt;/ref&amp;gt;它是一个发布于2004年的C++程序，与大多数的Linux发行版一起发行。在开源软件中，GNU &amp;lt;code&amp;gt;ddrescue&amp;lt;/code&amp;gt;有最先进的块大小变换算法。&amp;lt;ref&amp;gt;{{cite web | url=http://www.cgsecurity.org/wiki/Damaged_Hard_Disk | title=Damaged Hard Disk | publisher=www.cgsecurity.org | accessdate=2008-05-20 | archive-date=2008-05-10 | archive-url=https://web.archive.org/web/20080510140438/http://www.cgsecurity.org/wiki/Damaged_Hard_Disk | dead-url=no }}&amp;lt;/ref&amp;gt;（&amp;lt;code&amp;gt;ddrescue&amp;lt;/code&amp;gt;和&amp;lt;code&amp;gt;dd_rescue&amp;lt;/code&amp;gt;尽管名字相近，但却是不同的程序。因为如此，区分更为明确的备用名称也有使用；使用的名称有“addrescue”（freecode.com），“gddrescue”（[[Debian]]包名）和“gnu_ddrescue”（[[openSUSE]]包名）。）&lt;br /&gt;
&lt;br /&gt;
GNU &amp;lt;code&amp;gt;ddrescue&amp;lt;/code&amp;gt;既稳定又安全。&amp;lt;ref&amp;gt;{{cite web |url=http://blue-gnu.biz/content/interview_gnu_ddrescue_039_s_antonio_diaz_diaz |archiveurl=https://web.archive.org/web/20080415135125/http://blue-gnu.biz/content/interview_gnu_ddrescue_039_s_antonio_diaz_diaz |archivedate=2008-04-15 |title=Interview with GNU ddrescue&amp;#039;s Antonio Diaz Diaz |publisher=Blue-GNU |accessdate=2008-12-06 |deadurl=yes }}&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
另一个开源程序&amp;lt;code&amp;gt;&amp;#039;&amp;#039;savehd7&amp;#039;&amp;#039;&amp;lt;/code&amp;gt;使用更复杂的算法，但它需要安装自己的语言解释器。&lt;br /&gt;
&lt;br /&gt;
=== 驱动器性能基准测试 ===&lt;br /&gt;
对驱动器进行基准测试（通常是单线程），使用1024字节块分析连续系统读取和写入的性能：&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
dd if=/dev/zero bs=1024 count=1000000 of=file_1GB&lt;br /&gt;
dd if=file_1GB of=/dev/null bs=1024&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 用随机数据生成文件 ===&lt;br /&gt;
使用内核随机数驱动，用100个随机字节生成文件：&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
dd if=/dev/urandom of=myrandom bs=100 count=1&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 将文件转换为大写 ===&lt;br /&gt;
将文件转换为大写：&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
dd if=filename of=filename1 conv=ucase&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 创建任意大小的空文件 ===&lt;br /&gt;
创建1GiB的[[稀疏文件]]，或增加现有文件的大小：&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
dd if=/dev/zero of=mytestfile.out bs=1 count=0 seek=1G&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
（更先进的工具是GNU coreutils中的&amp;#039;&amp;#039;fallocate&amp;#039;&amp;#039;或&amp;#039;&amp;#039;truncate&amp;#039;&amp;#039;。）&lt;br /&gt;
&lt;br /&gt;
== 局限 ==&lt;br /&gt;
[[希捷科技|希捷]]的文档警告说，“一些依赖底层硬盘访问的硬盘工具（如DD）可能不支持48位[[逻辑区块地址]]（LBA），除非进行升级”。&amp;lt;ref&amp;gt;[https://web.archive.org/web/20070316080228/http://www.seagate.com/support/kb/disc/tp/137gb.pdf Windows 137GB (128 GiB) Capacity Barrier - Seagate Technology] (March 2003)&amp;lt;/ref&amp;gt;使用超过128 GiB的ATA硬盘时需要48位LBA。然而在[[Linux]]中，&amp;lt;code&amp;gt;dd&amp;lt;/code&amp;gt;使用内核读取或写入原始[[设备文件系统|设备文件]]。{{Efn|这可以用[[strace]]检查。}}2003年释出的2.4.23版本内核已经实现了对48位LBA的支持。&amp;lt;ref&amp;gt;{{cite web | url=http://www.kernel.org/pub/linux/kernel/v2.4/ChangeLog-2.4.23 | title=ChangeLog-2.4.23 | publisher=www.kernel.org | accessdate=2009-12-07 | archive-date=2009-10-08 | archive-url=https://web.archive.org/web/20091008103024/http://www.kernel.org/pub/linux/kernel/v2.4/ChangeLog-2.4.23 | dead-url=no }}&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;[http://lkml.indiana.edu/hypermail/linux/kernel/0311.3/0942.html Linux-2.4.23 released] {{Webarchive|url=https://archive.today/20121214210423/http://lkml.indiana.edu/hypermail/linux/kernel/0311.3/0942.html |date=2012-12-14 }} Linux kernel mailing list, 2003.&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
有人开玩笑说，&amp;lt;code&amp;gt;dd&amp;lt;/code&amp;gt;意为“destroy disk”（破坏硬盘）或“delete data”（删除数据），因为在对硬盘进行底层操作时，类似颠倒输入和输出文件的一个小错误都可能造成部分或全部硬盘数据的丢失。&amp;lt;ref name=&amp;quot;tfl-dd&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== dcfldd ==&lt;br /&gt;
&amp;#039;&amp;#039;&amp;lt;code&amp;gt;dcfldd&amp;lt;/code&amp;gt;&amp;#039;&amp;#039;是&amp;lt;code&amp;gt;dd&amp;lt;/code&amp;gt;的一个分支，由前[[美国国防部网络犯罪中心|美国国防部计算机取证实验室]]雇员尼克·哈勃（Nick Harbour）开发的增强版本。&amp;lt;ref&amp;gt;{{cite web | url=http://dcfldd.sourceforge.net/ | title=DCFLDD at Source Forge | publisher=Source Forge | accessdate=2013-08-17 | archive-date=2013-08-02 | archive-url=https://web.archive.org/web/20130802114625/http://dcfldd.sourceforge.net/ | dead-url=no }}&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;{{cite book|last=Jeremy Faircloth, Chris Hurley|title=Penetration Tester&amp;#039;s Open Source Toolkit|year=2007|publisher=Syngress|isbn=9780080556079|pages=470 - 472}}&amp;lt;/ref&amp;gt;&amp;lt;ref&amp;gt;{{cite book|last=Jack Wiles, Anthony Reyes|title=The Best Damn Cybercrime and Digital Forensics Book Period|year=2011|publisher=Syngress|isbn=9780080556086|pages=408 - 411}}&amp;lt;/ref&amp;gt;与&amp;lt;code&amp;gt;dd&amp;lt;/code&amp;gt;相比，&amp;lt;code&amp;gt;dcfldd&amp;lt;/code&amp;gt;允许一个以上的输出文件，同时支持多种校验计算方法，还提供了验证模式以匹配文件，并能显示操作进度百分比。&lt;br /&gt;
&lt;br /&gt;
== 参见 ==&lt;br /&gt;
* [[备份]]&lt;br /&gt;
* [[硬盘克隆]]&lt;br /&gt;
* [[硬盘复制]]&lt;br /&gt;
* [[硬盘镜像]]&lt;br /&gt;
* [[Unix实用程序列表]]&lt;br /&gt;
&lt;br /&gt;
== 注释 ==&lt;br /&gt;
{{notelist|iger=}}&lt;br /&gt;
&lt;br /&gt;
== 参考文献 ==&lt;br /&gt;
{{Reflist|30em}}&lt;br /&gt;
&lt;br /&gt;
== 外部链接 ==&lt;br /&gt;
{{Div col||30em}}&lt;br /&gt;
* {{man|cu|dd|SUS|convert and copy a file}}&lt;br /&gt;
* [http://www.gnu.org/software/coreutils/manual/html_node/dd-invocation.html dd]{{Wayback|url=http://www.gnu.org/software/coreutils/manual/html_node/dd-invocation.html |date=20150116050030 }}：[[GNU核心工具组]]手册页。&lt;br /&gt;
* {{man|1|dd|Darwin}}&lt;br /&gt;
* [http://www.chrysocome.net/dd dd for Windows]{{Wayback|url=http://www.chrysocome.net/dd |date=20130524132626 }}&lt;br /&gt;
* [http://seed7.sourceforge.net/scrshots/savehd7.htm savehd7 - Save a potentially damaged harddisk partition]{{Wayback|url=http://seed7.sourceforge.net/scrshots/savehd7.htm |date=20130515021928 }}&lt;br /&gt;
* [http://www.gnu.org/software/ddrescue/ddrescue.html GNU ddrescue]{{Wayback|url=http://www.gnu.org/software/ddrescue/ddrescue.html |date=20130417032439 }}&lt;br /&gt;
* [http://www.gnu.org/software/ddrescue/manual/ddrescue_manual.html GNU ddrescue手册页]{{Wayback|url=http://www.gnu.org/software/ddrescue/manual/ddrescue_manual.html |date=20131114193124 }}&lt;br /&gt;
* [http://www.garloff.de/kurt/linux/ddrescue/ dd_rescue]{{Wayback|url=http://www.garloff.de/kurt/linux/ddrescue/ |date=20010516091650 }}&lt;br /&gt;
* [http://www.kalysto.org/utilities/dd_rhelp/index.en.html dd_rhelp]{{Wayback|url=http://www.kalysto.org/utilities/dd_rhelp/index.en.html |date=20080516231947 }}&lt;br /&gt;
* [http://www.softpanorama.org/Tools/dd.shtml Softpanorama dd page]{{Wayback|url=http://www.softpanorama.org/Tools/dd.shtml |date=20130517235659 }}&lt;br /&gt;
* [http://wiki.linuxquestions.org/wiki/Dd DD at Linux Questions Wiki]{{Wayback|url=http://wiki.linuxquestions.org/wiki/Dd |date=20120118181914 }}&lt;br /&gt;
* [https://web.archive.org/web/20130917155902/http://www.myfixlog.com/fix.php?fid=21 How to use ddrescue to image a damaged harddisk partition and mount it in Windows.]&lt;br /&gt;
* [https://web.archive.org/web/20111206091733/http://www.forensicswiki.org/wiki/Dcfldd Forensics (DD) Dcfldd]&lt;br /&gt;
{{Div col end}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{光盘制作软件}}&lt;br /&gt;
{{Unix命令}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Unix SUS2008实用工具]]&lt;br /&gt;
[[Category:标准Unix程序]]&lt;/div&gt;</summary>
		<author><name>imported&gt;InternetArchiveBot</name></author>
	</entry>
</feed>