AnsweredAssumed Answered

How to change poweroff to sleep mode

Question asked by victor Wang on Feb 28, 2018
Latest reply on Feb 28, 2018 by Wigros Sun

Hi All,

I'm using Ubuntu 14.04 for my OS system and using i.MX6 sabreSD as my cpu.

My image is build by Yocto project.

 

Here is the issue now.

In my system I will have the command "poweroff"  to turn off my machine.

But now I'm trying to change the command, when I run the command "poweroff" in system I need it to run into sleep mode.

This is the log when I run the poweroff now.

 

Stopping Authorization Manager...
[ OK ] Stopped target Graphical Interface.
Stopping Light Display M Stopping Session c2 of user root.
[ OK ] Stopped target Timers.
Stopping User Manager for UID 1001...
Stopping User Manager for UID 0...
Stopping Session c1 of user hermes.
Stopping Disk Manager...
[ OK ] Stopped Daily Cleanup of Temporary Directories.
[ OK ] Stopped target Multi-User System.
Stopping LSB: Start busybox udhcpd at boot time...
Stopping LSB: Starts and stops Wicd...
Stopping Avahi mDNS/DNS-SD Stack...
Stopping LSB: Advanced IEEE 802.11 management daemon...
Stopping LSB: set CPUFreq kernel parameters...
Stopping LSB: Apache2 web server...
Stopping Modem Manager...
Stopping System Logging Service...
Starting Unattended Upgrades...
[ OK ] Stopped target Login Prompts.
Stopping Serial Getty on ttymxc0...
Stopping Getty on tty1...
Stopping OpenBSD Secure Shell server...
Stopping Regular background program processing daemon...
[ OK ] Stopped Session c3 of user root.
Stopping D-Bus System Message Bus...
[ OK ] Stopped D-Bus System Message Bus.
[ OK ] Stopped Regular background program processing daemon.
[ OK ] Stopped OpenBSD Secure Shell server.
[ OK ] Stopped Modem Manager.
[ OK ] Stopped System Logging Service.
[ OK ] Stopped Avahi mDNS/DNS-SD Stack.
[ OK ] Stopped Authorization Manager.
[ OK ] Stopped Serial Getty on ttymxc0.
[ OK ] Stopped Getty on tty1.
[ OK ] Stopped Light Display Manager.
[ OK ] Stopped User Manager for UID 1001.
[ OK ] Stopped Disk Manager.
[ OK ] Stopped User Manager for UID 0.
[ OK ] Stopped Session c2 of user root.
[ OK ] Stopped Session c1 of user hermes.
[ OK ] Stopped LSB: Advanced IEEE 802.11 management daemon.
[ OK ] Stopped LSB: Start busybox udhcpd at boot time.
[ OK ] Stopped LSB: Starts and stops Wicd.
[ OK ] Started Unattended Upgrades.
[ OK ] Stopped LSB: set CPUFreq kernel parameters.
Stopping LSB: Load kernel modules needed to enable cpufreq scaling...
[ OK ] Removed slice User Slice of root.
[ OK ] Removed slice User Slice of hermes.
Stopping Login Service...
[ OK ] Removed slice system-getty.slice.
[ OK ] Stopped /etc/rc.local Compatibility.
Stopping Permit User Sessions...
[ OK ] Removed slice system-serial\x2dgetty.slice.
[ OK ] Stopped Login Service.
[ OK ] Stopped Permit User Sessions.
[ OK ] Stopped LSB: Load kernel modules needed to enable cpufreq scaling.
[ OK ] Stopped LSB: Apache2 web server.
[ OK ] Stopped target Remote File Systems.
[ OK ] Stopped target Remote File Systems (Pre).
[ OK ] Stopped target Basic System.
[ OK ] Stopped target Slices.
[ OK ] Removed slice User and Session Slice.
[ OK ] Stopped target Sockets.
[ OK ] Closed D-Bus System Message Bus Socket.
[ OK ] Closed Avahi mDNS/DNS-SD Stack Activation Socket.
[ OK ] Stopped target System Initialization.
Stopping LSB: NFS support files common to client and server...
Stopping Load/Save Random Seed...
[ OK ] Stopped target Encrypted Volumes.
[ OK ] Stopped target Swap.
Stopping Update UTMP about System Boot/Shutdown...
[ OK ] Closed Syslog Socket.
[ OK ] Stopped target Paths.
[ OK ] Stopped Forward Password Requests to Wall Directory Watch.
[ OK ] Stopped Dispatch Password Requests to Console Directory Watch.
[ OK ] Stopped Load/Save Random Seed.
[ OK ] Stopped Update UTMP about System Boot/Shutdown.
[ OK ] Unmounted /run/rpc_pipefs.
[ OK ] Stopped LSB: NFS support files common to client and server.
[ OK ] Stopped target RPC Port Mapper.
Stopping LSB: RPC portmapper replacement...
[ OK ] Stopped target System Time Synchronized.
Stopping Network Time Synchronization...
[ OK ] Stopped Network Time Synchronization.
[ OK ] Stopped Create Volatile Files and Directories.
[ OK ] Stopped LSB: RPC portmapper replacement.
[ OK ] Stopped target Network is Online.
[ OK ] Stopped target Network.
Stopping Raise network interfaces...
[ OK ] Stopped Raise network interfaces.
[ OK ] Stopped Apply Kernel Variables.
[ OK ] Stopped target Local File Systems.
Unmounting /run/user/1001...
Unmounting /run/user/0...
Unmounting /media/hermes/0075-5826...
[ OK ] Unmounted /run/user/1001.
[ OK ] Unmounted /run/user/0.
[ OK ] Unmounted /media/hermes/0075-5826.
[ OK ] Reached target Unmount All Filesystems.
[ OK ] Stopped target Local File Systems (Pre).
[ OK ] Stopped Create Static Device Nodes in /dev.
[ OK ] Stopped Remount Root and Kernel File Systems.
[ OK ] Reached target Shutdown.
systemd-shutdown[1]: Sending SIGTERM to remaining processes...
systemd-journald[178]: Received SIGTERM from PID 1 (systemd-shutdow).
systemd-shutdown[1]: Sending SIGKILL to remaining processes...
systemd-shutdown[1]: Unmounting file systems.
systemd-shutdown[1]: Remounting '/' read-only with options 'data=ordered'.
EXT4-fs (mmcblk3p2): re-mounted. Opts: data=ordered
systemd-shutdown[1]: Remounting '/' read-only with options 'data=ordered'.
EXT4-fs (mmcblk3p2): re-mounted. Opts: data=ordered
systemd-shutdown[1]: All filesystems unmounted.
systemd-shutdown[1]: Deactivating swaps.
systemd-shutdown[1]: All swaps deactivated.
systemd-shutdown[1]: Detaching loop devices.
systemd-shutdown[1]: All loop devices detached.
systemd-shutdown[1]: Detaching DM devices.
systemd-shutdown[1]: All DM devices detached.
systemd-shutdown[1]: Powering off

reboot: Power down

 

I had try to find the file in linux driver, when it poweroff it will run into this file "kernel/reboot.c".

And I found that it will run below function.

void kernel_power_off(void)
{
kernel_shutdown_prepare(SYSTEM_POWER_OFF);
if (pm_power_off_prepare)
pm_power_off_prepare();
migrate_to_reboot_cpu();
syscore_shutdown();
pr_emerg("winmate victor Power down\n");
kmsg_dump(KMSG_DUMP_POWEROFF);
machine_power_off();
}
EXPORT_SYMBOL_GPL(kernel_power_off);

And if I mark the content in kernel_power_off out it will kernel panic when I run "poweroff".

 

How can I change poweroff to sleep mode ?

 

Thanks in Advanced!

Outcomes