Unlike LUKS1, the sector size of LUKS2 devices isn't hardcoded. Regarding the probe command, the following values of --target switch are affected: abstraction, arc_hints, baremetal_hints, bios_hints, cryptodisk_uuid, drive, efi_hints, hints_string, ieee1275_hints, zero_check.
For example using the --target=drive option: # dd if=/dev/zero of=data count=10 bs=1M # losetup --show -f data /dev/loop4 # echo -n pass | cryptsetup luksFormat -v --type luks2 /dev/loop4 Key slot 0 created. Command successful. # echo -n pass | cryptsetup -v open /dev/loop4 test No usable token is available. Key slot 0 unlocked. Command successful. # grub-probe --device /dev/mapper/test --target=cryptodisk_uuid grub-probe: error: disk `cryptouuid/f353c0f04a6a4c08bc53a0896130910f' not found. The updated output: # grub-probe --device /dev/mapper/test --target=cryptodisk_uuid f353c0f04a6a4c08bc53a0896130910f Signed-off-by: Pierre-Louis Bonicoli <pierre-louis.bonic...@libregerbil.fr> --- grub-core/kern/disk.c | 4 +++- grub-core/osdep/devmapper/getroot.c | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/grub-core/kern/disk.c b/grub-core/kern/disk.c index e1b0e073e..b042ceb63 100644 --- a/grub-core/kern/disk.c +++ b/grub-core/kern/disk.c @@ -237,8 +237,10 @@ grub_disk_open (const char *name) name); goto fail; } - if (disk->log_sector_size > GRUB_DISK_CACHE_BITS + GRUB_DISK_SECTOR_BITS + if ((disk->log_sector_size > GRUB_DISK_CACHE_BITS + GRUB_DISK_SECTOR_BITS || disk->log_sector_size < GRUB_DISK_SECTOR_BITS) + /* log_sector_size is unset for LUKS2 and that's ok */ + && !(disk->log_sector_size == 0 && dev->id == GRUB_DISK_DEVICE_CRYPTODISK_ID)) { grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, "sector sizes of %d bytes aren't supported yet", diff --git a/grub-core/osdep/devmapper/getroot.c b/grub-core/osdep/devmapper/getroot.c index 96781714c..4f51c113c 100644 --- a/grub-core/osdep/devmapper/getroot.c +++ b/grub-core/osdep/devmapper/getroot.c @@ -180,7 +180,8 @@ grub_util_pull_devmapper (const char *os_dev) grub_util_pull_device (subdev); } } - if (uuid && strncmp (uuid, "CRYPT-LUKS1-", sizeof ("CRYPT-LUKS1-") - 1) == 0 + if (uuid && (strncmp (uuid, "CRYPT-LUKS1-", sizeof ("CRYPT-LUKS1-") - 1) == 0 + || strncmp (uuid, "CRYPT-LUKS2-", sizeof ("CRYPT-LUKS2-") - 1) == 0) && lastsubdev) { char *grdev = grub_util_get_grub_dev (lastsubdev); -- 2.34.1 _______________________________________________ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel