Linux makes an image from current memory contents and system states using swap space. When user tries to resume, the make-shift image is loaded. As the system states are stored in persistence storage, memory can be powered off completely. This makes hibernation more power-saving than suspend-to-ram. On the other hand, resuming the system from contents in the disk may be slow. Thus resuming in general takes longer time.
Because of its nature, hibernation is much trickier to set up. For example, you'll need a swap partion or swap file for the hibernation image. See See Hibernation in Power management/Suspend and hibernate from Arch Linux wiki.
The behavior of suspension can be obeserved in dmesg
by runing pm-hibernate
after enable the /sys/power/pm_debug_messages
. The pm-hibernate
is part of the pm-utils
tool. You can install them on Ubuntu by:
$ sudo apt install pm-utils
To enable the pm_debug_messages
, simply cat
1 into it:
$ sudo sh -c 'echo 1 > /sys/power/pm_debug_messages'
Doing this will enable extra messages regarding power management in the dmesg
.
Finally, to start doing hibernation:
$ sudo pm-hibernate
Note that the machine hasn't setup swap files properly, so those are not catual hiberanation behaviors. That being said, some notable differences between suspend-to-ram can already be observed. For example, fomr logs you could see kernel trying to create image for hibernation.
[ 486.343412] PM: hibernation: Configured hibernation resume from disk to 8388610
[ 486.343416] PM: hibernation: Hibernation image partition 8:2 present
[ 486.343416] PM: hibernation: Looking for hibernation image.
[ 486.343419] PM: Image not found (code -16)
[ 486.343420] PM: hibernation: Hibernation image not present or could not be loaded.
[ 486.343434] PM: hibernation: Hibernation mode set to 'platform'
[ 486.414408] PM: hibernation: hibernation entry
[ 486.430803] Filesystems sync: 0.016 seconds
[ 486.430808] Freezing user space processes ... (elapsed 0.002 seconds) done.
[ 486.432950] OOM killer disabled.
[ 486.433076] PM: hibernation: Marking nosave pages: [mem 0x00000000-0x00000fff]
[ 486.433079] PM: hibernation: Marking nosave pages: [mem 0x00058000-0x00058fff]
[ 486.433080] PM: hibernation: Marking nosave pages: [mem 0x000a0000-0x000fffff]
[ 486.433083] PM: hibernation: Marking nosave pages: [mem 0x63355000-0x63355fff]
[ 486.433085] PM: hibernation: Marking nosave pages: [mem 0x63355000-0x63355fff]
[ 486.433086] PM: hibernation: Marking nosave pages: [mem 0x78d01000-0x78d48fff]
[ 486.433088] PM: hibernation: Marking nosave pages: [mem 0x78d5d000-0x78d8efff]
[ 486.433090] PM: hibernation: Marking nosave pages: [mem 0x78e39000-0x78e8efff]
[ 486.433093] PM: hibernation: Marking nosave pages: [mem 0x78ed4000-0x78efefff]
[ 486.433095] PM: hibernation: Marking nosave pages: [mem 0x78f85000-0x78fdefff]
[ 486.433098] PM: hibernation: Marking nosave pages: [mem 0x79000000-0xffffffff]
[ 486.435101] PM: hibernation: Basic memory bitmaps created
[ 486.435164] PM: hibernation: Preallocating image memory
[ 487.293741] PM: hibernation: Allocated 1489814 pages for snapshot
[ 487.293745] PM: hibernation: Allocated 5959256 kbytes in 0.85 seconds (7010.88 MB/s)
[ 487.293747] Freezing remaining freezable tasks ... (elapsed 0.001 seconds) done.
[ 487.295314] printk: Suspending console(s) (use no_console_suspend to debug)
[ 487.446347] PM: freeze of devices complete after 151.027 msecs
[ 487.472987] PM: late freeze of devices complete after 26.634 msecs
[ 487.473373] ACPI: EC: interrupt blocked
[ 487.474286] PM: noirq freeze of devices complete after 1.263 msecs
[ 487.474289] PM: end freeze of devices complete after 27.936 msecs
[ 487.474290] ACPI: PM: Preparing to enter system sleep state S4
[ 487.474865] ACPI: EC: event blocked
[ 487.474866] ACPI: EC: EC stopped
[ 487.474866] ACPI: PM: Saving platform NVS memory
[ 487.475044] Disabling non-boot CPUs ...
[ 487.476593] smpboot: CPU 1 is now offline
[ 487.487157] smpboot: CPU 2 is now offline
[ 487.489168] smpboot: CPU 3 is now offline
[ 487.494976] smpboot: CPU 4 is now offline
[ 487.500770] smpboot: CPU 5 is now offline
[ 487.502399] smpboot: CPU 6 is now offline
[ 487.504000] smpboot: CPU 7 is now offline
[ 487.504306] Checking wakeup interrupts
[ 487.504308] Calling kvm_suspend+0x0/0x30 [kvm]
[ 487.504347] Calling mce_syscore_suspend+0x0/0x20
[ 487.504350] Calling ledtrig_cpu_syscore_suspend+0x0/0x20
[ 487.504353] Calling timekeeping_suspend+0x0/0x2e0
[ 487.504384] Calling irq_gc_suspend+0x0/0x80
[ 487.504387] Calling save_ioapic_entries+0x0/0x170
[ 487.504455] Calling i8259A_suspend+0x0/0x40
[ 487.504459] Calling fw_suspend+0x0/0x20
[ 487.504461] Calling acpi_save_bm_rld+0x0/0x30
[ 487.504471] Calling intel_epb_save+0x0/0x40
[ 487.504473] Calling lapic_suspend+0x0/0x30
[ 487.504483] PM: hibernation: Creating image:
[ 487.738865] PM: hibernation: Need to copy 1462837 pages
[ 487.738867] PM: hibernation: Normal pages needed: 1462837 + 1024, available pages: 2699502
[ 489.139089] PM: hibernation: Image created (1462837 pages copied)
[ 487.504861] ACPI: PM: Restoring platform NVS memory
[ 487.504899] ACPI: EC: EC started
[ 487.504900] Calling init_counter_refs+0x0/0x60
[ 487.504905] Calling lapic_resume+0x0/0x30
[ 487.504927] Calling intel_epb_restore+0x0/0x90
[ 487.504928] Calling acpi_restore_bm_rld+0x0/0x70
[ 487.504934] Calling irqrouter_resume+0x0/0x60
[ 487.504937] Calling i8259A_resume+0x0/0x40
[ 487.505081] Calling i8237A_resume+0x0/0xd0
[ 487.505143] Calling ioapic_resume+0x0/0x150
[ 487.505166] Calling irq_gc_resume+0x0/0x80
[ 487.505169] Calling irq_pm_syscore_resume+0x0/0x20
[ 487.505177] Calling timekeeping_resume+0x0/0x170
[ 487.505210] Timekeeping suspended for 0.951 seconds
[ 487.505220] Calling ledtrig_cpu_syscore_resume+0x0/0x20
[ 487.505224] Calling mce_syscore_resume+0x0/0x30
[ 487.505237] Calling microcode_bsp_resume+0x0/0x70
[ 487.505240] Calling kvm_resume+0x0/0x30 [kvm]
[ 487.505279] Enabling non-boot CPUs ...
[ 487.505331] x86: Booting SMP configuration:
[ 487.505332] smpboot: Booting Node 0 Processor 1 APIC 0x2
[ 487.511635] CPU1 is up
[ 487.511672] smpboot: Booting Node 0 Processor 2 APIC 0x4
[ 487.516582] CPU2 is up
[ 487.516612] smpboot: Booting Node 0 Processor 3 APIC 0x6
[ 487.521457] CPU3 is up
[ 487.521487] smpboot: Booting Node 0 Processor 4 APIC 0x1
[ 487.526552] CPU4 is up
[ 487.526580] smpboot: Booting Node 0 Processor 5 APIC 0x3
[ 487.531500] CPU5 is up
[ 487.531531] smpboot: Booting Node 0 Processor 6 APIC 0x5
[ 487.536754] CPU6 is up
[ 487.536782] smpboot: Booting Node 0 Processor 7 APIC 0x7
[ 487.541815] CPU7 is up
[ 487.545327] ACPI: PM: Waking up from system sleep state S4
[ 487.547392] ACPI: EC: interrupt unblocked
[ 487.566645] PM: noirq thaw of devices complete after 19.437 msecs
[ 487.567123] PM: early thaw of devices complete after 0.417 msecs
[ 487.567236] ACPI: EC: event unblocked
[ 487.894462] ata1: SATA link up 6.0 Gbps (SStatus 133 SControl 300)
[ 487.895574] ata1.00: unexpected _GTF length (8)
[ 487.896233] ata1.00: unexpected _GTF length (8)
[ 487.896389] ata1.00: configured for UDMA/133
[ 491.095942] PM: thaw of devices complete after 3528.747 msecs
[ 491.096252] PM: hibernation: Writing hibernation image.
[ 491.097584] PM: Using 3 thread(s) for compression
[ 491.097586] PM: Compressing and saving image data (1465695 pages)...
[ 491.097593] PM: Image saving progress: 0%
[ 491.674061] PM: Image saving progress: 10%
[ 492.233351] PM: Image saving progress: 20%
[ 493.631248] PM: Image saving progress: 30%
[ 495.120169] PM: Image saving progress: 40%
[ 496.439402] PM: Image saving progress: 50%
[ 498.121164] PM: Image saving progress: 60%
[ 499.713156] PM: Image saving progress: 70%
[ 501.333536] PM: Image saving progress: 80%
[ 501.676735] PM: hibernation: Wrote 5862780 kbytes in 10.57 seconds (554.66 MB/s)
[ 501.878115] PM: hibernation: Basic memory bitmaps freed
[ 501.878120] OOM killer enabled.
[ 501.878121] Restarting tasks ...
[ 501.878210] usb 2-4: USB disconnect, device number 2
[ 501.881219] done.
[ 501.947069] video LNXVIDEO:00: Restoring backlight state
[ 501.947267] PM: hibernation: hibernation exit