Skip to content

Instantly share code, notes, and snippets.

@shoeper
Forked from kylemanna/ssd-cache-wait.conf
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shoeper/63d3002df11f2156a988 to your computer and use it in GitHub Desktop.
Save shoeper/63d3002df11f2156a988 to your computer and use it in GitHub Desktop.
description "Suspend dmcache for SSD cache"
author "Kyle Manna <kyle@kylemanna.com>"
# Start monitoring with inotifywait (will block) after the filesystem is
# mounted, when the filesystem is unmounted, teardown the dm devices.
start on mounted MOUNTPOINT=/media/usb1
script
inotifywait -e unmount $MOUNTPOINT
dmsetup suspend home-cached
dmsetup remove home-cached
dmsetup remove ssd-blocks
dmsetup remove ssd-metadata
end script
description "Configure dmcache for SSD cache"
author "Kyle Manna <kyle@kylemanna.com>"
# This would be handy, but it assumes the source device is already
# available, which in this case it isn't.
#start on mounting MOUNTPOINT=/media/usb1
# Run after /proc and /dev are finalized
start on virtual-filesystems
task
script
# Setup the /dev/mapper/home-cached entity so that mountall will automount it after reading fstab
dmsetup create ssd-metadata --table '0 20480 linear /dev/disk/by-id/scsi-SATA_KINGSTON_SV300S50026B774108482C-part1 0'
dmsetup create ssd-blocks --table '0 104857600 linear /dev/disk/by-id/scsi-SATA_KINGSTON_SV300S50026B774108482C-part2 0'
dmsetup create hdd-cached --table '0 1953118377 cache /dev/mapper/ssd-metadata /dev/mapper/ssd-blocks /dev/disk/by-id/usb-TOSHIBA_External_USB_3.0_231843245107-0:0-part1 512 1 writeback default 0'
dmsetup resume home-cached
end script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment