Skip to content

Instantly share code, notes, and snippets.

@zburgermeiszter
Forked from tjvr/crypttab
Created September 11, 2021 23:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zburgermeiszter/0d577560b38856d93c0d1b31b709e2dc to your computer and use it in GitHub Desktop.
Save zburgermeiszter/0d577560b38856d93c0d1b31b709e2dc to your computer and use it in GitHub Desktop.
Hibernate on Ubuntu 18.04 with LVM full-disk encryption
sda5_crypt UUID=c66880c1-c2f1-40fc-9580-f25d493876ef none luks,discard
# /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>
/dev/mapper/ubuntu--vg-root / ext4 errors=remount-ro 0 1
# /boot was on /dev/sda1 during installation
UUID=3a4152dc-b401-4ae3-96b7-b8da7d918023 /boot ext4 defaults 0 2
/dev/mapper/ubuntu--vg-swap_1 none swap sw 0 0
$ swapon -s
Filename				Type		Size	Used	Priority
/dev/dm-2                              	partition	16777212	0	-2
texas:~$ sudo lvdisplay
[sudo] password for tim: 
  --- Logical volume ---
  LV Path                /dev/ubuntu-vg/root
  LV Name                root
  VG Name                ubuntu-vg
  LV UUID                vEByY0-UUvE-OgLU-caQo-gku0-yt05-9l70KP
  LV Write Access        read/write
  LV Creation host, time ubuntu, 2018-07-07 15:08:49 +0100
  LV Status              available
  # open                 1
  LV Size                420.00 GiB
  Current LE             107520
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1
   
  --- Logical volume ---
  LV Path                /dev/ubuntu-vg/swap_1
  LV Name                swap_1
  VG Name                ubuntu-vg
  LV UUID                L3AKIc-rK4X-uy4l-jFuM-C1fc-TrNt-yodzsL
  LV Write Access        read/write
  LV Creation host, time ubuntu, 2018-07-07 15:08:49 +0100
  LV Status              available
  # open                 2
  LV Size                16.00 GiB
  Current LE             4096
  Segments               2
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:2

The fix

Edit /etc/initramfs-tools/conf.d/resume:

RESUME=/dev/mapper/ubuntu--vg-swap_1

Edit /etc/default/grub:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash resume=/dev/mapper/ubuntu--vg-swap_1"
sudo update-initramfs -u -k all
sudo update-grub
HandleSuspendKey=hibernate
HandleLidSwitch=hybrid-sleep
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment