Page 4 of 4 FirstFirst ... 234
Results 31 to 34 of 34

Thread: Disconnect USB ports in sleep mode

  1. #31
    Join Date
    Apr 2006
    Location
    Coventry
    Beans
    1,379
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: Disconnect USB ports in sleep mode

    Thanks for the link. It looks exactly like what I need.

    How could I set it up so that this happens before suspend and undo's after I come out of suspend?

  2. #32
    Join Date
    Dec 2008
    Location
    UK
    Beans
    589
    Distro
    Ubuntu Mate 22.04 Jammy Jellyfish

    Re: Disconnect USB ports in sleep mode

    OK, I put the script shown below in directory
    /usr/lib/pm-utils/sleep.d

    I named it 85test (bit of a guess, the scripts in this directory run in sequence according to the 2-digit prefix) and made it executable with
    Code:
    sudo chmod ugo+x 85test
    Script:
    Code:
    #!/bin/sh
    ##
    ## suspend-example.sh
    ##
    case $1 in
       suspend)
         ## COMMANDS THAT YOU WISH TO RUN BEFORE SUSPEND
         echo suspend > /var/log/miketest.txt
       ;;
       resume)
         ## COMMANDS THAT YOU WISH TO RUN AFTER RESUME
         echo resume >> /var/log/miketest.txt
       ;;
       hibernate)
         ## COMMANDS THAT YOU WISH TO RUN BEFORE HIBERNATE
         echo hibernate
       ;;
       thaw)
         ## COMMANDS THAT YOU WISH TO RUN AFTER RESUME FROM SUSPEND TO DISK
         echo thaw
       ;;
    esac
    This produced a file /var/log/miketest.txt with two lines saying 'suspend' and 'resume' when I did the suspend/resume operation.
    So if the echo commands I described earlier work OK you should be able to just plug them into the script above instead of the logging commands.
    Actually you might want to include some logging commands as well as the USB related commands while you're testing, just to prove the script is running, then remove them when working OK.

    Credit: Script sample was found here:
    http://myricci.com/index.php?option=...id=41&Itemid=9
    Last edited by mikechant; January 26th, 2010 at 07:56 PM. Reason: add credit

  3. #33
    Join Date
    Apr 2006
    Location
    Coventry
    Beans
    1,379
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: Disconnect USB ports in sleep mode

    Not sure what happened. But, usually when I click the power button it goes into Suspend. I pressed it this time and I hibernated. Perhaps a bug with the script?

  4. #34
    Join Date
    Jan 2006
    Location
    Waterloo, ON, Canada
    Beans
    214
    Distro
    Ubuntu 12.04 Precise Pangolin

    Smile Re: Disconnect USB ports in sleep mode

    All,

    This is the script I'm using now which has resolved the issue for me in Ubuntu 9.04.

    user@pc:/usr/lib/pm-utils/sleep.d$ cat 85usb_power_mgmt
    #!/bin/sh
    ##
    ## 85usb_power_mgmt
    ##
    case $1 in
    suspend)
    ## COMMANDS THAT YOU WISH TO RUN BEFORE SUSPEND
    echo "$(date): suspend" >> /var/log/usb_power_mgmt.txt
    ;;
    resume)
    ## COMMANDS THAT YOU WISH TO RUN AFTER RESUME
    echo "$(date): suspend-resume" >> /var/log/usb_power_mgmt.txt
    modprobe -r -v whci_hcd && modprobe -v whci_hcd
    ;;
    hibernate)
    ## COMMANDS THAT YOU WISH TO RUN BEFORE HIBERNATE
    echo "$(date): hibernate" >> /var/log/usb_power_mgmt.txt
    ;;
    thaw)
    ## COMMANDS THAT YOU WISH TO RUN AFTER RESUME FROM SUSPEND TO DISK
    echo "$(date): hibernate-thaw" >> /var/log/usb_power_mgmt.txt
    modprobe -r -v whci_hcd && modprobe -v whci_hcd
    ;;
    esac
    Which produces the following log:
    user@pc:/usr/lib/pm-utils/sleep.d$ cat /var/log/usb_power_mgmt.txt
    Sun Jun 27 17:58:21 EDT 2010: hibernate
    Sun Jun 27 17:59:40 EDT 2010: hibernate-thaw
    Sun Jun 27 18:00:37 EDT 2010: hibernate
    Sun Jun 27 18:49:19 EDT 2010: hibernate-thaw
    Sun Jun 27 20:22:51 EDT 2010: hibernate
    Sun Jun 27 20:23:57 EDT 2010: hibernate-thaw
    Sun Jun 27 20:32:58 EDT 2010: hibernate
    Sun Jun 27 20:34:00 EDT 2010: hibernate-thaw
    Sun Jun 27 20:36:14 EDT 2010: hibernate
    Sun Jun 27 20:37:24 EDT 2010: hibernate-thaw
    Sun Jun 27 20:48:46 EDT 2010: hibernate
    Sun Jun 27 20:49:54 EDT 2010: hibernate-thaw
    The important thing out of this is from the script:
    modprobe -r -v whci_hcd && modprobe -v whci_hcd
    Essentially this is removing the usb driver, and reloading it after resuming from suspend (RAM) or hibernation (disk). This worked for me in Ubuntu 9.04, but you might have to replace whci_hcd with a different driver...mileage may vary

    Can someone please confirm this resolves the issue for them on the same and/or different Ubuntu releases?
    ~Fermmy

Page 4 of 4 FirstFirst ... 234

Bookmarks

Posting Permissions

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