2

This USB flash installation media guides me to use oflag=sync:

# dd bs=4M if=/path/to/archlinux.iso of=/dev/sdx status=progress oflag=sync

... but other articles like itsfoss guide me to use sync:

# dd bs=4M if=/path/to/archlinux.iso of=/dev/sdx status=progress && sync

Which one is preferred: the oflag=sync option to dd, or a separate sync command?

1
  • 1
    I prefer using the separate sync command, because you won't need to sync the write if it fails. The && separator makes sure sync is only run if the dd command completes successfully.
    – Mio Rin
    Feb 26, 2018 at 14:37

1 Answer 1

1

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.

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