Linux Ate My RAM
linuxatemyram.com
linuxatemyram.com
Wildly disagree!
I regularly want to disable disk caching when I want to be able to drop power or disconnect a drive without drive corruption.
With smaller “microcontrollers” running linux, their power could drop at any moment. With external drives, I might want to pull the drive the second it’s done transferring a file. Caches get in the way in both cases.
to see wether or not write cache is active
cat /sys/block/[your block device]/queue/write_cache
write back means the write operation is completed as soon as it hits the linux write cache you can set it to write through to make it wait untill the controller responds, this has obvious performance implications depending on the workload. note that alot of hdd's and all ssd's have their own caches and you'll need to disable those as well.
that would at least give alot of performance back from the read cache.
check nvme controller write cache [1]
sudo nvme id-ctrl /dev/nvme0|grep vwc
disable nvme write cache
sudo nvme set-feature /dev/nvme0 -f 0x6 -v 0
I have not tested anything and I do not recommend this in the slightest, dont expect to be protected against sudden power failure data loss. it will also destroy your ssd and amplify writes considerably.
[1] https://wiki.archlinux.org/index.php/Solid_state_drive/NVMe#...
The one that eats your ram (the reason for the site to exist) would mostly be the read caches.