What?

Quickly check for direct I/O support on a file system

Why?

Direct I/O can bypass the system’s page cache for application control of file reads/writes direct to storage for reduced copies and performance.

How?

Check

dd if=/dev/zero of=/path/to/test/file bs=512 count=1 oflag=direct

If the above returns without error then DIRECT I/O is supported

Example: Supported

$ dd if=/dev/zero of=testfile bs=512 count=1 oflag=direct
1+0 records in
1+0 records out
512 bytes copied, 0.00071525 s, 716 kB/s
Verification Check(s)

Using vmtouch or fincore shows no pages were loaded into the page cache:

$ vmtouch testfile 
           Files: 1
     Directories: 0
  Resident Pages: 0/1  0/4K  0%
         Elapsed: 4.3e-05 seconds
 
$ fincore testfile 
RES PAGES  SIZE FILE
 0B     0  512B testfile

Using strace shows use of O_DIRECT flag:

strace
$ strace -f dd if=/dev/zero of=testfile bs=512 count=1 oflag=direct
 
...
openat(AT_FDCWD, "testfile", O_WRONLY|O_CREAT|O_TRUNC|O_DIRECT, 0666) = 3
...