2

I have writethrough bcache working on Debian Sid with an underlying LUKS + LVM. My swap partition (already present) is lying unused as an LVM volume.

I know that I am supposed to stop bcache before hibernation (suspend to disk), and resume bcache after resume (cannot be active during either).

How exactly do I ensure that? Are there are any pre- and post- scripts for this? If so, how should stop and restart bcache. All that echo n > /sys ... business can go remarkably awry if one does not know what one is doing.

Getting hibernation working is the last pending thing after the install.

1 Answer 1

1

At this point you probably have figured it out on your own, abandoned bcache, or lived without hibernation but this is how I am doing it:

Following the arch guide for resume/hibernate hooks with systemd: I created a service /etc/systemd/system/bcache-suspend.service

[Unit]
Description=Disable bcache chaching
Before=sleep.target suspend.target hibernate.target hybrid-sleep.target suspend-then-hibernate.target

[Service]
Type=simple
ExecStart=/usr/bin/bash -c "echo none > /sys/block/bcache0/bcache/cache_mode"

[Install]
WantedBy=sleep.target suspend.target hibernate.target hybrid-sleep.target suspend-then-hibernate.target

and a similar one, /etc/systemd/system/bcache-resume.service

[Unit]
Description=Re-enable bcache chaching
After=sleep.target suspend.target hibernate.target hybrid-sleep.target suspend-then-hibernate.target

[Service]
Type=simple
ExecStart=/usr/bin/bash -c "echo writeback > /sys/block/bcache0/bcache/cache_mode"

[Install]
WantedBy=sleep.target suspend.target hibernate.target hybrid-sleep.target suspend-then-hibernate.target

Also don't forget to enable the services systemctl enable bcache-resume.service and systemctl enable bcache-suspend.service.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.