According to the manual for dd, there are two options that can cause I/O to bypass the filesystem cache: direct and nocache. When using these flags to, for example, copy files or copy raw data to/from block devices, what are the differences between these two flags?

Let's say I want to copy one file from A to B using just dd (no real reason, just an experiment), in a way that dd will...

  1. ...read one full block from the input file, without putting it in the read cache, and then...
  2. ...write that data to the destination as soon as a full block is read, without putting it in the write cache.

What do these flags do differently for this example scenario? What would be the proper invocation of dd for this task?

1 Answer 1


Disclaimer: I can't say definitively, but this is my best guess.

No Cache:

Read unaligned input directly from the device.

Direct I/O:

Read and write aligned data without using either the OS's internal buffers or L* caching.

In summation, if you wanted to avoid OS/L* caching altogether just go with the direct I/O option. If it's only read caching you're trying to avoid, nocache should suffice.

  • 1
    It’s a pretty good guess. direct opens files with O_DIRECT, which on Linux tries to minimise the use of caches, and reads and writes directly to and from the userspace buffers. nocache uses posix_fadvise to tell the kernel that the caches can be dropped, after reads; so caches are used, but hopefully for a short while only. Commented Jul 9, 2020 at 9:58

You must log in to answer this question.

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