Arch Linux

Please read this before reporting a bug:

Do NOT report bugs when a package is just outdated, or it is in the AUR. Use the 'flag out of date' link on the package page, or the Mailing List.

REPEAT: Do NOT report bugs for outdated packages!

FS#72119 - [cryptsetup] add support for sector-size option in encrypt hook

Attached to Project: Arch Linux
Opened by Alexey Rychkov (nightfog) - Monday, 13 September 2021, 13:12 GMT
Last edited by Christian Hesse (eworm) - Monday, 20 March 2023, 07:56 GMT
Task Type Feature Request
Category Packages: Core
Status Closed
Assigned To Christian Hesse (eworm)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 1
Private No


As of 2.4.0-1, the plain dm-crypt device, created with non-default (512) sector-size parameter, is impossible to use.
Even more, user has no way to know that's wrong, because for such devices there is no error on cryptsetup open command. Problems usually arise at mount attempt.
The source of the problem is that the device is created and opened with different sector sizes. At the moment it's always opened with 512 bytes long sector size.
I suppose to propagate sector-size option too, additionally to already supported. It's cryptdevice third argument, we can use a form 'sector-size=value'.
This task depends upon

Closed by  Christian Hesse (eworm)
Monday, 20 March 2023, 07:56 GMT
Reason for closing:  Fixed
Additional comments about closing:  in SVN
Comment by Alexey Rychkov (nightfog) - Friday, 17 September 2021, 07:54 GMT
Proposed solution
Comment by Christian Hesse (eworm) - Monday, 20 September 2021, 07:40 GMT
This looks really wrong. Instead of mis-using the default switch target (and adding a nested one) you should add a new switch target ("sector-size=*)").

Wondering if we really need this. Still trying to understand your issue... Does your plain dm-crypt use a sector size of 512 bytes or something different?
Comment by Alexey Rychkov (nightfog) - Monday, 20 September 2021, 17:44 GMT
I use the plain dm-crypt with a sector size = 4096 bytes. That was the option when I opened the device with cryptsetup and formatted a filesystem.
Then at boot time it failed to mount. With the supplied patch or by other means specifying sector-size option (hard-coding encrypt hook) it works.
Comment by Christian Hesse (eworm) - Monday, 20 September 2021, 19:10 GMT
Does this work for you?
Comment by Alexey Rychkov (nightfog) - Tuesday, 21 September 2021, 04:45 GMT
Yes, it works with this patch.
Actually I have changed my mind about this option. I think it's a better place for it within 'crypto'.
All options of cryptdevice parameter seemed non essential, optimization options.
But crypto options are different. They are designed for a plain mode.
Consider the fourth option offset. Personally I didn't use it. But someone do. And for them the target is unusable without it, means if they couldn't pass it through. The sector-size is completely the same in logical terms. Most people never need it, but for someone (me) it's vital to support it.
Do you think it worth the effort to transfer this option into crypto group?
It could be made optional sixth argument so it will not break the existing setups.
Comment by Alexey Rychkov (nightfog) - Wednesday, 22 September 2021, 17:43 GMT
Could you please consider the following patch. I have tested it with my setup.
Comment by Neven Sajko (Neven) - Thursday, 05 May 2022, 22:40 GMT
Just a thought, maybe helps someone: I think it's possible to work around this by changing the default sector size on the SSD side (assuming the disk here is an SSD). See and the rest of that page.