[SOLVED] How to start script from /etc/pm/sleep.d after resume from hibernate?
FedoraForum.org - Fedora Support Forums and Community
Results 1 to 6 of 6
  1. #1
    Join Date
    Jan 2010
    Location
    Poland
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to start script from /etc/pm/sleep.d after resume from hibernate?

    Hi.

    I have a little problem. Long time ago i've added hdparm -B 254 /dev/sda to rc.local (to extend lifetime of my laptop HDD).

    But as far i know, this value from rc.local is reset to default after hibernation (from 254 to 128) and after every laptop resume i need to tap in the console hdparm -B 254 /dev/sda again and again.

    I've read that good solution is add new script to /etc/pm/sleep.d and that script will be executed after resume from sleep or hibernation. But i've read that syntax of this script is a little bit more complicated than simple hdparm 254 and chmod+x on script. And in matter of fact - it does not worked.

    It takes me 2 hours of testing scripts for /etc/pm/sleep.d but without sucess. I've copied one script from web and put hdparm command in it, but on every resume - hdparm is still reset to default 128 value.

    Script:

    Code:
    case $1 in
         suspend|suspend_hybrid|hibernate)
    	hdparm -B 254 /dev/sda
            ;;
    esac
    I've named it 00hdparm254, chmod+x but it does not work.

    The question is: what i need to execute hdparm -B 254 /dev/sda after wake laptop from sleep or hibernation? Script in /etc/pm/sleep.d - i know, but...

    I will be grateful for every advice because i'm lack of idea.

  2. #2
    Join Date
    Oct 2010
    Location
    Canberra
    Posts
    3,511
    Mentioned
    7 Post(s)
    Tagged
    1 Thread(s)

    Re: How to start script from /etc/pm/sleep.d after resume from hibernate?

    I have not tried this, but from the script example at
    http://ckirbach.wordpress.com/2012/1...-resumewakeup/

    I would guess that your function is being called as it is putting the system to sleep, but you need it to happen when it wakes up, ie with thaw or resume.

    User error. Please replace user and try again

  3. #3
    Join Date
    Jun 2010
    Location
    Lost...
    Posts
    1,300
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How to start script from /etc/pm/sleep.d after resume from hibernate?

    I think that it is now systemd that is doing the suspend/hibernation, and not pm-utils.
    You can try to add a script /usr/lib/systemd/system-sleep/local.sh
    Code:
    #!/bin/bash
    [ "$1" = "post" ] && exec /usr/sbin/hdparm -B 254 /dev/sda
    exit 0
    Don't forget to run 'chmod +x' on it.

    Details are in 'man systemd-suspend.service'.
    :confused:

  4. #4
    Join Date
    Oct 2010
    Location
    Canberra
    Posts
    3,511
    Mentioned
    7 Post(s)
    Tagged
    1 Thread(s)

    Re: How to start script from /etc/pm/sleep.d after resume from hibernate?

    Quote Originally Posted by Skull One
    I think that it is now systemd that is doing the suspend/hibernation, and not pm-utils.
    That will depend on which version of Fedora is being used, which the OP neglected to mention.
    I would hope that /etc/pm/sleep.d doesn't exist if the functionality is being handled by systemd.

    User error. Please replace user and try again

  5. #5
    Join Date
    Jan 2010
    Location
    Poland
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How to start script from /etc/pm/sleep.d after resume from hibernate?

    Quote Originally Posted by Skull One
    I think that it is now systemd that is doing the suspend/hibernation, and not pm-utils.
    You can try to add a script /usr/lib/systemd/system-sleep/local.sh
    Code:
    #!/bin/bash
    [ "$1" = "post" ] && exec /usr/sbin/hdparm -B 254 /dev/sda
    exit 0
    Don't forget to run 'chmod +x' on it.

    Details are in 'man systemd-suspend.service'.

    Yes, yes - it seems that this script solved my problem I'm not up to date with changes in Fedora - i'm using Linux from 7 years but i'm not watching under the hood - only sometimes when i need something like in this topic

    I was confused - especially when most info are about pm I this this is the answer why pm scripts was not working.

    That will depend on which version of Fedora is being used, which the OP neglected to mention.
    Right... I forgot to mention about Fedora 20


    I am grateful - without Your help i don't think that i will be able to find the answer

  6. #6
    Join Date
    Jun 2010
    Location
    Lost...
    Posts
    1,300
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How to start script from /etc/pm/sleep.d after resume from hibernate?

    Quote Originally Posted by ocratato
    I would hope that /etc/pm/sleep.d doesn't exist if the functionality is being handled by systemd.
    You're right: /etc/pm/* belongs to the package 'filesystem'. I think that it should belong to pm-utils instead. There is some cleanup to do, unless those directories are used by something else?.
    :confused:

Similar Threads

  1. debug resume from hibernate
    By andyzhu35 in forum Using Fedora
    Replies: 1
    Last Post: 21st January 2012, 03:31 AM
  2. hibernate: resume problem again
    By andyzhu35 in forum Using Fedora
    Replies: 0
    Last Post: 29th December 2011, 01:37 AM
  3. Sleep & Hibernate
    By jvillain in forum F17 Development Forum
    Replies: 1
    Last Post: 8th September 2011, 08:10 AM
  4. Kick off script after resume from sleep (FC7)
    By rollingsr in forum Using Fedora
    Replies: 0
    Last Post: 19th August 2007, 02:04 AM
  5. Sleep/Suspend/Hibernate
    By chrisndebb in forum Using Fedora
    Replies: 2
    Last Post: 4th June 2006, 05:38 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •