My target device is a hard drive with 4096 bs. I want to bypass caches and write to storage directly or as soon as possible. Speed is not my primary concern: 30 hours is too much, but the difference between 4 and 7 hours is insignificant.
What I understand (might not be 100% correct):
conv=fsync
will be executed only once at the end of dd
call.
But I don't want to postpone sync until the end. I want the data written to storage as soon as possible. There two other options: oflag=direct
and oflag=sync
. I don't like oflag=sync
, because (1) it's extremely slow when I test with bs=4096
, and (2) it still uses memory cache -- unnecessarily, I think.
oflag=direct
bypasses the kernel's page cache (memory cache), writing directly to the storage. But the storage may itself store the data in a write-back (hdd) cache, so conv=fsync
will still be required to write hdd cache to the actual storage.
Thus, I hope it is permissible -- I wonder whether it is ideal -- to use the two arguments together, maybe like this:
dd if=/dev/zero of=/dev/sdX bs=4096 status=progress oflag=direct conv=fsync
bs=4096
is faster thanbs=1M
. I haven't tested dd with direct and sync options yet. Because I am asking this question and not sure if this is the proper way to bypass all cache. Cheers. – sgon00 Jun 29 '21 at 11:47cat /dev/zero >/dev/sdX
and avoid all the fiddle withdd
– Chris Davies Jun 29 '21 at 11:52cat
will use RAM too. That is not what I want. I expect direct IO without any memory and hdd cache. Cheers. – sgon00 Jun 29 '21 at 11:59