This answer should partially answer your question. Basically, dd
does not bypasses kernel disk caches when writing to device, and using this oflag
will sync those disk writes to disk.
Both sync
command and oflag=sync
will do the same job. The only difference i can spot here is that sync
command will write to disk all caches from all disks so, a machine that is pretty busy writing to other disks will have a slower(you may even not feel it) response.
Quoting sync
documentation:
Description
sync writes any data buffered in memory out to disk. This
can include (but is not limited to) modified superblocks, modified
inodes, and delayed reads and writes. This must be implemented by the
kernel; The sync program does nothing but exercise the sync(2)
system
call.
sync
command, because you won't need to sync the write if it fails. The&&
separator makes suresync
is only run if thedd
command completes successfully.