Re: Block sizes in ISOs. was: USB Install Fails, Complains about CD-ROM
Hi,
Pascal Hambourg wrote:
> I have never seen a hard disk or flash drive with a sector size of 2048
> (only 512 or 4096) so the kernel must be correct and the Apple partition
> table must be wrong.
Both are correct. The kernel reports what it perceives as hardware block
size ("physical"). The Apple Partition Map is free to use one of several
block sizes. (In case of a "mjg" isohybrid it is 2048 in order to give
room for the GPT header block at byte 512 to 1023. The first APM entry
then begins at byte 2048.)
It is the partition editor who is clueless. (One wonders how those editors
get to their hunchbacked representations from quite clear partition table
specs.)
> Can you please explain why the wrong block size does not matter ?
Block size matters in various aspects. But these aspects refer to own info
sources which do not necessarily tell the same number.
In a Debian x86 isohybrid we have the following block sizes:
- The MBR partition table assumes block size 512. To be used when converting
Logical Block Address and block count to the byte offsets of partitions.
- The El Torito Sector Count assumes block size 512. To be used when loading
the BIOS boot image into memory, or when accepting the EFI boot image as
EFI System Partition.
- The El Torito Load RBA (start block of the boot image) assumes block size
2048. To be used when loading or accepting the boot image.
- The Apple Partition Map announces block size 2048. To be used when
converting block addresses and counts of the APM to byte offsets.
- The ISO 9660 filesystem announces a block size of 2048. To be used when
converting block addresses and counts of the ISO metadata to byte offsets.
- Then we have the FAT filesystem in the EFI boot image. Probably it uses
a block size of 512 bytes.
Each interpreter of those structures needs to get told the matching block
size or needs to assume it correctly without being told.
> The only storage media with a bloc size of 2048 I know about are optical
> media such as CD and DVD.
Readers of ISO 9660 should obey the block size given in the Primary Volume
Descriptor. But all i know (including mine) will only work with logical
block size 2048.
The block size used with filesystem or partition table is quite independent
of the block size which the device assumes for its Logical Block Addresses.
(I think Linux demands multiples of 512 by a power of two: 512, 1024, 2048,
4096, ...)
The kernel converts the logical block addressies of filesystem or partition
table to the logical block addresses of the storage device.
(Many storage devices expose a logical block size of 512 while really having
larger storage chunks.)
> Could the Apple partition map in the image be used when booting from an
> optical disk on a Mac ?
Hardly. One can never be sure with firmware behavior, though.
Matthew J. Garrett ("mjg") introduced the APM into Fedora isohybrids in
order to mark a small HFS+ filesystem image file inside the ISO.
But Debian has no such HFS+ image, and thus does not serve that obscure
class of Apple machines which probably predate Apple's adoption of EFI.
In Fedora-Workstation-netinst-x86_64-23.iso one can see:
MBR partition table: N Status Type Start Blocks
MBR partition : 1 0x80 0x00 0 845824
MBR partition : 2 0x00 0xef 180 10780
MBR partition : 3 0x00 0x00 684488 43168
MBR partition path : 2 /images/efiboot.img
MBR partition path : 3 /images/macboot.img
...
APM : N Info
APM block size : 2048
APM gap fillers : 0
APM partition name : 1 EFI
APM partition type : 1 Apple_HFS
APM start and size : 1 45 2695
APM partition path : 1 /images/efiboot.img
APM partition name : 2 EFI
APM partition type : 2 Apple_HFS
APM start and size : 2 171122 10792
APM partition path : 2 /images/macboot.img
...
Both partition tables mark the ISO files efiboot.img and macboot.img as
partitions. The addresses match when interpreted by appropriate block sizes:
180 = 45 * 4
684488 = 171122 * 4
When debian-cd adopted this layout, the HFS+ image was omitted, but the
option to mark the EFI image in Apple Partition Map staid with the xorriso
run. So we still see an APM in debian-cd amd64 and i386 ISOs.
E.g. in debian-9.4.0-amd64-xfce-CD-1.iso :
APM : N Info
APM block size : 2048
APM gap fillers : 0
APM partition name : 1 EFI
APM partition type : 1 Apple_HFS
APM start and size : 1 1835 208
APM partition path : 1 /boot/grub/efi.img
Matthew described his invention in
http://mjg59.dreamwidth.org/11285.html
Have a nice day :)
Thomas
Reply to: