- swapon on swapfile;
- suspend;
- countdown;
- wakeup;
- copy RAM to swapfile;
- suspend again;
while kept energized, will return a simple suspension, high speed. But, if power's out, the workload is saved on swapfile.
Is to less io, using swapfile only to hibernate, but speed up return, using suspension by default.
Suspend is:
- slow energy mode
if shutdown, lose workload
Hybrid sleep is:
- store ram in swap/file immediately AND suspend.
if it is turned off, retrieve the job copy swap/file to RAM memory. if only suspend, return. But, it ALWAYS copy RAM to disk, even with high battery or charger. a TBW waste if you return from suspension in a short time.
Suspend then hibernate is:
- slow energy mode;
- wakeup to verify battery level;
- if bigger 5%, suspend, else, copy ram to disk, and shutdown;
if 5% is not enough power for the copy operation (common especially on devices with old battery, which skip percentages), workload is lost.
Smart suspend hibernate it's the best balance between avoiding writing to disk but being reliable about the hibernation operation.
- mkdir (or btrfs su cr) /var/swap;
- chattr +C /var/swap;
- chcom -R unconfined_u:object_r:var_t:s0 /var/swap;
- cd /var/swap;
- btrfs fi mkswapfile --size (size)G swapfile;
- mkswap swapfile (that will define unconfined_u:object_r:swapfile_t:s0 on swapfile, check with ls -Z, manual define using chcon);
- btrfs inspect-internal map-swapfile -r swapfile (is resume_offset);
- add resume device and resume_offset on bootloader config;
- add resume support on initrd.