I made a mistake and installed Ubuntu 20.04 LTS with an encrypted ZFS / OpenZFS root partition on my productive working desktop in a dual boot configuration (see partition table below). But I didn't pay proper attention on the tutorial I was following and now it seems that I have a Swap partition of 4G although I have 32G of RAM (EDIT: I found out how I'm able to increase the Swap but I still can't go into hibernation — see below). Therefore I cannot put this machine on hibernation.

What's the best way to solve this issue, so that I can put this machine into hibernation?

Current state

$ sudo fdisk -l /dev/nvme0n1
Disk /dev/nvme0n1: 1.88 TiB, 2048408248320 bytes, 4000797360 sectors
Disk model: KXG60PNV2T04 NVMe KIOXIA 2048GB         
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 1FCA11ED-9263-4C06-A8DF-594C0DE84AFA

Device             Start        End    Sectors   Size Type
/dev/nvme0n1p1      2048    1085439    1083392   529M Windows recovery environment
/dev/nvme0n1p2   1085440    1290239     204800   100M EFI System
/dev/nvme0n1p3   1290240    1323007      32768    16M Microsoft reserved
/dev/nvme0n1p4   1323008  409420488  408097481 194.6G Microsoft basic data
/dev/nvme0n1p5 409421824  410920959    1499136   732M Windows recovery environment
/dev/nvme0n1p6 410923008  415117311    4194304     2G Linux filesystem
/dev/nvme0n1p7 415117312 4000797326 3585680015   1.7T Linux filesystem

$ sudo swapon --show --output all
NAME     TYPE      SIZE USED PRIO UUID                                 LABEL
/dev/zd0 partition   4G   0B   -2 1e1fb013-69d9-4878-b358-6b8ee53d5b09

$ sudo zpool list -v
Root         1.66T   535G  1.13T        -         -     2%    31%  1.00x    ONLINE  -
  nvme0n1p7  1.66T   535G  1.13T        -         -     2%  31.5%      -  ONLINE

$ sudo zpool status -v
  pool: Root
 state: ONLINE
  scan: none requested

    Root         ONLINE       0     0     0
      nvme0n1p7  ONLINE       0     0     0

errors: No known data errors

$ sudo zfs list
NAME                                                                              USED  AVAIL     REFER  MOUNTPOINT
Root                                                                              539G  1.08T      192K  none
Root/root                                                                         534G  1.08T      530G  /
Root/root/00a891589b00cebc55cb6767e266ca38ac201daf3a6048c1f33d7d55c0710533        544K  1.08T      143M  legacy
[…] # many other legacy mount points
Root/root/ffe52d35c873e6a417ee12c7025d848dac1f269b8078266f00a8d8088fd34384        396K  1.08T      607M  legacy
Root/swap                                                                        4.25G  1.08T      172M  -

$ sudo zfs get all Root/swap
NAME       PROPERTY              VALUE                 SOURCE
Root/swap  type                  volume                -
Root/swap  creation              So Aug  2 15:36 2020  -
Root/swap  used                  4.25G                 -
Root/swap  available             1.08T                 -
Root/swap  referenced            172M                  -
Root/swap  compressratio         1.00x                 -
Root/swap  reservation           none                  default
Root/swap  volsize               4G                    local
Root/swap  volblocksize          4K                    -
Root/swap  checksum              on                    default
Root/swap  compression           off                   local
Root/swap  readonly              off                   default
Root/swap  createtxg             3746                  -
Root/swap  copies                1                     default
Root/swap  refreservation        4.25G                 local
Root/swap  guid                  12379969387189982956  -
Root/swap  primarycache          metadata              local
Root/swap  secondarycache        none                  local
Root/swap  usedbysnapshots       0B                    -
Root/swap  usedbydataset         172M                  -
Root/swap  usedbychildren        0B                    -
Root/swap  usedbyrefreservation  4.08G                 -
Root/swap  logbias               throughput            local
Root/swap  objsetid              278                   -
Root/swap  dedup                 off                   default
Root/swap  mlslabel              none                  default
Root/swap  sync                  always                local
Root/swap  refcompressratio      1.00x                 -
Root/swap  written               172M                  -
Root/swap  logicalused           169M                  -
Root/swap  logicalreferenced     169M                  -
Root/swap  volmode               default               default
Root/swap  snapshot_limit        none                  default
Root/swap  snapshot_count        none                  default
Root/swap  snapdev               hidden                default
Root/swap  context               none                  default
Root/swap  fscontext             none                  default
Root/swap  defcontext            none                  default
Root/swap  rootcontext           none                  default
Root/swap  redundant_metadata    all                   default
Root/swap  encryption            aes-256-gcm           -
Root/swap  keylocation           none                  default
Root/swap  keyformat             passphrase            -
Root/swap  pbkdf2iters           342K                  -
Root/swap  encryptionroot        Root                  -
Root/swap  keystatus             available             -

