Use sectorsize for partition tables on block devs

Fix for specific case #30393 where 4k sector luks container is created
on a 512b device. In this case the partition table needs to be 512b,
else the kernel will not be able to find the partition, and we will
have to create a loop device to translate the partition table to 4k.
This commit is contained in:
scarlet-storm
2026-02-17 18:23:35 +05:30
parent 6a389701b2
commit 48b9d7e980
+9 -3
View File
@@ -2365,9 +2365,15 @@ int home_create_luks(
image_sector_size = UINT32_MAX;
/* Let cryptsetup decide if the sector size is not specified in home record */
luks_sector_size = 0;
} else
luks_sector_size = image_sector_size = user_record_luks_sector_size(h);
} else {
if (S_ISBLK(st.st_mode)) {
/* For physical block devices always use the actual device logical
* sector size. Else the partition will not be discoverable by kernel. */
image_sector_size = UINT32_MAX;
luks_sector_size = user_record_luks_sector_size(h);
} else
image_sector_size = luks_sector_size = user_record_luks_sector_size(h);
}
r = make_partition_table(
setup->image_fd,
image_sector_size,