Why is sync so important when making a bootable linux usb stick?
The dd
does not bypass the kernel disk caches when it writes to a device, so some part of data may be not written yet to the USB
stick upon dd
completion. If you unplug your USB
stick at that moment, the content on the USB
stick would be inconsistent. Thus, your system could even fail to boot from this USB
stick.
Sync
flushes any still-in-cache data to the device.
Instead of invoking sync
you could use fdatasync
dd
's conversion option:
fdatasync
physically write output file data before finishing
In your case, the command would be:
tar -xzOf archlinux-2016-09-03-dual.iso | \
dd of=/dev/disk2 bs=4M status=progress conv=fdatasync
The conv=fdatasync
makes dd
effectively call fdatasync()
system call at the end of transfer just before dd
exits (I checked this with dd
's sources).
This confirms that dd
would not bypass nor flush the caches unless explicitly instructed to do so.