Search code examples
linuxshellsshinitnas

Using "Deep Sleep" / "Power Saving" mode through SSH in NAS OS?


I'm an user of a LACIE 2-BIG-NAS. Until the NAS OS 4.1.9.2 version I had the "Deep Sleep" option in the Home menu, but after the next upgrade this option was removed. I tried to downgrade to the previous version following the manual steps but it was not able, only upgrades are available. I asked to the support service of Lacie but the their solution is to backup my data and do a fresh install and upgrade until 4.1.9.2. This isn't a solution from my point of view.

Now I tried to get into deep sleep mode from a SSH conection because NAS OS is a linux-based SO. I tried all the posibilities with initng command (sudo ngc -0 and -1) which is used by the NAS OS, but it's imposible to wake on lan the NAS (the OS powers off but no answer from the wake-on-lan request).

The code for wake on lan is correct because when I schedule the deep sleep mode I can do it, but I don`t know how to get deep sleep mode on-demand.

I googled and try other options but I think these were the closest to the solution.

Please, can you help me to find the correct ssh command line to get the deep sleep mode in the Lacie 2-big-nas?

Best regards.


Solution

  • I found the solution in cron. There is a scheduled command in /sbin/smart_shutdown so, if you execute that script as root, the 2-big-nas go into the Deep sleep mode.

    This is the content of the script "smart_shutdown":

    #!/bin/sh  
    #  
    # This script is intended to handle a user shutdown request.  
    # It will probably (but not necesseraly) called from a crontab.  
    #  
    
    PATH=/bin:/sbin:/usr/bin:/usr/sbin
    
    valid_runlevels="shutdown halt sleep reboot"
    
    runlevel="sleep"
    
    check_runlevel()
    {
    
      req_runlevel=$1
    
      for valid in ${valid_runlevels}; do  
        [ "${req_runlevel}" = "${valid}" ] && return 0
      done
    
      logger "smart_shutdown: request invalid runlevel ${req_runlevel}"
      return 1  
    }
    
    request_runlevel()
    {
      dbus-send --system --dest=com.lacie.Unicorn --type=method_call --print-reply --reply-timeout=1000 /com/lacie/Unicorn com.lacie.Unicorn.switch_runlevel string:"$1"
    }
    
    if [ ! -z "$1" ]; then 
      check_runlevel "$1" || exit 1
      runlevel=$1
    fi
    
    request_runlevel ${runlevel}
    
    exit 0  
    

    I hope you can take advantage of this in the future.