I have configured a new Ubuntu installation in a Notebook to use a swap file, instead of using a swap partition.
By default is not possible to get Ubuntu to hibernate using a swap file, so I tried this tutorial, but it is specific to grub1, and Ubuntu now uses grub2.
Does anybody know how to do this?
Best Answer
Here is what I did to make it work with Ubuntu 18.04.
/swapfile
have at least the size of your RAM/swapfile
:uswsusp
in order to correctly use the swapfile:sudo systemctl edit systemd-hibernate.service
and fill it with the following content:/swapfile
:/etc/default/grub
and modify the following line:/etc/initramfs-tools/conf.d/resume
:Now you can hibernate with
sudo systemctl hibernate
.One can also create those scripts:
So you can sleep with
gotosleep
or hibernate withgotohibernation
.You must be able to execute
sudo s2both
,sudo s2ram
andsudo systemctl hibernate
without having to enter your password for the previous scripts to work.You could do that for example by creating a
powerdev
group, add your current user to it, and configure the following sudoers config (edit it withsudo visudo -f /etc/sudoers.d/powerdev
):Documentation used: