/etc/systemd/system/xfs-write-cache.service
[Unit]
Description=Set XFS Write cache to write through
[Service]
Type=oneshot
User=root
Group=root
ExecStart=/usr/lib/systemd/system-sleep/xfs-write-cache
RemainAfterExit=true
StandardOutput=journal
[Install]
WantedBy=multi-user.target
/usr/lib/systemd/system-sleep/xfs-write-cache
#!/bin/sh
echo "write through" | sudo tee /sys/block/sda/queue/write_cache
We put xfs-write-cache
executable script in /usr/lib/systemd/system-sleep/
because we want the "write through" setting to be set again after a resume.
Source: https://serverfault.com/questions/980677/xfs-with-no-barrier-mount-option-deprecated