I want to have 32GB of SWAP on LUKS encrypted filesystem and have hibernation enabled. My basic swap partition was 1GB, and I've made ´/swapfile'of 31GB. I first tried with fallocate
command as explained here. I edited my /etc/initramfs-tools/conf.d/resume
and /etc/default/grub
to something like:
> cat /etc/initramfs-tools/conf.d/resume
RESUME=UUID=<uuid> resume_offset=<offset>
where and were result of commands:
> sudo findmnt -no UUID -T /swapfile
> sudo filefrag -v /swapfile | awk '{ if($1=="0:"){print substr($4, 1, length($4)-2)} }'
I called sudo update-grub
and sudo update-initramfs -u
. It didn't work.
Than I tried deleting old /swapfile
and creating new with dd
command.
> sudo dd if=/dev/zero of=/swapfile bs=1024 count=32768k
33554432+0 records in
33554432+0 records out
34359738368 bytes (34 GB, 32 GiB) copied, 69,0213 s, 498 MB/s
> sudo mkswap /swapfile
mkswap: /swapfile: insecure permissions 0644, 0600 suggested.
Setting up swapspace version 1, size = 32 GiB (34359734272 bytes)
no label, UUID=b86d678c-9717-44a0-876d-6ee9e26f3685
> sudo chmod 0600 /swapfile
> sudo swapon -a
Than I used UUID from the above and edited /etc/initramfs-tools/conf.d/resume
and /etc/default/grub
again, and called
sudo update-grub
and sudo update-initramfs -u
. Here are some outputs:
> cat /etc/initramfs-tools/conf.d/resume
RESUME=UUID=b86d678c-9717-44a0-876d-6ee9e26f3685
> sudo update-initramfs -u
update-initramfs: Generating /boot/initrd.img-5.13.0-22-generic
cryptsetup: ERROR: Couldn't resolve device
UUID=b86d678c-9717-44a0-876d-6ee9e26f3685
W: initramfs-tools configuration sets RESUME=UUID=ea58698b-f7ec-425a-950f-f5e5bae157ce
W: but no matching swap device is available.
I: The initramfs will attempt to resume from /dev/dm-2
I: (/dev/mapper/vgubuntu-swap_1)
I: Set the RESUME variable to override this.
I've also tried chancing /etc/fstab
entry from /swapfile
to UUID
, but it didn't work
A bit more system information:
> blkid
/dev/mapper/nvme0n1p3_crypt: UUID="5XbV4n-kt79-RvIe-xKsA-ZfX3-fqLJ-8FW9Zt" TYPE="LVM2_member"
/dev/mapper/vgubuntu-root: UUID="ea58698b-f7ec-425a-950f-f5e5bae157ce" BLOCK_SIZE="4096" TYPE="ext4"
/dev/nvme0n1p3: UUID="f7314e8e-de0d-4932-a081-5ebbaec6434b" TYPE="crypto_LUKS" PARTUUID="89c52d41-d933-4ea0-8741-0e52d04f82f7"
/dev/loop0: TYPE="squashfs"
/dev/loop1: TYPE="squashfs"
/dev/loop2: TYPE="squashfs"
/dev/loop3: TYPE="squashfs"
/dev/loop4: TYPE="squashfs"
/dev/loop5: TYPE="squashfs"
/dev/loop6: TYPE="squashfs"
/dev/loop7: TYPE="squashfs"
/dev/nvme1n1p1: UUID="5d52d5c1-aa21-4a99-8faa-7b397017ae5e" TYPE="crypto_LUKS" PARTUUID="6cc4e2cc-c761-47f4-9a17-522bfcb5db9e"
/dev/nvme0n1p1: UUID="E470-EC97" BLOCK_SIZE="512" TYPE="vfat" PARTLABEL="EFI System Partition" PARTUUID="8852d515-0378-4677-ac67-544c672c1e2c"
/dev/nvme0n1p2: UUID="cf67ab1d-e312-40d5-85f2-5f8fd33e3aab" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="7f2c243e-c977-44ae-84b8-783994279798"
/dev/mapper/vgubuntu-swap_1: UUID="da63ab4f-fdeb-4f50-832c-85d31e9fe479" TYPE="swap"
/dev/loop8: TYPE="squashfs"
/dev/loop9: TYPE="squashfs"
/dev/loop10: TYPE="squashfs"
/dev/loop11: TYPE="squashfs"
/dev/loop12: TYPE="squashfs"
/dev/loop13: TYPE="squashfs"
/dev/loop14: TYPE="squashfs"
/dev/mapper/luks-5d52d5c1-aa21-4a99-8faa-7b397017ae5e: LABEL="/home" UUID="af98cf42-73d6-450a-a2fb-b6cd3a16a04b" BLOCK_SIZE="4096" TYPE="ext4"
> 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>
/dev/mapper/vgubuntu-root / ext4 errors=remount-ro 0 1
# /boot was on /dev/nvme0n1p2 during installation
UUID=cf67ab1d-e312-40d5-85f2-5f8fd33e3aab /boot ext4 defaults 0 2
# /boot/efi was on /dev/nvme0n1p1 during installation
UUID=E470-EC97 /boot/efi vfat umask=0077 0 1
/dev/mapper/vgubuntu-swap_1 none swap sw 0 0
/swapfile none swap sw 0 0
UUID=af98cf42-73d6-450a-a2fb-b6cd3a16a04b /home ext4 defaults 0 2
> ls /dev/mapper
control nvme0n1p3_crypt vgubuntu-swap_1
luks-5d52d5c1-aa21-4a99-8faa-7b397017ae5e vgubuntu-root
> /etc/crypttab
nvme0n1p3_crypt UUID=f7314e8e-de0d-4932-a081-5ebbaec6434b none luks,discard
luks-5d52d5c1-aa21-4a99-8faa-7b397017ae5e UUID=5d52d5c1-aa21-4a99-8faa-7b397017ae5e none nofail
I tried various combinations of either file offset and drive UUID in both grub and initramfs-tools. I even tried plain restarting and hoping it will work. I have no idea what to do next. Does anyone have the solution for this?