Skip to content

Instantly share code, notes, and snippets.

@AnatomicJC
Last active June 19, 2024 16:17
Show Gist options
  • Save AnatomicJC/260e4a0c53f116c06b8fa351715691d6 to your computer and use it in GitHub Desktop.
Save AnatomicJC/260e4a0c53f116c06b8fa351715691d6 to your computer and use it in GitHub Desktop.
XFS write-cache

/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

for device in $(mount | grep xfs | awk '{print $1}' | sed 's/\/dev\///')
do
  echo "write through" | tee /sys/block/${device}/queue/write_cache
done

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment