TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Comparing dd and cp when writing a file to a thumb drive

58 点作者 vector_spaces超过 1 年前

4 条评论

codetrotter超过 1 年前
Speaking of thumb drives.<p>In the case of copying files to a mounted file system, I’ve sometimes found it faster to use a tar pipeline than cp when copying data to an USB stick or SD&#x2F;microSD card.<p>Instead of:<p><pre><code> cp -r ~&#x2F;wherever&#x2F;somedir&#x2F; &#x2F;media&#x2F;SOMETHING&#x2F; </code></pre> I would do<p><pre><code> cd ~&#x2F;wherever&#x2F; tar cf - somedir&#x2F; | ( cd &#x2F;media&#x2F;SOMETHING&#x2F; &amp;&amp; tar xvf - ) </code></pre> And it would be <i>noticably</i> faster.<p>Not the same use case as linked article, but wanted to bring this up since it’s somewhat related.
评论 #39154797 未加载
评论 #39154967 未加载
评论 #39157571 未加载
评论 #39154956 未加载
tadfisher超过 1 年前
cp queries the preferred block size of the destination file in &#x27;struct stat&#x27;, and has specific tweaks for certain filesystems. As far as I can tell, dd does not do this as it calls through to &#x27;write&#x27; directly.<p>In any case, the tests in ioblksize.h indicate that bs=4M is far too large and may perform worse than the default for cp&#x2F;cat (128KiB). There is a script there that should clear things up for more modern systems.<p>The point about fdatasync is superfluous as you can run &#x27;sync&#x27; yourself, or unmount the filesystem.
评论 #39152615 未加载
评论 #39154396 未加载
BenjiWiebe超过 1 年前
I&#x27;ve switched to the following:<p><pre><code> &lt;infile pv &gt;outfile </code></pre> And it seems to work very well plus gives a good progress indicator.
bravetraveler超过 1 年前
One of my favorite party tricks is using <i>shell redirects</i> to do this. Using coreutils <i>(&#x27;cp&#x27;)</i> is a nice approach<p>I&#x27;m all for anything not <i>&#x27;dd&#x27;</i> or cargo-culted like <i>balenaEtcher</i><p>This all depends on a certain format of ISO that I can&#x27;t recall<p>There&#x27;s no magic. Checksum the drive and the file after
评论 #39154359 未加载
评论 #39155996 未加载