• Pop!_Planet is still very much under development. Data for the wiki is being sourced from the Arch Linux and Ubuntu wikis, along with a bunch of completely unique content specific to Pop!_OS, and sourcing, converting and updating that content takes time; please be patient. If you can't find what you're looking for here, check the Arch Linux and Ubuntu wikis.
  • Welcome!

    I'll get straight to the point.

    When I started Pop!_Planet, I launched it because I saw a need for a centralized community for Pop!_OS. To be frank, I never expected the level of popularity it has achieved. Over the last year, we have gone from under 50 users, to almost 400 users. That's awesome! However... it also comes with a downside. We are rapidly running out of disk space on our server, and the bandwidth costs go up every month.

    Pop!_Planet is not affiliated with System76 in any way, and is funded completely out of pocket. From day one, I said that I'd never use on-site ads (I hate them as much as you do), so the only monetization we get is through donations. Right now, the donations we receive don't even cover our overhead.

    I know that most users will ignore this message, and that's ok. However, if even a few of our users are willing and able to donate a few dollars to help offset our expenses, it would be greatly appreciated.

    Support Pop!_Planet

    Thank you for your time,

    Dan Griffiths
    Pop!_Planet Founder

Question Guide Guide to hibernate? (Answer is a guide)

wrhgw

Member
Oct 24, 2019
21
1
9
30
Hi, I did get hibernate and resume to work with grub on a Legacy install but I don know how to do it exactly with systemd and kernelstub. I followed some guides on reddit but I never managed to get resume from hibernation to work.

Is there an official guide? Why is this not an option in the installation or settings?
Thanks!
 

bwat47

Member
Feb 27, 2019
6
2
9
31
I've got it working on mine with an EFI installation

You can add the resume parameter with kernelstub like so:

sudo kernelstub -a "resume=UUID=25fe928e-8214-4177-9d79-5fad2edefc11"

Where the UUID= part is the UUID of your Swap partition

Also edit /etc/initramfs-tools/conf.d/resume to add the same line

and update the initramfs: sudo update-initramfs -u

NOTE: I have an un-encrypted installation, and I also disabled the encrypted swap partition (for some reason pop defaults to encrypted swap even if you install without full disk encryption). I'm not sure how to get it to work with encrypted swap.
 
With some help from the above comment by @bwat47 I was able to get this working on my Darter Pro with full disk encryption.

I believe a very similar process would have worked using the swap partition, by I opted for a swap file on my root partition instead (since I have plenty of free space and I could make it as big as I wanted).

I more or less followed the Arch Wiki instructions here, i.e.:
Code:
fallocate -l [N]G /swapfile           # [N] = swapfile size in GB
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
Then added /swapfile none swap defaults 0 0 to my /etc/fstab and followed the instructions here (i.e. ran filefrag -v /swapfile) to get the disk offset for the swapfile.

After that I had the kernel options I needed:
Code:
resume=/dev/mapper/data-root resume_offset=[offset]
Which I added to the GRUB_CMDLINE_LINUX_DEFAULT line of my /etc/default/grub, then ran grub-mkconfig -o /boot/grub/grub.cfg. I expected this to work but when it didn't I went searching more and found this thread and learned about kernelstub. Given that the rest of the steps duplicate this information it's possible this step isn't necessary, but I haven't tested that.

So after toying around with kernelstub and figuring out how to modify the kernel boot options line to have the options I wanted, something like:
Code:
kernelstub -a "resume=.... resume_offset=..."
I then created /etc/initramfs-tools/conf.d/resume and added the same resume/resume_offset line there and ran sudo update-initramfs -u.

After rebooting and testing hibernate using sudo systemctl hibernate, it worked. My computer shut off and when I started it back up and entered by encryption password and it resumed from the swap file. I also updated /etc/systemd/logind.conf to set HandleLidSwitch to hibernate so my laptop automatically hibernates when I close my laptop.

I was very surprised I couldn't find any official System76 guides to get hibernation working but hopefully this will help someone else get things set up the way they want.
 

derpOmattic

Pop!_Muse
Trusted User
Founding Member
Nov 23, 2018
1,904
324
30
www.patreon.com
Install and configure grub:
I really don't want to rain on your attempt to share, it's appreciated, and is probably helpful for people who already have GRUB installed. System76 don't support GRUB. In fact, Pop!_OS has been intentionally designed to NOT use GRUB, and use systemd boot instead. Pop's devs have put a mountain of effort into escaping the bloated, insecure mess that is GRUB.

Once again, I hope this doesn't come off as being critical - it's not. My intention for this reply is not to be critical, or censor you. Like I said, it's probably helpful for people who already have a legacy installation. I want to make new users aware that, although GRUB is familiar to many people, Pop!_OS doesn't use it.

Linux is freedom to do what you like, I get it, but the shear amount of support requests System76 get for GRUB, software they don't support and left in the dust years ago, is staggering. If you have a machine capable of booting in UEFI mode, and you want to use Pop!_OS, please don't use GRUB. It's not designed for it.
 

amarkovits

New member
Aug 7, 2020
3
2
4
38
If you have a machine capable of booting in UEFI mode, and you want to use Pop!_OS, please don't use GRUB. It's not designed for it.
I really like Pop!_OS and plan to use it but unfortunattly there is little documentation regarding boot modifications. I ended up using GRUB because I wanted to have the option to easily dual boot to windows (managed it also with systemd-boot but it was much more complicated). Also for testing some mainline kernels I use ukuu and it works better with grub (for systemd-boot I have to take some extra steps). I think that some well written guides reparding boot options using systemd-boot (add more kernels, dual boot, hibernate support) would help a lot, especially users with less linux experience (like me).

Anyway, sorry for being off-topic. I really appreciate your replay and plan to switch back to systemd-boot (I like doing things the standard way, so if this is what Pop!_OS recommends than I prefer it)
 
  • Like
Reactions: Tiger862000

amarkovits

New member
Aug 7, 2020
3
2
4
38
Thanks, I got it working with systemd-boot. Just enabled systemd-boot, and added the resume option with kernelstub as described above. Thanks
 
  • Like
Reactions: Tiger862000

derpOmattic

Pop!_Muse
Trusted User
Founding Member
Nov 23, 2018
1,904
324
30
www.patreon.com
Thanks, I got it working with systemd-boot. Just enabled systemd-boot, and added the resume option with kernelstub as described above. Thanks
Nice!
For the record, I'm glad you posted a solution for our friends that have legacy installs on old hardware, or, who are dual booting with existing Windows legacy/ GRUB scenarios. System76 are trying damn hard to drag everyone into the present because most modern PCs only have UEFI. Legacy only machines are obsolete and slowly dying off.
 

Tiger862000

New member
Aug 30, 2020
6
1
4
30
I followed @thesquaregroot guide but hibernation doesn't work for me - after cryptsetup on resume from hibernation-test nothing happens, as if the process hangs. I have to manually switch off the PC to start freshly.
My setup is encrypted, I use UEFI and a swapfile.
sudo update-initramfs -u gives me:
update-initramfs: Generating /boot/initrd.img-5.4.0-7642-generic
cryptsetup: ERROR: Couldn't resolve device ed035e91-ff20-4c7a-b94b-4ec24d327a94
cryptsetup: WARNING: Resume target cryptswap uses a key file
kernelstub.Config : INFO Looking for configuration...
kernelstub : INFO System information:

OS:..................Pop!_OS 20.04
Root partition:....../dev/dm-1
Root FS UUID:........ed035e91-ff20-4c7a-b94b-4ec24d327a94
ESP Path:............/boot/efi
ESP Partition:......./dev/sda1
ESP Partition #:.....1
NVRAM entry #:.......-1
Boot Variable #:.....0000
Kernel Boot Options:.quiet loglevel=0 systemd.show_status=false splash resume=ed035e91-ff20-4c7a-b94b-4ec24d327a94 resume_offset=241664
Kernel Image Path:.../boot/vmlinuz-5.4.0-7642-generic
Initrd Image Path:.../boot/initrd.img-5.4.0-7642-generic
Force-overwrite:.....False

kernelstub.Installer : INFO Copying Kernel into ESP
kernelstub.Installer : INFO Copying initrd.img into ESP
kernelstub.Installer : INFO Setting up loader.conf configuration
kernelstub.Installer : INFO Making entry file for Pop!_OS
kernelstub.Installer : INFO Backing up old kernel
kernelstub.Installer : INFO Making entry file for Pop!_OS
There are errors and warnings, but don't know what these mean. Please help!
My fstab looks like this.
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
PARTUUID=6c0f170e-3a6d-473c-a500-8f008db30c82 /boot/efi vfat umask=0077 0 0
PARTUUID=e21e3bc5-789a-4a2d-ba27-7a4d80f2f0dd /recovery vfat umask=0077 0 0
/dev/mapper/cryptswap none swap defaults 0 0
/swapfile none swap defaults 0 0
UUID=ed035e91-ff20-4c7a-b94b-4ec24d327a94 / ext4 noatime,errors=remount-ro 0 0


Below are all the steps I took:

# hibernation UEFI Bios systemd-boot kernelstub swapfile

# Create swapfile
fallocate -l [N]G /swapfile # [N] = swapfile size in GB
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile

# Edit fstab
# Add
/swapfile none swap defaults 0 0


# Using a swap file requires also setting the resume=swap_device and additionally a resume_offset=swap_file_offset kernel parameters. See the kernel documentation.

# swap_device is the the volume where the swap file resides and it follows the same format as for the root parameter. The value of swap_file_offset can be obtained by running filefrag -v swap_file, the output is in a table format and the required value is located in the first row of the physical_offset column.

# The following command may be used to identify swap_device:
findmnt -no UUID -T /swapfile
# ==> ed035e91-ff20-4c7a-b94b-4ec24d327a94

The following command may be used to identify swap_file_offset:
filefrag -v /swapfile | awk '{ if($1=="0:"){print $4} }'
# ==> the physical value where the file starts = 241664

# kernel boot parameter:
kernelstub -a "resume=swap_device resume_offset=swap_file_offset"

> kernelstub -a "resume=ed035e91-ff20-4c7a-b94b-4ec24d327a94 resume_offset=241664"

# Add to /etc/initramfs-tools/conf.d/resume the same line kernel boot parameter
# Run
sudo update-initramfs -u

# Test hibernation
sudo systemctl hibernate
 
I updated my system to test and make sure things were working and I discovered an issue that was either caused by a recent update or was always present and I just never noticed.

It seems that after I reboot if I then trigger hibernate via sudo systemctl hibernate everything seems normal but after typing in my encryption password it seems to flash the typical "resuming" message but then stop and continues booting like normal. I found the following messages in dmesg:

[ 9.061092] PM: Image signature found, resuming
[ 9.061093] PM: resume from hibernation
[ 9.061243] Freezing user space processes ... (elapsed 0.001 seconds) done.
[ 9.062420] OOM killer disabled.
[ 9.062420] Freezing remaining freezable tasks ... (elapsed 0.001 seconds) done.
[ 9.063649] PM: Marking nosave pages: [mem 0x00000000-0x00000fff]
[ 9.063650] PM: Marking nosave pages: [mem 0x000a0000-0x000fffff]
[ 9.063651] PM: Marking nosave pages: [mem 0x981f8000-0x98246fff]
[ 9.063653] PM: Marking nosave pages: [mem 0x996ae000-0x997f1fff]
[ 9.063656] PM: Marking nosave pages: [mem 0x997fd000-0x997fdfff]
[ 9.063656] PM: Marking nosave pages: [mem 0x99b50000-0xffffffff]
[ 9.064319] PM: Basic memory bitmaps created
[ 9.114627] PM: Using 3 thread(s) for decompression
[ 9.114628] PM: Loading and decompressing image data (1045133 pages)...
[ 9.114637] Hibernate inconsistent memory map detected!
[ 9.114638] PM: Image mismatch: architecture specific data
[ 9.114639] PM: Read 4180532 kbytes in 0.01 seconds (418053.20 MB/s)
[ 9.115132] PM: Error -1 resuming
[ 9.115134] PM: Failed to load hibernation image, recovering.
[ 9.115412] PM: Basic memory bitmaps freed
[ 9.115412] OOM killer enabled.
[ 9.115413] Restarting tasks ... done.
[ 9.115505] PM: resume from hibernation failed (-1)
Interestingly, after I log in that time I am able to hibernate successfully from that point on... until the next reboot. I don't have time at the moment to try to track down what's happening but I would first suggest just trying another time in case you're running into the same issue (and also checking dmesg for similar messages).

Beyond that the main other thing that seems different is that I used resume=/dev/mapper/data-root instead of the UUID, so that might be worth a shot just in case. Alternatively, you might want to make sure you add UUID= before the UUID. So in your case resume=UUID=ed035e91-ff20-4c7a-b94b-4ec24d327a94 resume_offset=241664.

If things still aren't working share the output of:

Code:
dmesg | grep "PM: "
For reference, here's the output I saw from my boot, failed hibernation (start at 9 seconds), then successful hibernation (starting at 227 seconds):

[ 0.051034] PM: Registered nosave memory: [mem 0x00000000-0x00000fff]
[ 0.051035] PM: Registered nosave memory: [mem 0x000a0000-0x000fffff]
[ 0.051036] PM: Registered nosave memory: [mem 0x981f8000-0x98246fff]
[ 0.051037] PM: Registered nosave memory: [mem 0x996ae000-0x997f1fff]
[ 0.051038] PM: Registered nosave memory: [mem 0x997fd000-0x997fdfff]
[ 0.051039] PM: Registered nosave memory: [mem 0x99b50000-0x9f7fffff]
[ 0.051039] PM: Registered nosave memory: [mem 0x9f800000-0xdfffffff]
[ 0.051039] PM: Registered nosave memory: [mem 0xe0000000-0xefffffff]
[ 0.051040] PM: Registered nosave memory: [mem 0xf0000000-0xfbffffff]
[ 0.051040] PM: Registered nosave memory: [mem 0xfc000000-0xfc000fff]
[ 0.051041] PM: Registered nosave memory: [mem 0xfc001000-0xfdffffff]
[ 0.051041] PM: Registered nosave memory: [mem 0xfe000000-0xfe00ffff]
[ 0.051041] PM: Registered nosave memory: [mem 0xfe010000-0xfed0ffff]
[ 0.051042] PM: Registered nosave memory: [mem 0xfed10000-0xfed17fff]
[ 0.051042] PM: Registered nosave memory: [mem 0xfed18000-0xfed3ffff]
[ 0.051042] PM: Registered nosave memory: [mem 0xfed40000-0xfed44fff]
[ 0.051043] PM: Registered nosave memory: [mem 0xfed45000-0xfed7ffff]
[ 0.051043] PM: Registered nosave memory: [mem 0xfed80000-0xfed83fff]
[ 0.051043] PM: Registered nosave memory: [mem 0xfed84000-0xfed8ffff]
[ 0.051044] PM: Registered nosave memory: [mem 0xfed90000-0xfed91fff]
[ 0.051044] PM: Registered nosave memory: [mem 0xfed92000-0xfed9ffff]
[ 0.051044] PM: Registered nosave memory: [mem 0xfeda0000-0xfeda1fff]
[ 0.051045] PM: Registered nosave memory: [mem 0xfeda2000-0xffffffff]
[ 0.145668] PM: RTC time: 21:49:23, date: 2020-08-31
[ 1.192489] PM: Magic number: 0:360:855
[ 9.061092] PM: Image signature found, resuming
[ 9.061093] PM: resume from hibernation
[ 9.063649] PM: Marking nosave pages: [mem 0x00000000-0x00000fff]
[ 9.063650] PM: Marking nosave pages: [mem 0x000a0000-0x000fffff]
[ 9.063651] PM: Marking nosave pages: [mem 0x981f8000-0x98246fff]
[ 9.063653] PM: Marking nosave pages: [mem 0x996ae000-0x997f1fff]
[ 9.063656] PM: Marking nosave pages: [mem 0x997fd000-0x997fdfff]
[ 9.063656] PM: Marking nosave pages: [mem 0x99b50000-0xffffffff]
[ 9.064319] PM: Basic memory bitmaps created
[ 9.114627] PM: Using 3 thread(s) for decompression
[ 9.114628] PM: Loading and decompressing image data (1045133 pages)...
[ 9.114638] PM: Image mismatch: architecture specific data
[ 9.114639] PM: Read 4180532 kbytes in 0.01 seconds (418053.20 MB/s)
[ 9.115132] PM: Error -1 resuming
[ 9.115134] PM: Failed to load hibernation image, recovering.
[ 9.115412] PM: Basic memory bitmaps freed
[ 9.115505] PM: resume from hibernation failed (-1)
[ 227.030594] PM: hibernation entry
[ 227.039207] PM: Marking nosave pages: [mem 0x00000000-0x00000fff]
[ 227.039207] PM: Marking nosave pages: [mem 0x000a0000-0x000fffff]
[ 227.039210] PM: Marking nosave pages: [mem 0x981f8000-0x98246fff]
[ 227.039212] PM: Marking nosave pages: [mem 0x996ae000-0x997f1fff]
[ 227.039218] PM: Marking nosave pages: [mem 0x997fd000-0x997fdfff]
[ 227.039219] PM: Marking nosave pages: [mem 0x99b50000-0xffffffff]
[ 227.040414] PM: Basic memory bitmaps created
[ 227.040424] PM: Preallocating image memory... done (allocated 1428075 pages)
[ 227.627173] PM: Allocated 5712300 kbytes in 0.58 seconds (9848.79 MB/s)
[ 228.018093] PM: Saving platform NVS memory
[ 228.044956] PM: Creating hibernation image:
[ 228.336296] PM: Need to copy 1419091 pages
[ 228.336298] PM: Normal pages needed: 1419091 + 1024, available pages: 2742493
[ 228.469731] PM: free pages cleared after restore
[ 228.469754] PM: Restoring platform NVS memory
[ 230.574250] PM: Basic memory bitmaps freed
[ 231.154040] PM: hibernation exit
 
