Hi @michaelolbrich , all
Are there recommendations about how to support creating images for a 4Kn storage device using genimage?
We've been testing with NVMe devices which have been set to operate with a 4096 byte logical and physical block size (i.e. 4Kn), so a sector is actually 4096 (native) bytes rather than 512. We're building GPT hd images with genimage where the vfat boot filesystem is created with -S 4096 (sets the number of bytes per logical sector) and ext4 created with -b -4096 (specifies a minimum block size of 4096). All partitions are aligned correctly (we use 8M as we've seen improved performance on large capacity SD cards).
The GPT primary header is expected at LBA1. When genimage creates a GPT hdimage, it inserts the GPT primary header at offset +512 bytes into the image file:
https://github.com/pengutronix/genimage/blob/master/image-hd.c#L534.
This is fine for an LBA size of 512 (512e or 512n) but not 4Kn where it should be +4096 bytes.
To handle 4Kn devices, it appears as though genimage needs to know the logical sector size so it can factor it into it's calculations, e.g. have some abstraction for positioning of blobs that require an LBA offset rather than assuming one LBA unit is 512 bytes.
Boot firmware that is able to transparently support 512n, 512e and 4Kn will likely inspect attributes of the block device and use both its logical and physical block sizes in alignments checks and calculations. For example, a 4Kn device would need to have its GPT primary header offset 4K byte aligned. If it's always at offset +512 bytes, it's probably fair to say the firmware should assume a 512 byte IO unit size.
I'm not sure yet, but I suspect this only impacts GPT images.
Lack of this support appears to indicate users only format disks like this on-device.
Do you think genimage needs to gain a logical-sector-size (defaults to 512) param which is used in the appropriate calculations, or are there other ways we can create 4Kn compatible images with GPT using genimage?
-- Matt
Hi @michaelolbrich , all
Are there recommendations about how to support creating images for a 4Kn storage device using genimage?
We've been testing with NVMe devices which have been set to operate with a 4096 byte logical and physical block size (i.e.
4Kn), so a sector is actually 4096 (native) bytes rather than 512. We're building GPT hd images with genimage where the vfat boot filesystem is created with-S 4096(sets the number of bytes per logical sector) and ext4 created with-b -4096(specifies a minimum block size of 4096). All partitions are aligned correctly (we use 8M as we've seen improved performance on large capacity SD cards).The GPT primary header is expected at LBA1. When genimage creates a GPT hdimage, it inserts the GPT primary header at offset +512 bytes into the image file:
https://github.com/pengutronix/genimage/blob/master/image-hd.c#L534.
This is fine for an LBA size of 512 (512e or 512n) but not 4Kn where it should be +4096 bytes.
To handle 4Kn devices, it appears as though genimage needs to know the logical sector size so it can factor it into it's calculations, e.g. have some abstraction for positioning of blobs that require an LBA offset rather than assuming one LBA unit is 512 bytes.
Boot firmware that is able to transparently support 512n, 512e and 4Kn will likely inspect attributes of the block device and use both its logical and physical block sizes in alignments checks and calculations. For example, a 4Kn device would need to have its GPT primary header offset 4K byte aligned. If it's always at offset +512 bytes, it's probably fair to say the firmware should assume a 512 byte IO unit size.
I'm not sure yet, but I suspect this only impacts GPT images.
Lack of this support appears to indicate users only format disks like this on-device.
Do you think genimage needs to gain a
logical-sector-size(defaults to 512) param which is used in the appropriate calculations, or are there other ways we can create 4Kn compatible images with GPT using genimage?-- Matt