wait for dd command to fully write to the disk
Solution 1:
Despite popular belief, dd
is a perfectly ordinary command, it isn't more low-level than cat
or cp
. Your command reads from the disk cache and writes to the disk buffers like any other command.
In order to make sure that the data is fully written to the physical media, you need to call sync
. The command sync
flushes all output buffers to the disk(s). When the sync
command returns, the data has been fully written.
sudo dd if=~/Desktop/ubuntu.iso of=/dev/sdx bs=1M; sync
Most of the time, you don't need to call sync
, because unmounting a filesystem does the same job. When the umount
command returns, or when you get a confirmation message after clicking “Eject”, the buffers have been written to the disk. Here, you're directly writing to the disk without going through a mounted filesystem, so you need to explicitly flush the buffer.
Note that instead of dd
, you could use tee
. This has two advantages: there's less risk of inverting the source and destination due to a typo, and it's probably slightly faster.
<~/Desktop/ubuntu.iso sudo tee /dev/sdx >/dev/null; sync
Solution 2:
Try this:
sudo dd if=~/Desktop/ubuntu.iso of=/dev/sdx conv=fdatasync bs=1m
The conv=fdatasync
tells dd
to use the special options to make sure that the data get written to the physical device.