11

What is a reasonable bs to use when running dd to flash an Ubuntu image? I am using:

dd if=ubuntu-17.04-server-amd64.iso of=/dev/sda bs=1M

The ubuntu-17.04-server-amd64.iso file is 685 M.

I am running this dd operation on a strong server, with bs=1M. It takes almost 3 minutes (154 seconds):

718274560 bytes (718 MB) copied, 154.192 s, 4.7 MB/s

I assume that if I will use a higher bs, like bs=500M, it will be quicker (though I did not check it).

What is a recommended and reliable bs= for such dd command?

1

2 Answers 2

20

My standard dd block size is bs=4096

Some years ago I tested different block sizes, and found that bs=4096 is a good value for most cases. It made no big difference to increase the block size to higher values. If I understood correctly, it was also the value used by several programs (cat, cp etc). This is the block size used for dd under the hood in mkusb.

Things may have changed since I tested different block sizes, but I think the speed in your case is limited by the flash memory hardware. A fast USB 3 pendrive or fast memory card will be 5 times faster (~25 MB/s) even when connected via USB 2. See this link and links from it,

help.ubuntu.com/community/Installation/FromUSBStick#Notes_about_speed

So you can continue with bs=1M or use bs=4096.

If you wish, you can try some different block sizes, but do not expect any big improvement. Please come back and report the result, particularly if you find a major improvement. In that case it is also important to specify the hardware and the operating system (version of Ubuntu).

Edit: New test

I tested again, with current Lubuntu 16.04 LTS versions, and computer hardware of different kind and age, as described in the following table and graphs.

Test details

  • The test was run with a shell-script, that for each block size wiped and synced the first Gibibyte of the target USB pendrive (overwrote with zeros), then cloned and synced from a Lubuntu iso file (which is slightly smaller than one Gibibyte, so within the wiped part of the pendrive).
  • In all cases a pure dd command line was used (no piping via pv or similar commands).
  • Most tests were run from Lubuntu 16.04.2 LTS amd64 system (with a yakkety kernel) installed in an SSD, but the tests in an HP xw8400 workstation were run with the installed Lubuntu 16.04 LTS i386 system (with a xenial kernel) in an internal HDD.

  • 'Extreme' and 'Cruzer_blade' are Sandisk USB pendrive models

  • 'drive port' is where the target USB pendrive is connected
  • 'os port' is where the SSD or HDD with the operating system is connected

  • More details are listed in the following table, and the variations due to the block size are illustrated in the following graphs with log (block size) along the x-axis because of the character of the range of block size values,

    • 512 (default)
    • 4096 (4K)
    • 65536 (64K)
    • 1048576 (1M)
    • 4194304 (4M)

dd-blocksize-test-table

dd-blocksize-test-graphs

Conclusions

  • The default block size, bs=512 (bytes) makes dd slow.

  • Cloning with block sizes from bs=4096 to 4M run at 'full speed'. There are only minor differences between the test cases (except for bs=512).

1
  • Wow, that is a very extensive test! Thank you! May 4, 2020 at 17:52
0

Using a usb stick that is USB 3.x compatible, I get 65MB/s for an ISO burn.

sudo dd if=xubuntu-20.04.1-desktop-amd64.iso of=/dev/sdb bs=4M
405+1 records in
405+1 records out
1699577856 bytes (1.7 GB, 1.6 GiB) copied, 26.4146 s, 64.3 MB/s

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .