Create a bootable USB drive on Linux using dd with correct flags
Start by identifying the device name.
myth@ion:~$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sdc 8:0 1 14,9G 0 disk
├─sdc1 8:1 1 2,6G 0 part /media/myth/Ubuntu 20.04.1 LTS amd64
└─sdc2 8:2 1 3,9M 0 part
In this case it is /dev/sdc
. Proceed to unmount it:
sudo umount /dev/sdc1
Write your ISO file to the drive:
dd if=/home/myth/downloads/ubuntu-20.10-beta.iso of=/dev/sdc bs=1M oflag=dsync status=progress
When not using conv=fdatasync
or oflag=dsync
, it is wise to call sync
after dd
exits to ensure kernel buffers are flushed and all data is written to the device. The kernel might do some caching and buffering to do I/O optimization and if you unplug your drive prior to the last blocks being written you might have a bad time.
About the flags
bs=1M
replaces the default block size of dd to significantly increase throughput. Going above 4096 does not yield significantly better performance normally, but when using the oflag=dsync
setting instead of let's say conv=fdatasync
, it has a much greater impact, as data is periodically synced instead of just before dd exits.
status=progress
is of course to display the current write speed, elapsed time, and how much data has been written.
oflag=dsync
does a write + flush after each segment, which makes progress
display the actual throughput.
conv=fdatasync
ensures a flush when dd is done, right before it exists, meaning progress
might show write figures greatly skewed by kernel buffering.