4K sector size, cryptswap, with/-out dm-integrity?
Thorsten Glaser <[email protected]> Fri, 10 Jul 2026 19:14:55 +0200 (CEST)
| Newsgroups | dev.linux.lists.cryptsetup |
|---|---|
| Message-ID | <[email protected]> |
Hi, I=E2=80=99ve been looking a bit at how 4K sector sizes are passed through the stack today, and I=E2=80=99m wondering a bit about things the docs don=E2=80=99t have sufficiently deep details for. AIUI, and please correct me if I=E2=80=99m wrong anywhere: First, the easy(?) cases: - HDD with 512 bytes underlying sector size =E2=87=92 4K sectors never ok - SSD with 512 bytes logical sector size and no 4K listed in the =E2=80=9Csmartctl -c /dev/nvme0n1=E2=80=9D / =E2=80=9Cnvme id-ns -H /= dev/nvme0n1=E2=80=9D output =E2=87=92 4K sectors likely not ok? - HDD/SSD with 4K logical sectors =E2=87=92 4K sectors ok The documentation also says that this should be: - dm-integrity device with --sector-size 4096 in journalled mode =E2=87=92 = ok - does this even differ between underlying 512/512, 512/4K, 4K/4K devices= ? - same but in D (direct) mode =E2=87=92 not ok unless underlying device is - 4K/4K? - 512/4K or 4K/4K (see below)? - same but in B (bitmap) mode =E2=87=92 ? - same but in I (inline) mode =E2=87=92 only ok if the underlying device ma= tches? - R (recovery) mode is special anyway Then, there=E2=80=99s this one: - HDD with 512b logical and 4K physical sectors according to =E2=80=9Chdparm -I=E2=80=9D/=E2=80=9Csmartctl -i=E2=80=9D =E2=87=92 that = ok? And the thing I=E2=80=99ve really been wondering about is: at the moment, I use encrypted swap like this (crypttab): # <target name> <source device> <key file> <options> cswp1 /dev/=E2=80=A6=E2=80=A6=E2=80=A6 /dev/urando= m discard,cipher=3Daes-xts-plain64,size=3D512,plain,swap Is it possible to add =E2=80=9C,sector-size=3D4096=E2=80=9D to that line an= d will it help (encrypting 4K in one go is faster than eight times 512b after all)? Does the kernel swapping subsystem work with that? (On amd64, so my page size is 4096, though since 4K pages on 512b devices works, 16K/64K pages on 4K devices will likely also work for things like MIPS, ARM=E2=80=A6) If so, under the same circumstances as above? (Either 4K logical device (which I seem to not have) or 4K integritysetup with journal (also on 512/4K or 512/512 devices?) or MAYBE 512/4K devices?) I=E2=80=99ve been putting integritysetup with 4K sectors and journal under my RAID-1+LUKS recently already anyway, even if performance is=E2=80=A6 lacking. But I should stick to J (journal) mode with this, no? Thanks, //mirabilos --=20 =E2=80=9ECool, /usr/share/doc/mksh/examples/uhr.gz ist ja ein Grund, mksh auf jedem System zu installieren.=E2=80=9C =09-- XTaran auf der OpenRheinRuhr, ganz begeistert (EN: =E2=80=9C[=E2=80=A6]uhr.gz is a reason to install mksh on every system= =2E=E2=80=9D)