What I tried

Creating a Swapfile

I thought a swapfile might be an easy fix but I was obviously wrong:

$ sudo dd if=/dev/zero of=/swapfile bs=1MiB count=$((32*1024))
32768+0 records in
32768+0 records out
34359738368 bytes (34 GB, 32 GiB) copied, 14.5783 s, 2.4 GB/s

$ sudo chmod 600 /swapfile

$ sudo swapon /swapfile
swapon: /swapfile: skipping - it appears to have holes.

So I guess I should rather increase the swap partition. It's also not clear to me why swapon claims that the swap partition has 4G although zfs get all Root/swap says that 1.08T are available.

Anything with GParted

GParted won't recognize much. This could be related to the bug in os-prober (GParted issue 14, Debian bug 888114, os-prober issue 1848496, openzfs issues 9801 and 9069)

enter image description here

Replacing the small Swap partition (=increasing the Swap partition on ZFS)

The creation command was inspired by a comment on GitHub but you should keep in mind not to use -o sync=always.

$ sudo zfs create -V 32G -b $(getconf PAGESIZE) -o logbias=throughput -o primarycache=metadata -o secondarycache=none -o com.sun:auto-snapshot=false -o compression=zle Root/swap_two
$ sudo zfs rename Root/swap Root/swap_bak
$ sudo zfs rename Root/swap_two Root/swap
$ sudo mkswap -f /dev/zvol/Root/swap
$ sudo swapon /dev/zvol/Root/swap

ensuring that this entry is in /etc/fstab:

/dev/zvol/Root/swap none swap discard 0 0

then reboot and remove the tiny legacy swap:

$ sudo zfs destroy Root/swap_bak

While this seem to have worked, I still cannot hibernate:

$ sudo systemctl hibernate
Failed to hibernate system via logind: Sleep verb "hibernate" not supported

Therefore I'm still open for any advice. Maybe it needs a dedicated resume parameter in GRUB_CMDLINE_LINUX_DEFAULT?

  • 1
    I want to use zfs with encryption, too. Did you solve this problem?
    – ikreb
    Jan 30, 2021 at 8:59
  • Unfortunately not. I'm very sorry. Jan 31, 2021 at 15:32
  • @alexanderadam: But what was the reason: 1) you have further tried and tried and it is impossible to do? 2) you simply stopped trying (having no time etc)? 3) other reason? (of course I am also very interested in this function)
    – Tomeg
    May 24, 2021 at 7:56
  • The reason was something else. Hibernation is disabled on Ubuntu ( discourse.ubuntu.com/t/re-visiting-hibernate-on-ubuntu/15953 ) and has to be activated manually. May 24, 2021 at 12:23
  • I just posted the solution that I had to apply here and hope that it'll help you as well. May 24, 2021 at 12:35

3 Answers 3


In the end the reason wasn't related to ZFS. Even after resizing the swap it didn't work because it is simply disabled on newer Ubuntu versions (it will be reconsidered though).

To solve this, you have to activate hibernation.

  1. Open com.ubuntu.desktop.pkla in an editor:
$ sudo vim /var/lib/polkit-1/localauthority/10-vendor.d/com.ubuntu.desktop.pkla
# or on some machines
$ sudo vim /etc/polkit-1/localauthority/10-vendor.d/com.ubuntu.desktop.pkla

Search for the entries Disable hibernate by default in upower and Disable hibernate by default in logind and change each ResultActive value to yes.

Reboot and test the result with

$ sudo systemctl hibernate
# or
$ sudo pm-hibernate

If it still doesn't work, you might have to deactivate things like Fast boot and Secure boot in your BIOS (ATTENTION: it is very likely that you have to do that on newer machines).

If the test doesn't result in an error anymore, you should also be able to assign Hibernations to certain actions in Ubuntu settings. For instance on pressing the power button.

Power — Suspend & Power — Button Power Button Behaviour — Hibernate


Using ZFS for swap (either a file on a filesystem or an entire zvol) is already a bad idea, let alone hibernating with it. My only advice would be give it up completely, ZFS isn't built for this purpose.

ZFS is a log-structured filesystem, where blocks (extents) of a file isn't fixed at any time, but rather changes for every write (the no-overwrite rule). The swap subsystem, however, expects simple, intelligible mappings between the swapfile and blocks, and direct access to the underlying disk sectors, neither of which is a trait of log-structured filesystems. Btrfs, being another LFS, supports swapfiles with numerous restrictions, only to make it usable, while ZFS does not even support O_DIRECT. There's a reason that swap partitions perform better and are more reliable than swap files.

ZFS does a lot of internal bookkeeping to guarantee transactional safety, and relies heavily on abundant memory. If you use ZFS for swap, whose primary purpose is to serve as a disk-backed extension for memory, it causes a positive feedback loop between ZFS and the memory management subsystem under high load or high swap pressure. This can lead to, for example, soft locking the whole system.

If you go further and hibernate with swap-on-ZFS, the internal data structures of ZFS will sooner or later go nuts, as resuming from hibernation relies on correct and consistent memory loaded from disk, while ZFS also depends on well-formed in-memory data structures to provide integral disk data.


process to Increase Size of Swap Partition and use it for Hibernation

  1. Creating the swap partition

    Activating the swap partition

    Making the new swap partition work for hibernate (optional)

    Creating the swap partition Boot to Ubuntu install CD and choose the option to run Ubuntu now Go to system -> GParted Partition Editor

Delete the swap partition and, if there is nothing else in it, the extended partition that holds it. (If by some miracle you're able to resize your swap partition from here, I imagine your life will be a lot easier than mine.) Decrease the size of your primary partition by the amount you want your new swap to be (I made mine 2x RAM + 500MB just to be safe). The easiest way to do this is to fill in the amount of space you want swap to be in the "free space following" field In the free space that has now been created, choose new, type linux-swap and you can name the partition "swap" if you like Hit the Apply button (should be a check mark) to write the changes to disk When done, reboot back into Ubuntu Activating the swap partition (If your swap is on your primary hard drive, you don't need to do anything here.) Now you need to find what partition your swap is on and what its UUID is. UUID?! you say? Well that's the Universally Unique IDentifier for the partition so you can reference it even if it's on a different mount point from boot-to-boot due to adding disks, etc.

Pull up a terminal and run gksu gparted & and enter your root password. The & lets this process run while still giving you access to the command line.

Right-click on your swap partition and choose Information. You should see the Path and UUID listed there. Keep this open for further reference. Run gksu gedit /etc/fstab & and look for the line that has swap in it. It should be the third column, separated by spaces or tabs. You can either use the path or the UUID to tell Linux where to find your swap partition. I recommend UUID because it'll stay constant even if you move the partition around or the disk somehow becomes sdb instead of sda or something like that. Make the appropriate edits and save the file. Your line should look something like this if you used UUID (with your UUID instead, of course):

UUID=41e86209-3802-424b-9a9d-d7683142dab7 none swap sw 0 0

or this if you used path: /dev/sda2 none swap sw 0 0

Save the file. Enable the new swap partition with this command.

sudo swapon --all


$ sudo swapon --all --verbose

swapon on /dev/sda2
swapon: /dev/sda2: found swap signature: version 1, page-size 4, same byte order
swapon: /dev/sda2: pagesize=4096, swapsize=2147483648, devsize=2147483648
Confirm that the swap partition exists.

$ cat /proc/swaps
Filename                                Type            Size    Used    Priority
/dev/sda2                               partition       2097148 0       -1

Reboot to make sure the new swap gets activated properly at startup Making the swap partition work for hibernate (optional) 'INFO: This will not work for 12.04, resume from hibernate work differently in 12.04.'

Pull up a Terminal again and run cat /proc/swaps and hopefully you see the path to your swap partition listed there. If not chances are something went wrong in the steps above. Here's my output:

Filename Type Size Used Priority /dev/sda2 partition 2676732 73380 -1 gksu gedit /etc/default/grub & to pull up the boot loader configuration

Look for the line GRUB_CMDLINE_LINUX="" and make sure it looks like this (using your UUID of course) GRUB_CMDLINE_LINUX="resume=UUID=41e86209-3802-424b-9a9d-d7683142dab7" and save the file

sudo update-grub and wait for it to finish

gksu gedit /etc/initramfs-tools/conf.d/resume & and make sure its contents are resume=UUID=41e86209-3802-424b-9a9d-d7683142dab7 (with your UUID of course in place of mine). Save the file!

sudo update-initramfs -u

Reboot! Now you should be able to hibernate and resume!

  • 2
    This doesn't work with ZFS and Ubuntu 20.04. It shows only a single ZFS partition on /dev/nvme0n1. I also posted some issue links in case you're curious why this won't work. That's why I explicitly mentioned Ubuntu 20.04 and ZFS. Aug 13, 2020 at 12:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .