1

I know hdparm -W0 /dev/sata-ssd can disable disk cache for SATA SSD, but this does not work on my NVMe SSD (i.e., Samsung 980 pro). Maybe some option of nvme can do it, but I failed to find it.

How can I make this?

Thanks.

Tim He
  • 331

1 Answers1

6

You can do this via the nvme commands, but I'm curious to know why you would want to do this. Disabling the cache will save a bit of RAM if that's the goal, bit it will cut your throughput in half at the very least.

Either way, this is how you do it:

# nvme get-feature -f 6 /dev/nvme0n1 
get-feature:0x6 (Volatile Write Cache), Current value:0x000001
# nvme set-feature -f 6 -v 0 /dev/nvme0n1 
set-feature:06 (Volatile Write Cache), value:00000000
# nvme get-feature -f 6 /dev/nvme0n1 
get-feature:0x6 (Volatile Write Cache), Current value:00000000

If for some reason you elect to make this persistent across reboots, you will need to write a udev rule:

ACTION=="add", KERNEL=="nvme*", RUN+="nvme set-feature -f 6 -v 0 %N"

These commands work with my Samsung 970 Pro, so should work with your device as well.