File:  [NetBSD Developer Wiki] / wikisrc / tutorials / how_to_poweroff_at_shutdown.mdwn
Revision 1.2: download - view: text, annotated - select for diffs
Sun Feb 5 07:14:36 2012 UTC (3 years, 9 months ago) by schmonz
Branches: MAIN
CVS tags: HEAD

If you have ATX hardware, for various reasons, you might want your box to poweroff by itself when you shut it down. To achieve this you have to enable [apm(8)]( in the kernel. Here's how to do it: 



#  Obtaining the Sources 

If you are running 3.0, you can get the Sources from the NetBSD FTP Server or from a [Mirror](Get BSD) close to you. If you are running current, you should check out the Sources from a CVS Mirror close to you. 

    # cd /
    # ftp
    # tar -zxf syssrc.tgz

#  Configure the kernel 

Edit the file `/usr/src/sys/arch/i386/conf` and uncomment _apm_ to enable APM, it should look like: 
    apm0	at mainbus0			# Advanced power management

Alternatetively, you might want to customize (uncomment) these options: 
    # Tuning for power management, see apm(4) for more details.
    #options        APM_NO_IDLE             # Don't call BIOS CPU idle function
    #options        APM_V10_ONLY            # Use only the APM 1.0 calls
    #options        APM_NO_POWEROFF         # Don't power off on halt(8)
    #options        APM_POWER_PRINT         # Print stats on the console
    #options        APM_DISABLE_INTERRUPTS=0 # Don't disable interrupts

#  Build the kernel 
    # config GENERIC_APM
    # cd ../compile/GENERIC_APM
    # make depend; make

If everything went OK, your new APM-enabled-kernel should be located in ./netbsd 

#  Install the kernel 
    # mv /netbsd /netbsd.old
    # cp netbsd /
    # shutdown -r now

Now when you shutdown the box it should poweroff by itself, without the need for the power button to be pressed. 

#  Troubleshooting 

If something went wrong, test with [apm(8)]( Sample output: 

    root@antfarm:~# apm
    Battery charge state: absent
    Battery remaining: 0 percent (0 minutes)
    A/C adapter state: connected
    Power management enabled

##  apmd

You will need the apm Daemon _apmd_ running for setting your Notebook fall into sleep. For that please add: 

to your /etc/rc.conf Also see [apmd(8)]( for more power management issues. 

CVSweb for NetBSD wikisrc <> software: FreeBSD-CVSweb