1

When writing an ISO image to USB flash drive with dd, how do I know I can remove the stick? Obviously I'll wait until the command completes and I'm back at the terminal prompt. But even then the device might still be busy from a cache/buffer. Because I'm writing to the device itself, nothing is mounted, so I also don't call umount and cannot see if the device is still busy.

I've seen dd ... && sync a few times. But doesn't that block until buffers for all media have been written? Not only the one flash drive that I used dd with. So if I have lots of other write processes, wouldn't that block?

Would the conv= argument for dd help? But which one of conv=sync, conv=fsync, conv=fdatasync, ...?

1
  • I think most people use sync for this purpose (yes, it flushes all buffers, but that's OK in almost all cases).
    – sudodus
    Sep 13, 2021 at 19:20

3 Answers 3

1

There are short descriptions of fsync and fdatasync in man dd and with slightly more details in info dd.

If I don't want to use the separate and global sync, I would use conv=fsync in ddbecause it writes both data and metadata before finishing. From info dd:

 ‘fdatasync’
      Synchronize output data just before finishing.  This forces a
      physical write of output data.

 ‘fsync’
      Synchronize output data and metadata just before finishing.
      This forces a physical write of output data and metadata.
0
1

Once the dd command has finished, run sudo eject /dev/sd[drive letter]. Once that has finished, you are free to remove it. The data will be sync'd.

0
1

This answer to a related question seems to imply that conv=fdatasync is equivalent to sync for that one dd call.

1
  • There are short descriptions of fsync and fdatasync' in man dd` and with slightly more details in info dd.
    – sudodus
    Sep 13, 2021 at 19:26

You must log in to answer this question.

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