How to Enable Hibernate on Ubuntu 26.04 LTS
Enable Hibernate Function in Ubuntu 26.04, 24.04 or 22.04 LTS
u-admin@ubuntu-server:~$ cat /proc/swaps
Filename Type Size Used Priority
/swapfile file 524284 0 -1
u-admin@ubuntu-server:~$ sudo swapoff /swapfile
sudo rm -f /swapfile /swap.img
sudo fallocate -l 20G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
Setting up swapspace version 1, size = 20 GiB (21474832384 bytes)
no label, UUID=612c8171-f10a-4fe9-8ed7-d0d3a5f3d4d0
u-admin@ubuntu-server:~$ cat /proc/swaps
Filename Type Size Used Priority
/swapfile file 20971516 0 -1
u-admin@ubuntu-server:~$ cat /etc/fstab
# /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>
UUID=A259-7FE0 /boot/efi vfat defaults 0 2
UUID=af9fa36a-afed-4638-ab57-6f4c9788e08e / ext4 defaults 0 1
# UUID=424C5B5E4C5B4C33 /media/gamedisk ntfs uid=1000,gid=1000,rw,user,exec,umask=000 0 0
/swapfile swap swap defaults 0 0
tmpfs /tmp tmpfs defaults,noatime,mode=1777 0 0
u-admin@ubuntu-server:~$ findmnt -no UUID -T /swapfile
af9fa36a-afed-4638-ab57-6f4c9788e08e
u-admin@ubuntu-server:~$ sudo filefrag -v /swapfile | head -5
Filesystem type is: ef53
File size of /swapfile is 21474836480 (5242880 blocks of 4096 bytes)
ext: logical_offset: physical_offset: length: expected: flags:
0: 0.. 0: 98529265.. 98529265: 1:
1: 1.. 36863: 98529281.. 98566143: 36863: unwritten
u-admin@ubuntu-server:~$ sudo nano /etc/default/grub
GRUB_DEFAULT=0
GRUB_TIMEOUT_STYLE=hidden
GRUB_TIMEOUT=0
GRUB_DISTRIBUTOR='Kubuntu'
GRUB_CMDLINE_LINUX_DEFAULT='quiet splash resume=UUID=af9fa36a-afed-4638-ab57-6f4c9788e08e resume_offset=98529265'
GRUB_CMDLINE_LINUX=""
u-admin@ubuntu-server:~$ sudo update-grub
Sourcing file `/etc/default/grub'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-7.0.0-27-generic
Found initrd image: /boot/initrd.img-7.0.0-27-generic
Found linux image: /boot/vmlinuz-7.0.0-22-generic
Found initrd image: /boot/initrd.img-7.0.0-22-generic
Found linux image: /boot/vmlinuz-7.0.0-14-generic
Found initrd image: /boot/initrd.img-7.0.0-14-generic
Found memtest86+ 64bit EFI image: /boot/mt86+x64
Found memtest86+ 32bit EFI image: /boot/mt86+ia32
Found memtest86+ 64bit image: /boot/mt86+x64
Found memtest86+ 32bit image: /boot/mt86+ia32
Warning: os-prober will be executed to detect other bootable partitions.
Its output will be used to detect bootable binaries on them and create new boot entries.
Found Windows Boot Manager on /dev/nvme0n1p2@/EFI/Microsoft/Boot/bootmgfw.efi
Adding boot menu entry for UEFI Firmware Settings ...
done
u-admin@ubuntu-server:~$ sudo nano /etc/initramfs-tools/conf.d/resume
resume=UUID=af9fa36a-afed-4638-ab57-6f4c9788e08e resume_offset=98529265
u-admin@ubuntu-server:~$ sudo update-initramfs -u -k all
update-initramfs: Generating /boot/initrd.img-7.0.0-27-generic
cryptsetup: ERROR: Couldn't resolve device /swapfile
update-initramfs: Generating /boot/initrd.img-7.0.0-22-generic
cryptsetup: ERROR: Couldn't resolve device /swapfile
update-initramfs: Generating /boot/initrd.img-7.0.0-14-generic
cryptsetup: ERROR: Couldn't resolve device /swapfile
Filename Type Size Used Priority
/swapfile file 524284 0 -1
u-admin@ubuntu-server:~$ sudo swapoff /swapfile
sudo rm -f /swapfile /swap.img
sudo fallocate -l 20G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
Setting up swapspace version 1, size = 20 GiB (21474832384 bytes)
no label, UUID=612c8171-f10a-4fe9-8ed7-d0d3a5f3d4d0
u-admin@ubuntu-server:~$ cat /proc/swaps
Filename Type Size Used Priority
/swapfile file 20971516 0 -1
u-admin@ubuntu-server:~$ cat /etc/fstab
# /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>
UUID=A259-7FE0 /boot/efi vfat defaults 0 2
UUID=af9fa36a-afed-4638-ab57-6f4c9788e08e / ext4 defaults 0 1
# UUID=424C5B5E4C5B4C33 /media/gamedisk ntfs uid=1000,gid=1000,rw,user,exec,umask=000 0 0
/swapfile swap swap defaults 0 0
tmpfs /tmp tmpfs defaults,noatime,mode=1777 0 0
u-admin@ubuntu-server:~$ findmnt -no UUID -T /swapfile
af9fa36a-afed-4638-ab57-6f4c9788e08e
u-admin@ubuntu-server:~$ sudo filefrag -v /swapfile | head -5
Filesystem type is: ef53
File size of /swapfile is 21474836480 (5242880 blocks of 4096 bytes)
ext: logical_offset: physical_offset: length: expected: flags:
0: 0.. 0: 98529265.. 98529265: 1:
1: 1.. 36863: 98529281.. 98566143: 36863: unwritten
u-admin@ubuntu-server:~$ sudo nano /etc/default/grub
GRUB_DEFAULT=0
GRUB_TIMEOUT_STYLE=hidden
GRUB_TIMEOUT=0
GRUB_DISTRIBUTOR='Kubuntu'
GRUB_CMDLINE_LINUX_DEFAULT='quiet splash resume=UUID=af9fa36a-afed-4638-ab57-6f4c9788e08e resume_offset=98529265'
GRUB_CMDLINE_LINUX=""
u-admin@ubuntu-server:~$ sudo update-grub
Sourcing file `/etc/default/grub'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-7.0.0-27-generic
Found initrd image: /boot/initrd.img-7.0.0-27-generic
Found linux image: /boot/vmlinuz-7.0.0-22-generic
Found initrd image: /boot/initrd.img-7.0.0-22-generic
Found linux image: /boot/vmlinuz-7.0.0-14-generic
Found initrd image: /boot/initrd.img-7.0.0-14-generic
Found memtest86+ 64bit EFI image: /boot/mt86+x64
Found memtest86+ 32bit EFI image: /boot/mt86+ia32
Found memtest86+ 64bit image: /boot/mt86+x64
Found memtest86+ 32bit image: /boot/mt86+ia32
Warning: os-prober will be executed to detect other bootable partitions.
Its output will be used to detect bootable binaries on them and create new boot entries.
Found Windows Boot Manager on /dev/nvme0n1p2@/EFI/Microsoft/Boot/bootmgfw.efi
Adding boot menu entry for UEFI Firmware Settings ...
done
u-admin@ubuntu-server:~$ sudo nano /etc/initramfs-tools/conf.d/resume
resume=UUID=af9fa36a-afed-4638-ab57-6f4c9788e08e resume_offset=98529265
u-admin@ubuntu-server:~$ sudo update-initramfs -u -k all
update-initramfs: Generating /boot/initrd.img-7.0.0-27-generic
cryptsetup: ERROR: Couldn't resolve device /swapfile
update-initramfs: Generating /boot/initrd.img-7.0.0-22-generic
cryptsetup: ERROR: Couldn't resolve device /swapfile
update-initramfs: Generating /boot/initrd.img-7.0.0-14-generic
cryptsetup: ERROR: Couldn't resolve device /swapfile