From the Arch Linux Wiki: https://wiki.archlinux.org/index.php/USB_flash_installation_media
# dd bs=4M if=/path/to/archlinux.iso of=/dev/sdx status=progress && sync
[...] Do not miss sync to complete before pulling the USB drive.
I would like to know
- What does it do?
- What consequences are there if left out?
Notes
dd
command used with optional status=progress
:
tar -xzOf archlinux-2016-09-03-dual.iso | dd of=/dev/disk2 bs=4M status=progress && sync
Or using pv
for progress
tar -xzOf archlinux-2016-09-03-dual.iso | pv | dd of=/dev/disk2 bs=4M && sync
dd
does not bypass the kernel disk caches when it writes to a device. When writing to a file (over the file system layer of the kernel), things are cached. However, I am concerned about writing to devices. Please provide a source for that statement if you can, because that is the linchpin of this question. If true, it would provide a valid reason for runningsync
after add
-to-device operation. – Jonathan Komar Sep 28 '16 at 14:30oflag=sync
, so progress outputs the real transfer speed and not the cached one (so going a steady 10MB/s instead of one second 100MB/s and then 10 seconds of stall). – Bart Polot Dec 21 '17 at 10:29conv=fsync
in your answer and explain why you rather use/recommend one or the other. – DJCrashdummy Dec 05 '21 at 04:21oflag=direct conv=fsync
.fsync
does the same asfdatasync
and and additionally syncs file metadata likest_atime
,st_mtime
(again no need for an explicit call tosync
after runningdd
). The explanation ofoflag=direct
leaves much to be desired inman dd
, butinfo dd
explains that it uses "[..] direct I/O for data, avoiding the buffer cache.". – Jonathan Komar Jan 23 '22 at 07:56oflag=direct
- it's interesting, I will check... – Serge Jan 23 '22 at 09:44oflag=direct
? – Jonathan Komar Apr 26 '22 at 19:42