Celeb Glow
general | March 29, 2026

How to run a script after the system resumes from hibernate (suspent-to-disk)?

I have configured powernap to hibernate (i.e., suspend-to-disk) the machine if idle. In order to save additional power, I have configured my non-root, data disks to spin-down using the hdparm command. Unfortunately, this setting gets lost after resuming from hibernate.

I'd like to run these hdparm command right after the system has resumed. How/Where to install them?

1 Answer

You can do this by creating a script in /etc/pm/sleep.d

sudo nano /etc/pm/sleep.d/99_hdparm_thaw

Use this as your base:

#!/bin/sh
PATH=/sbin:/usr/sbin:/bin:/usr/bin
case "${1}" in hibernate) # this is where you put something you want to run before hibernating ;; resume|thaw) # this is where you put something you want to run on resume/thaw ;;
esac

You will then need to make sure it is executable:

sudo chmod +x /etc/pm/sleep.d/99_hdparm_thaw

There are other scripts in that directory, which is where I came up with the base. You may be able to use those for ideas.

Also, those scripts are run in alphabetical order. This is why I chose to name it 99_hdparm_thaw, so it will be the last run script.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy