An annoying kernel bug delays resume from suspend to RAM: https://bugzilla.opensuse.org/show_bug.cgi?id=1195025 As a workaround the HDD involved is deactivated on suspend.
Scripts:
The dirty hack works as long as the HDD is plugged into the third SATA header on the motherboard.
Deactivate disk:
**erlangen:~ #** cat /usr/local/bin/delete-backup-disk
#!/bin/bash
if -f /sys/devices/pci0000:00/0000:00:17.0/ata4/host3/target3:0:0/3:0:0:0/delete ] ; then
echo 1 > /sys/devices/pci0000:00/0000:00:17.0/ata4/host3/target3:0:0/3:0:0:0/delete
fi
**erlangen:~ #**
Scan for disk:
**erlangen:~ #** cat /usr/local/bin/scan-for-backup-disk
#!/bin/bash
echo "- - -" > /sys/devices/pci0000:00/0000:00:17.0/ata4/host3/scsi_host/host3/scan
**erlangen:~ #**
Services:
Disable HDD on boot and prior to suspend
**erlangen:~ #** systemctl cat HDD-disable.service
**# /etc/systemd/system/HDD-disable.service**
[Unit]
Description=Disable backup HDD
[Service]
ExecStart=/usr/local/bin/delete-backup-disk
[Install]
WantedBy=multi-user.target
**erlangen:~ #**
Scan for disk:
**erlangen:~ #** systemctl cat HDD-scan.service
**# /etc/systemd/system/HDD-scan.service**
[Unit]
Description=Scan for backup HDD
[Service]
ExecStart=/usr/local/bin/scan-for-backup-disk
**erlangen:~ #**
Modification to suspend:
**erlangen:~ #** systemctl cat systemd-suspend
**# /etc/systemd/system/systemd-suspend.service**
# SPDX-License-Identifier: LGPL-2.1-or-later
#
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
[Unit]
Description=System Suspend
Documentation=man:systemd-suspend.service(8)
DefaultDependencies=no
Requires=sleep.target **HDD-disable.service**
After=sleep.target **HDD-disable.service**
[Service]
Type=oneshot
ExecStart=/usr/lib/systemd/systemd-sleep suspend
**erlangen:~ #**
Changes to backup service:
[FONT=monospace]**erlangen:~ #** systemctl cat backup-home.service
**# /etc/systemd/system/backup-home.service**
[Unit]
Description=Backup /home
Requires=HDD.mount **HDD-scan.service**
After=HDD.mount **HDD-scan.service**
[Service]
ExecStart=/usr/bin/rsync -a --exclude=.cache --exclude=covid-19-data /home/ /HDD/backup/home/
ExecStopPost=/usr/bin/umount /HDD
**ExecStopPost=/usr/local/bin/delete-backup-disk **
**erlangen:~ #**
[/FONT]
Resume from suspend is now as fast as it was prior to kernel bug:
**erlangen:~ #** journalctl -b -u HDD-disable.service -u systemd-suspend.service --since 11:53 -o short-monotonic
4001.282464] erlangen systemd[1]: Started Disable backup HDD.
4001.286366] erlangen systemd[1]: Starting System Suspend...
4001.289061] erlangen systemd[1]: HDD-disable.service: Deactivated successfully.
4001.294992] erlangen systemd-sleep[5105]: INFO: Skip running /usr/lib/systemd/system-sleep/grub2.sleep for suspend
**4001.296099**] erlangen systemd-sleep[5103]: Entering sleep state 'suspend'...
**4003.592988**] erlangen systemd-sleep[5103]: System returned from sleep state.
4003.599700] erlangen systemd-sleep[5119]: INFO: Skip running /usr/lib/systemd/system-sleep/grub2.sleep for suspend
4003.600892] erlangen systemd[1]: systemd-suspend.service: Deactivated successfully.
4003.601116] erlangen systemd[1]: Finished System Suspend.
**erlangen:~ #**