Description
This test case tests hibernation via systemd.
Setup
- Check that the hibernate is supported on your platform:
$ cat /sys/power/state
- If there is disk in the output, it signals that the hibernate is supported.
- Check your swap:
$ swapon -s
- You may see something like:
Filename Type Size Used Priority /dev/dm-2 partition 3997692 1856 -1
- If you are running from the live medium note the filename of the swap partition with the highest priority (/dev/dm-2 in this case). It will be your resume partition. You will need this filename later when resuming. It is not needed if running installed system.
- Check your physical RAM size and swap size by:
$ free
How to test
- Run the following command:
# systemctl hibernate
- Wait for hibernation process to complete (it typically takes cca. 2-60 seconds).
- Resume by hitting the power button.
- If you hibernated from the installed system it should work out of the box but if you hibernated from the live medium you may need to follow the following steps during the boot:
- Select boot from the live media.
- When the boot manager displays make sure the default option is selected (e.g. "Default" or "Start PM Test", the exact value depends on the medium/boot manager you are using) and edit the kernel boot parameters (mostly by hitting the Tab).
- Append to the kernel boot parameters resume=/dev/dm-2 (replace /dev/dm-2 by your swap partition, it is the filename you previously noted during the setup) In case your resume partition is still not recognized you may try to add dracut boot parameters from troubleshooting.
- Boot (mostly by hitting Enter).
Expected Results
- System correctly hibernates.
- System correctly resumes.
Troubleshooting
For cases you booted from the live medium and there is no active swap partition, but you have swap on the host disk LVM/LUKS (i.e. it wasn't auto-detected) you may try the following steps (you can als combine them in cases you have LVM on LUKS, etc.). In case nothing helps feel free to skip this test case.
LVM
- Scan for logical volumes:
# vgscan --mknodes # vgchange -a y # lvscan
- Find your swap (e.g. /dev/vg0/swap) and activate it:
# swapon /dev/vg0/swap
You may also boot with the following dracut parameters (hit Tab in the live medium boot menu to add them) that should do the same (i.e. use swap on vg0/swap):
rd.lvm.vg=vg0 rd.lvm.lv=vg0/swap
LUKS
- Unlock encrypted partition (e.g. /dev/sda2):
# cryptsetup luksOpen /dev/sda2 crypt1
- Or if you know the UUID (it can be obtained by cryptsetup luksUUID /dev/sda2) you may use:
# cryptsetup luksOpen UUID=luks-fa649b04-5ede-496f-9168-331161a2b833 crypt1
- Activate swap:
# swapon /dev/mapper/swap1
You may also boot with the following dracut parameters (hit Tab in the live media boot menu to add them) that should do the same (please note only UUID identification is supported):
rd.luks.uuid=luks-fa649b04-5ede-496f-9168-331161a2b833