Remedy MacPro 1,1 Suspend Issue with Ubuntu 24.04

After upgrade from 18.04 to 24.04, suspend stopped working on my MacPro 1,1 home server. I use it as a beautiful furniture/home server that sleeps unless accessed, so it being able to sleep is essential.

After lengthy diagnostics with Claude, the culprit was identified as Nvidia GT7300 video card, and the following script pasted to fix the issue:

sudo tee /lib/systemd/system-sleep/nouveau.sh << 'EOF'
#!/bin/bash
case $1 in
  pre)
    modprobe -r nouveau
    ;;
  post)
    modprobe nouveau
    ;;
esac
EOF
sudo chmod +x /lib/systemd/system-sleep/nouveau.sh

Also etherwake script was updated in OpenWrt:

/etc/init.d/arp-wol:

#!/bin/sh /etc/rc.common

START=99
USE_PROCD=1

start_service() {
    procd_open_instance
    procd_set_param command /bin/sh -c 'tcpdump -i br-lan -l arp and ether[0x26:1]=192 and ether[0x27:1]=168 and ether[0x28:1]=1 and ether[0x29:1]=192 | while read -r line; do etherwake -i br-lan 00:17:f2:0a:af:33; done'
    procd_set_param respawn
    procd_set_param stdout 1
    procd_set_param stderr 1
    procd_close_instance
}

enable with:

/etc/init.d/arp-wol enable && /etc/init.d/arp-wol start

And finally a simple script to run by cron every minute on MacPro to put it to sleep unless there is a live ssh/sftp or a terminal session (including screen), with a 5 min grace period:

#!/bin/bash

FLAG_FILE="/tmp/ssh-suspend-flag"
IDLE_MINUTES=5

# Check for active SSH connections (port 22) OR logged-in users
if ss -tn | grep -q ':22.*ESTABLISHED' || who | grep -q .; then
    # Activity detected - remove flag and exit
    rm -f "$FLAG_FILE"
    exit 0
fi

# No activity - check flag
if [ ! -f "$FLAG_FILE" ]; then
    # First time idle - create flag
    touch "$FLAG_FILE"
    exit 0
fi

# Flag exists - check age
FLAG_AGE=$(($(date +%s) - $(stat -c %Y "$FLAG_FILE")))
if [ $FLAG_AGE -ge $((IDLE_MINUTES * 60)) ]; then
    # Flag is old enough - suspend
    rm -f "$FLAG_FILE"
    systemctl suspend
fi

I hope it helps someone as it would definitely help me upon the next upgrade/rebuild!

Leave a Reply

Your email address will not be published. Required fields are marked *