Sdcard becomes read-only after waking up from suspend

It looks like I’ve found a workaround for this issue.

Some context first: I use ext4 fs over LUKS encrypted partition located on sd-card as soon as I keep my personal files here and I’d like to be protected if I lose the phone.

Solution: LUKS has suspend option when all io operation stopped. So, I’ve created luks-suspend-resume.service with the next content:

[Unit]
Before=sleep.target
StopWhenUnneeded=yes

[Service]
Type=oneshot
RemainAfterExit=yes
# before suspend
ExecStart=/usr/sbin/cryptsetup luksSuspend <storage_name>
# after resume
ExecStop=/usr/sbin/cryptsetup luksResume <storage_name> --key-file=<path/to/your/keyfile>

[Install]
WantedBy=sleep.target

Do not forget to enable the unit. After that I have no issue with my sdcard. Another issues happened some times, but it is another history.

8 Likes