You are not logged in.
Hello there,
I was configuring an encrypted swap partition using dm-crypt, as described here.
The partition I'm trying to use for my swap space is the following:
/dev/nvme0n1p2: PARTUUID="6588817b-63c8-47cc-8306-6672adeafeb1"Such partition is roughly 4GiB in size, as confirmed by "lsblk" (N.B I am aware my swap is not mounted yet):
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
nvme0n1 259:5 0 465.8G 0 disk
├─nvme0n1p1 259:6 0 1G 0 part /boot
├─nvme0n1p2 259:7 0 4G 0 part
│ └─swap 254:1 0 4G 0 crypt
└─nvme0n1p3 259:8 0 460.8G 0 part
└─root 254:0 0 460.7G 0 crypt /I'm re-encrypting it upon every boot with a fresh key thanks to the following line in my /etc/crypttab:
# <name> <device> <password> <options>
swap PARTUUID=6588817b-63c8-47cc-8306-6672adeafeb1 /dev/urandom swap,cipher=aes-xts-plain64,size=512,sector-size=4096At this point I was trying to inspect my swap volume mapper with the following command and I am confused by the sizes reported in its output:
# cryptsetup status swap/dev/mapper/swap is active.
type: PLAIN
cipher: aes-xts-plain64
keysize: 512 [bits]
key location: dm-crypt
device: /dev/nvme0n1p2
sector size: 4096 [bytes]
offset: 0 [512-byte units] (0 [bytes])
size: 8392704 [512-byte units] (34376515584 [bytes])
mode: read/writeSpecifically, it says 8392704 [512-byte units] which adds up to the exact size in bytes of my swap partition, multiplying 8392704 by 512.
However, the other size - 34376515584 bytes - doesn't mean anything to me.
It's 32 GiB but that doesn't correspond to anything on my system. Initially I thought it could have been the amount of memory in my system but I have 64GB of RAM - not 32. So what gives?
Obviously I tried searching around and reading man pages but I could not find the answer to my question.
Last edited by brainplot (2025-12-30 13:29:44)
Offline
probably a bug? says 512 byte units but multiplies with 4096. some math isn't mathing somewhere, in the cryptsetup status code.
https://gitlab.com/cryptsetup/cryptsetu … L1022-1025
the [512-byte units] part of the message is hardcoded, then multiplies with a variable sector size, which is incorrect if the size given was actually in 512-byte sectors regardless of specified sector size
Last edited by frostschutz (2025-12-29 23:37:32)
Offline
Yep, looks like they mistakenly multiply devmapper device size in 512-byte units by device-specific sector size, which can be 4096 bytes. Deserves to be reported as a bug.
Last edited by dimich (2025-12-30 07:44:31)
Offline
That makes sense. I reported it upstream.
Thank you frostschutz for taking the time to look through the code. I mentioned your finding in the issue.
Offline