@Tiger862000

Looking more closely at your output from update-initramfs, I think one of the things I mentioned above (using /dev/mapper/data-root or inserting UUID= in your resume parameter) will work at least get you closer. The following line seems to especially suggest that it doesn't understand what you have right now:

cryptsetup: ERROR: Couldn't resolve device ed035e91-ff20-4c7a-b94b-4ec24d327a94
Here are the first few lines of my output (the rest are effectively the same as yours):

update-initramfs: Generating /boot/initrd.img-5.4.0-7642-generic
kernelstub.Config : INFO Looking for configuration...
kernelstub : INFO System information:

OS:..................Pop!_OS 20.04
So probably no need to waste time testing things until you've got that cleared up.
 

Tiger862000

New member
Aug 30, 2020
6
1
4
30
It works now PARTICALLY - means ONLY when I hit sudo systemctl hibernate
otherwhise when I close my lid, the system only goes to sleep.

Anyways @thesquaregroot big big thanks for your help my friend. You pointed me into the right direction, to at least get one step closer.

Problem was indeed the ERROR and the WARNING after firing sudo update-initramfs -u

update-initramfs: Generating /boot/initrd.img-5.4.0-7642-generic
cryptsetup: ERROR: Couldn't resolve device ed035e91-ff20-4c7a-b94b-4ec24d327a94
cryptsetup: WARNING: Resume target cryptswap uses a key file
So I fixed the WARNING with the swap file first >> See my guide below

After that still had the ERROR "Couldn't resolve device" open.
First tried changing to "resume=UUID=XXX", that didn't help either. So I changed to "resume=/dev/mapper/data-root" as @thesquaregroot suggested, yet the ERROR stayed persistently.

One beer later I was already kind of desperate and thought about the number one suggestion from our IT department.
So, a reboot later and update-initramfs -c -k all hybernation does now work for me.

As mentioned above it's not perfect now, as I still get some error messages during boot up and cannot hibernate once the I close the lid.

Attached the guide I wrote for myself. Stay tuned for further updates here.

# hibernation UEFI Bios systemd-boot kernelstub swapfile


# Create swapfile
fallocate -l [N]G /swapfile # [N] = swapfile size in GB
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile

# Edit fstab
# Add
/swapfile none swap defaults 0 0
# Then follow steps
1) sudo swapoff -a
2) sudo cryptsetup remove cryptswap1
3) edit `/etc/fstab`, comment the line mentioning cryptswap
4) edit `/etc/crypttab `, comment the line mentioning cryptswap

# checking the status of the swap
> sudo cryptsetup status /dev/mapper/cryptswap
/dev/mapper/cryptswap1 is active and is in use.

# To check swap status, use:
> swapon --show

# Using a swap file requires also setting the resume=swap_device and additionally a resume_offset=swap_file_offset kernel parameters. See the kernel documentation.

# swap_device is the the volume where the swap file resides and it follows the same format as for the root parameter. The value of swap_file_offset can be obtained by running filefrag -v swap_file, the output is in a table format and the required value is located in the first row of the physical_offset column.

# The following command may be used to identify swap_device:
findmnt -no UUID -T /swapfile
# ==> ed035e91-ff20-4c7a-b94b-4ec24d327a94

The following command may be used to identify swap_file_offset:
filefrag -v /swapfile | awk '{ if($1=="0:"){print $4} }'
# ==> the physical value where the file starts = 241664

# kernel boot parameter:
kernelstub -a "resume=swap_device resume_offset=swap_file_offset"

#XXX > kernelstub -a "resume=ed035e91-ff20-4c7a-b94b-4ec24d327a94 resume_offset=241664"
> kernelstub -a "resume=/dev/mapper/data-root resume_offset=241664"



# Add to /etc/initramfs-tools/conf.d/resume the same line kernel boot parameter
# Run
sudo update-initramfs -u

# In case of problems
# update-initramfs cryptsetup: ERROR: Couldn't resolve device XXX
> update-initramfs -c -k all
> reboot

# Test hibernate
sudo systemctl hibernate
EDIT Mon, Sept. 14th 2020: Changed my message - "I did not succeed entirely" - for others not to have false impressions.
 
Last edited:

Tiger862000

New member
Aug 30, 2020
6
1
4
30
@thesquaregroot here is my dmesg | grep "PM: " output
[ 0.060172] PM: Registered nosave memory: [mem 0x00000000-0x00000fff]
[ 0.060173] PM: Registered nosave memory: [mem 0x00058000-0x00058fff]
[ 0.060174] PM: Registered nosave memory: [mem 0x0008c000-0x0009ffff]
[ 0.060175] PM: Registered nosave memory: [mem 0x000a0000-0x000dffff]
[ 0.060176] PM: Registered nosave memory: [mem 0x000e0000-0x000fffff]
[ 0.060177] PM: Registered nosave memory: [mem 0x92093000-0x92093fff]
[ 0.060179] PM: Registered nosave memory: [mem 0x920a3000-0x920a3fff]
[ 0.060180] PM: Registered nosave memory: [mem 0x9a2aa000-0x9cbfefff]
[ 0.060181] PM: Registered nosave memory: [mem 0x9cbff000-0x9cd7efff]
[ 0.060181] PM: Registered nosave memory: [mem 0x9cd7f000-0x9cdfefff]
[ 0.060183] PM: Registered nosave memory: [mem 0x9ce00000-0x9dffffff]
[ 0.060184] PM: Registered nosave memory: [mem 0x9e000000-0x9fffffff]
[ 0.060184] PM: Registered nosave memory: [mem 0xa0000000-0xf80f7fff]
[ 0.060185] PM: Registered nosave memory: [mem 0xf80f8000-0xf80f8fff]
[ 0.060185] PM: Registered nosave memory: [mem 0xf80f9000-0xfed1bfff]
[ 0.060186] PM: Registered nosave memory: [mem 0xfed1c000-0xfed1ffff]
[ 0.060186] PM: Registered nosave memory: [mem 0xfed20000-0xffffffff]
[ 0.167643] PM: Registering ACPI NVS region [mem 0x9cbff000-0x9cd7efff] (1572864 bytes)
[ 0.167643] PM: RTC time: 21:05:10, date: 2020-09-07
[ 0.827016] PM: Magic number: 4:286:95
[ 1000.791814] PM: Image not found (code -22)
[ 1000.797363] PM: hibernation entry
[ 1000.954201] PM: Marking nosave pages: [mem 0x00000000-0x00000fff]
[ 1000.954204] PM: Marking nosave pages: [mem 0x00058000-0x00058fff]
[ 1000.954206] PM: Marking nosave pages: [mem 0x0008c000-0x000fffff]
[ 1000.954213] PM: Marking nosave pages: [mem 0x92093000-0x92093fff]
[ 1000.954215] PM: Marking nosave pages: [mem 0x920a3000-0x920a3fff]
[ 1000.954217] PM: Marking nosave pages: [mem 0x9a2aa000-0x9cdfefff]
[ 1000.954692] PM: Marking nosave pages: [mem 0x9ce00000-0xffffffff]
[ 1000.957507] PM: Basic memory bitmaps created
[ 1000.958013] PM: Preallocating image memory... done (allocated 1086926 pages)
[ 1001.782809] PM: Allocated 4347704 kbytes in 0.82 seconds (5302.07 MB/s)
[ 1002.040828] PM: Saving platform NVS memory
[ 1002.051708] PM: Creating hibernation image:
[ 1002.218713] PM: Need to copy 1082605 pages
[ 1002.218716] PM: Normal pages needed: 1082605 + 1024, available pages: 2030688
[ 1002.797868] PM: free pages cleared after restore
[ 1002.797910] PM: Restoring platform NVS memory
[ 1004.317099] PM: Basic memory bitmaps freed
[ 1004.381553] PM: hibernation exit
 

Tiger862000

New member
Aug 30, 2020
6
1
4
30
It works now. See my full guide below!

System: Lenovo ThinkPad T450s with Intel integraded graphics. With dedicated graphics further tweaking might be needed.

# Enable hibernation mode for Pop!OS - A step by step guide, for hibernation on UEFI Bios, using systemd-boot, kernelstub and a swapfile in an encrypted root partition

## Prerequisites — does your kernel support suspend-to-disk?
Kernel supports whatever is listed in /sys/power/state, so:
> cat /sys/power/state

Allowed (to my knowledge) entries there include: mem, standby, freeze, disk. Explanation:
mem — has several meanings, which one exactly on your system you’ll find out via cat /sys/power/mem_sleep. I have: s2idle [deep]
standby — Power-On Suspend (if supported)
freeze — Suspend To Idle (STI)
disk — Suspend To Disk (STD), hibernation. This what you want!

## Setup Swapfile

### Create swapfile
> fallocate -l [N]G /swapfile # [N] = swapfile size in GB
> chmod 600 /swapfile
> mkswap /swapfile
> swapon /swapfile

### Edit fstab
> sudo gedit /etc/fstab
Add "/swapfile none swap defaults 0 0"
# Then follow steps
> sudo swapoff -a
> sudo cryptsetup remove cryptswap1
edit `/etc/fstab`, comment the line mentioning cryptswap
edit `/etc/crypttab `, comment the line mentioning cryptswap

### Checking the status of the swap
> sudo cryptsetup status /dev/mapper/cryptswap
You should see following message: "/dev/mapper/cryptswap1 is active and is in use."

### To check swap status, use:
> swapon --show

## Setup Hibernation with swapfile

### Help: "https://wiki.archlinux.org/index.php/Power_management/Suspend_and_hibernate#Hibernation_into_swap_file"
Using a swap file requires also setting the resume=swap_device and additionally a resume_offset=swap_file_offset kernel parameters. See the kernel documentation.

swap_device is the the volume where the swap file resides and it follows the same format as for the root parameter. The value of swap_file_offset can be obtained by running filefrag -v swap_file, the output is in a table format and the required value is located in the first row of the physical_offset column.

### Identify swapfile
The following command may be used to identify swap_device:
> findmnt -no UUID -T /swapfile
Should give you an output like this "ed035e91-ff20-4c7a-b94b-4ec24d327a94"

The following command may be used to identify swap_file_offset:
> filefrag -v /swapfile | awk '{ if($1=="0:"){print $4} }'
Should give you an output like this "the physical value where the file starts = 241664"

