
 NVRAM-WakeUp

 (C) 2001-2004, Sergei Haller <Sergei.Haller@math.uni-giessen.de>

 $Id: README.reboot 828 2005-03-16 17:51:25Z bistr-o-math $


THE REBOOT PROBLEM(s):

First  of  all, there are TWO DIFFERENT problems which became known as
the REBOOT problem.  The only thing the two problems have in common is 
a possible way to be solved.

FIRST PROBLEM:
   The  changes  to  take  effect,  you need to restart (not halt) the 
   computer and wait until the BIOS runs (don't need to enter the BIOS
   setup).  Otherwise  the machine will wake up at the time programmed 
   PREVIOUSLY.

SECOND PROBLEM:
   Some boards do not wake up at all if powered off by APM methods.
   Some boards do not wake up at all if powered off by ACPI methods.
   Some boards do or do not wake up  depending  on the version of ACPI 
   drivers in the kernel.

   E.g., I found the following in the user's manual of the ASUS A7M266
   board (Thanks to Thomas Dingermann for the hint):

     ftp://ftp.asuscom.de/pub/ASUSCOM/HANDBUCH/Motherboard/Socket_A/AMD_Chipset/a7m266-104.pdf
   
     "... Automatic Power Up will not work if the system is powered
     down  by  operating systems such as Windows 98, that have ACPI 
     support enabled. ..."


SO WHAT CAN WE DO ABOUT THISE PROBLEMS?

FIRST PROBLEM
   is  dependent  on  the board. Thus there  is a configuration option
   need_reboot (see `man nvram-wakeup.conf' for more information).

   Dependent on that option and the changed values,  nvram-wakeup will
   tell the user if a reboot is needed.
  
   See below on how to initiate a reboot and an immediate shutdown.

SECOND PROBLEM
   is  dependent  on  your kernel and the power managment routines you 
   are using. nvram-wakeup can't know anything about it.

   What  you  can  do  is  just  always  to  reboot the machine before 
   powering off with the appropriate method.  In  you use  vdrshutdown
   just remove the case "0)" and rename the case "1)" in "0,1)".


REBOOT WITH A FOLLOWING IMMEDIATE POWEROFF

   The question  is:  How  to make  the computer  reboot and  shutdown
   afterwards automatically? There are two ways to do it.  vdrshutdown
   is prepared for both ways: It will
       - do  nothing,  if  some  error  occurred  while  executing  of
         nvram-wakeup. (E.g.  if the time  was in the past  or not far
         enough in the future)
       - shutdown (halt) the computer if there's no need to reboot.
         (FIRST PROBLEM)
       - prepare the system (according to A or B, see below) to be
         rebooted and halted. Reboot the system.

   The  general  idea  is the following: 
   
   1. Prepare  a boot option in your favourite boot loader which would 
      immediately  shutdown the computer with the "right" method. (see 
      below for details on how to do so). This step is done only once.

   2. Before  rebooting, tell the boot loader to use the prepared boot 
      option the next time (and only the next time).

   Details: (1L,2L for LILO; 1G,2G for GRUB)

   1L. If you  are using LILO, you can take a modified poweroff-kernel
       from the reboot package (see at nvram-wakeup homepage)

       prepare a new LILO section in /etc/lilo.conf. E.g.,
          image  = /boot/bzImage.poweroff
          label  = PowerOff
       end eventually add a line
          append="apm=off"
       or
          append="acpi=off"
       to this section.

       Another  way  to  do is to copy your default section with a new
       different label and to add the line
          append="0"
       to the new section. E.g.
          image = /boot/bzImage
          label = Linux
          root = /dev/hda1
 
          image = /boot/bzImage
          label = PowerOff
          root = /dev/hda1
          append="0"

       Remember to run lilo once after editing the lilo.conf file.

   1G. If you  are using GRUB, you can take a modified poweroff-kernel
       from the reboot package (see at nvram-wakeup homepage)
   
       prepare a new GRUB section in /boot/grub/menu.lst. E.g.,
          title PowerOff
          kernel /boot/bzImage.poweroff [... options ...]
       where options might be one of
          apm=off
       or
          acpi=off

       Another  way  to  do is to copy your default section with a new
       different label and to add the option 0 to the kernel. E.g.
          title Linux
          kernel /boot/bzImage [... other options ...]

          title PowerOff
          kernel /boot/bzImage [... same options ...] 0

       with  GRUB  you  have a third choice: create a new section with
       the halt command. E.g.,
          title PowerOff
          halt
       
       I  don't  use GRUB myself. This information was communicated to
       me by various people or collected in the VDR-Portal.

   2L. If you are using LILO, just call
         lilo -R <title-of-the-prepared-boot-option>
       and then reboot.

   2G. If you are using GRUB, it is slightly more complicated.
         echo "savedefault --default=<nr> --once quit" | grub
       or
         echo -e "savedefault --default=<nr> --once \nquit" | grub --batch
       where  <nr>  is  the number  of your prepared boot option. Note 
       that  the  first  entry  in  grub menu has the number 0, second 
       entry  has  the number 1 and so on. Note that this last command
       can last one minute or more.
 
       If  you  are using GRUB, I can't really help much since I never
       used it, but here is what Markus Loehner wrote about it:

       ML> To  make grub reselect the default entry it is necessary to
       ML> add
       ML>      savedefault default=0
       ML> to the poweroff entry in /boot/grub/menu.lst like
       ML>
       ML>   title PowerOff
       ML>     savedefault default=0
       ML>     kernel [...other options...]
       ML>
       ML> Otherwise  grub  leads  into  a  kind of deadlock in always
       ML> booting into Poweroff (--once doesn't seem to work).
       ML>
       ML> Also, to make grub  not to wait for hitting the RETURN key, 
       ML> it  is  necessary to comment out the gui relating lines  in
       ML> /boot/grub/menu.lst like
       ML>
       ML>   # gfxmenu (hd0,0)/message
       ML>   # color white/blue black/light-gray
       ML>
       ML> I use SuSE 8.1 and grub 0.92.



HOW TO FIND OUT IF THE OWN BOARD IS AFFECTED BY THE REBOOT PROBLEM(s)

   First  make  sure  that  nvram-wakeup  is  configured correctly and
   working. (Run  it with the --settime option, go into BIOS setup and
   check if everything was set correctly.
   
   * Let's say, we have 12:00. 
     - Run
         nvram-wakeup -s $((`date +%s` + 1200))
       the wakeup will be set for 12:15.
     - Reboot 
     - Now we have 12:05. Run
         nvram-wakeup -s $((`date +%s` +  601))
       the wakeup will be set for 12:10.
     - Shutdown.
     
     If the machine wakes up at 12:10 or at 12:15, you don't have  the
     SECOND PROBLEM. 
     
     If  it  doesn't  wake up until 12:20, you have the SECOND PROBLEM.
     In this case stop reading -- you need to reboot anyway.
     
     If  the  machine  wakes  up  at 12:15, you have the FIRST PROBLEM. 
     Stop reading and set need_reboot to ON_ANY_CHANGE.
     
     If the machine wakes up at 12:10, you  don't  seem  to  have  the 
     FIRST PROBLEM.  Though,  on  some machines the FIRST PROBLEM only 
     occurs if the status is changed (enabled <-> disabled). 

     - Let's say, now we have 12:30. Run
         nvram-wakeup -s $((`date +%s` + 1200))
       the wakeup will be set for 12:45.
     - Reboot 
     - Now we have 12:35. Run
         nvram-wakeup -d
       the wakeup will be disabled.
     - Shutdown.

     If  the  machine  wakes  up  at 12:45, you have the FIRST PROBLEM. 
     Stop reading and set need_reboot to ON_STAT.

     If  it  doesn't  wake up until 12:50, you have neither of the two
     problems.

   * There  are  also  other possible values for need_reboot (see `man 
     nvram-wakeup.conf'). Use them if you know what you are doing.

