Help us understand the problem. What is going on with this article?

ddコマンドのbsサイズ

More than 3 years have passed since last update.

ddコマンドを使って、イメージファイルをsdcardとかに書き込む際に、bsオプションを使ってバッファリングサイズを調整すると、早くなります。
(参考:dd コマンドの bs の値の意味を詳しく教えてください。)

いくつにするのがいいのか、というのを、いつも忘れてしまうので、調べるスクリプトを貼っておきます。
元のソースコードは server fault - How to determine the best byte size for the dd commandより。

#!/bin/bash
#
#create a file to work with
#
echo "creating a file to work with"
dd if=/dev/zero of=/var/tmp/infile count=1175000

for bs in  16m 32m 64m 128m 256m 512m

do
        echo "---------------------------------------"
        echo "Testing block size  = $bs"
        dd if=/var/tmp/infile of=/var/tmp/outfile bs=$bs
        echo ""
done
rm /var/tmp/infile /var/tmp/outfile

私のMac Miniではこんな感じでした。いつもbs=32mで指定していましたが、bs=16mのが早いわけですね。

$> ./test_dd_bs.sh 

creating a file to work with
1175000+0 records in
1175000+0 records out
601600000 bytes transferred in 3.716253 secs (161883487 bytes/sec)
---------------------------------------
Testing block size  = 16m
35+1 records in
35+1 records out
601600000 bytes transferred in 1.312157 secs (458481751 bytes/sec)

---------------------------------------
Testing block size  = 32m
17+1 records in
17+1 records out
601600000 bytes transferred in 1.512825 secs (397666614 bytes/sec)

---------------------------------------
Testing block size  = 64m
8+1 records in
8+1 records out
601600000 bytes transferred in 1.472201 secs (408639823 bytes/sec)

---------------------------------------
Testing block size  = 128m
4+1 records in
4+1 records out
601600000 bytes transferred in 1.510589 secs (398255218 bytes/sec)

---------------------------------------
Testing block size  = 256m
2+1 records in
2+1 records out
601600000 bytes transferred in 1.574169 secs (382169855 bytes/sec)

---------------------------------------
Testing block size  = 512m
1+1 records in
1+1 records out
601600000 bytes transferred in 1.684105 secs (357222349 bytes/sec)
Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away