Skip to content

Instantly share code, notes, and snippets.

@MikeDacre
Created February 20, 2013 20:55
Show Gist options
  • Save MikeDacre/4999529 to your computer and use it in GitHub Desktop.
Save MikeDacre/4999529 to your computer and use it in GitHub Desktop.
systemd script for flashcache - non-root disk Install to /usr/lib/systemd/system/flashcache.service. Activate with `systemctl enable flashcache` You need to update the shell script to reflect your own caches.
#!/bin/bash
HOMEMOUNT=$(mount | grep home | sed 's/ .*//' | sed 's#.*/##' )
if [[ ! "$(eval lsmod | grep "^flashcache")" ]]; then
modprobe flashcache
fi
if [[ ! "$HOMEMOUNT" == "flashcache" ]]; then
umount /home
if [ ! -e /dev/mapper/homecache ]; then
flashcache_load /dev/sdc1
fi
mount /home
fi
[Unit]
Description=FlashCache
[Service]
Type=oneshot
RemainAfterExit=no
ExecStart=/usr/local/bin/flashcache
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment