Setting correct size for "cryptsetup: WARNING: Option 'size' missing in crypttab for plain dm-crypt mapping root" message

I have a full disk encryption using ecryptfs, after upgrading to 18.10 a warning message started to appearing at boot:

cryptsetup: WARNING: Option 'size' missing in crypttab for plain dm-crypt mapping root. Please read /usr/share/doc/cryptsetup/README.initramfs and add the correct 'size' option to your crypttab(5).

From what I see at /usr/share/doc/cryptsetup-initramfs/README.initramfs.gz I should edit /etc/cryptsetup and set the correct size, but how should this size be calculated for my system?

This is the content of /etc/crypttab:

 cryptswap1 UUID=1d1XXXXXXXXXXXX /dev/urandom swap,offset=1024,cipher=aes-xts-plain64

Solution 1:

Add the size like size=256 to /etc/crypttab configuration:

cryptswap1 UUID=1d1XXXXXXXXXXXX /dev/urandom swap,offset=1024,cipher=aes-xts-plain64,size=256

Solution 2:

Editing the 'crypttab' file was not enough in my case (upgraded to Ubuntu 20.04).

After editing the file, I had to disable (temporary) the swap file and re-generate the initramfs image:

sudo swapoff -a
sudo update-initramfs -c -k all
sudo swapon -a

Unfortunately, that step should be repeated after every kernel update.