Somehow I could install Ubuntu 18.10 without creating any SWAP partition nor I seem to have a SWAP file. I wonder if I still could get hibernation to work, without having both of them. I tried already creating a SWAP-file and hibernate with it, but that did not work.
Is there a way around the SWAP file and get hibernation running?
I fear creating a SWAP file is your only option. Your RAM state needs to be held somewhere on the disk while power is off. Maybe you created too small SWAP – it is recommended to have the SWAP space at least as big as your RAM (+ some small reserve). I have Ubuntu 18.10 with 16 GB of RAM and 19 GB of SWAP file and it works well.
Nevertheless, it seems you didn't tell the system it should use SWAP to resume from hibernation. Modify
/etc/default/grub
(sudoedit /etc/default/grub
), edit the lineGRUB_CMDLINE_LINUX_DEFAULT
and put there parametersresume
(with your /dev/ UID of partition having the SWAP file) andresume_offset
with the starting value of physical_offset of this swap.(You'll get this value by checking output of
sudo filefrag -v /swapfile | head
.)Finally, reload by
sudo update-grub
.For more thorough answer about setting GRUB, see an excellent section Hibernation using a swap file: How can I hibernate on Ubuntu 16.04?
Tell us if you succeeded.
Yes you can find answers elsewhere searching for hibernate + linux + file but I post the super-short answer:
sudo filefrag -v /swapfile |grep " 0:"| awk '{print $4}'
in my system for example it gives: 57643008.. (for the sake of curiosity this is the offset of the swap file the file system...) put away this number (we will use it later) and find another number:
lsblk -o UUID,MOUNTPOINT
in my system for example it gives:
0ec9c519-c7ec-43e3-b812-967d81842458 /home
eb343dae-82e4-4155-9026-18c891d3252b /
since the swap file is in / it is this the UUID of interest. Then add to /etc/default/grub:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash resume=UUID=eb343dae-82e4-4155-9026-18c891d3252b resume_offset=57643008"
sudo update-grub
and you are done (use your UUID and OFFSET numbers obviously). Test it with the command:
sudo hibernate
PS: according to some kernel docs that I can't find now, it should be sufficient a swap file of half of your RAM size or less (they say 2/5). Check with: cat /sys/power/image_size