## Write resume parameter
POP OS! Does not use Grub2 in POP OS! 20.04
POP OS! uses system-boot and kernelstab to manage kernel boot option.
To add the resume parameter in kernelstab

### kernel boot parameter:
> kernelstub -a "resume=swap_device resume_offset=swap_file_offset"

e.g.:
> kernelstub -a "resume=ed035e91-ff20-4c7a-b94b-4ec24d327a94 resume_offset=241664"
OR
> kernelstub -a "resume=/dev/mapper/data-root resume_offset=241664"
...choose whichever variant works for you.

Make it permanent and add to "/etc/initramfs-tools/conf.d/resume" the same line kernel boot parameter
Then run in the terminal:
> sudo update-initramfs -u

## In case of problems
### Error: "update-initramfs cryptsetup: ERROR: Couldn't resolve device XXX"
Then run in terminal
> update-initramfs -c -k all

### if you get multiple Kernel Boot Option:
e.g. "resume=UUID=25fe928e-8214–4177–9d79–5fad2edefc11 resume=UUID=434dsfsf-2233–4177–9d79–5fad2edddfe1"
then you have to delete the non working entries. The Following command let's you pass The total boot options to the kernel.
> sudo kernelstab -o “resume=UUID=434dsfsf-2233–4177–9d79–5fad2edddfe1”
then run
> sudo update-initramfs -u
Now you can see only one entry in Kernel boot option.
> reboot

## Test hibernation
sudo systemctl hibernate

## To see the log output
dmesg | grep "PM: "

## Lid close events
### Setup the events
Edit logind.conf to enable suspend-then-hibernate on lid closed and uncomment the following lines.
Run first:
> sudo gedit /etc/systemd/logind.conf
Edit and uncomment these Lines:
"HandleLidSwitch=suspend-then-hibernate"
"HandleLidSwitchExternalPower=suspend-then-hibernate"

### Setup delay
To add the delay after how many sec/min the hibernation should happen after suspend was entered.
> sudo gedit /etc/systemd/sleep.conf
Uncomment and edit following line:
"HibernateDelaySec=30min"
Note: for min add the value "min" e.g. 30min, for seconds add the value 30. help: https://www.freedesktop.org/software/systemd/man/systemd-sleep.conf.html

++++Congrats hibernation should be up and working like a charm now.++++
Kudos to Mr. Satyendra on medium for pointing me into the right direction: https://medium.com/@csatyendra02/pop-os-hibernate-enable-step-by-step-complete-tutorial-and-references-601e0ca4c96e
Note: My guide works with a swapfile in the encrypted root partition. Mr. Satyendra's uses an unencrypted swap-partition to store the hibertation image.
 
Last edited:
  • Winner
Reactions: derpOmattic

ozspeed

New member
Nov 1, 2020
9
0
4
51
When you hibernate does it actually restore the session as it was or does it drop you into a fresh gnome shell?

This is what is happening to me, the process works hibernate looks like it flushes state to disk, switches off, restarts and says restoring from the resume target and then opens a fresh gnome shell with nothing in it.
 

ozspeed

New member
Nov 1, 2020
9
0
4
51
I mean when I restart after hibernate etc.

UPDATE: It works flawlessly when using intel integrated graphics but resumes with a fresh gnome session when the nvidia drivers are loaded on system76 oryx pro (using the gpu only or hybrid graphics modes).

So let me ask my question above in another way: has anyone got hibernate to work with the nvidia driver loaded?
 
Last edited:

Tiger862000

New member
Aug 30, 2020
6
1
4
30
UPDATE: It works flawlessly when using intel integrated graphics but resumes with a fresh gnome session when the nvidia drivers are loaded on system76 oryx pro (using the gpu only or hybrid graphics modes).

So let me ask my question above in another way: has anyone got hibernate to work with the nvidia driver loaded?
@ozspeed sorry cannot really help you there as I use a system with only Intel integrated GPU.

I could have a look at your system log. Please post the output of dmesg | grep "PM: " after you put your system to hybernate using nvidia graphics driver and booted up from that hibernation again.
 

Members online

No members online now.

Latest projects

Forum statistics

Threads
1,486
Messages
6,712
Members
1,433
Latest member
ducky