[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-xorriso] ISO installer image: GPT versus MBR partitions
From: |
Thomas Schmitt |
Subject: |
Re: [Bug-xorriso] ISO installer image: GPT versus MBR partitions |
Date: |
Wed, 24 Apr 2019 12:34:16 +0200 |
Hi,
Florian Pelz wrote:
> Sorry, I meant to quote this aspect:
I wrote:
> > > One can read trailing garbage not only from USB sticks but also from
> > > most DVD types.
Florian Pelz wrote:
> > So… GPT is wrong for some optical media too?
I wrote:
> Not in this aspect. GPT partitions must not start at block 0.
> So the overall ISO superblock is not mountable as partition and thus
> free to claim the full image size as filesystem size.
I already understood you correctly ... i think. :))
GPT partitioned ISO are not hampered from telling the full image
size as size of the ISO 9660 filesystem.
$ /sbin/gdisk -l guixsd-install-0.15.0.i686-linux.iso
...
Number Start (sector) End (sector) Size Code Name
1 64 34107 16.6 MiB 0700 Gap0
2 34108 39867 2.8 MiB EF00 EFI boot partition
3 39868 1815727 867.1 MiB AF00 HFSPLUS
4 1815728 1816327 300.0 KiB 0700 Gap1
$ expr $(/sbin/isosize guixsd-install-0.15.0.i686-linux.iso) / 512
1816376
The isosize is a bit larger than the end of partition 4, because after
this partition comes the GPT backup.
The isosize matches the image file size:
$ expr $(ls -l guixsd-install-0.15.0.i686-linux.iso | awk '{print $5}') / 512
1816376
But an MBR partition which begins by block 0 and is mountable as ISO 9660
filesystem keeps its ISO superblock from telling a size larger than the
partition. So it cannot claim an appended partition 2 as part of its range.
$ export MKRESCUE_SED_MODE=mbr_hfs
$ grub-mkrescue --xorriso=./grub-mkrescue-sed.sh -o output.iso minimal \
--iso_mbr_part_type 0x83
...
$ /sbin/fdisk -l output.iso
...
Disklabel type: dos
...
Device Boot Start End Sectors Size Id Type
output.iso1 * 0 28371 28372 13.9M 83 Linux
output.iso2 28372 34131 5760 2.8M ef EFI (FAT-12/16/32)
$ expr $(/sbin/isosize output.iso) / 512
28372
This discrepancy of image file size and isosize is undesirable when the
image file itself cannot say its size any more, because it is on USB
stick or a DVD which delivers more bytes than were written as image.
So i propose partition offset 16 to get the partition superblock away
from being mountable by the base device.
$ export MKRESCUE_SED_MODE=mbr_hfs
$ grub-mkrescue --xorriso=./grub-mkrescue-sed.sh -o output.iso minimal \
-partition_offset 16 --iso_mbr_part_type 0x83
This yields
$ /sbin/fdisk -l output.iso
...
Disklabel type: dos
...
Device Boot Start End Sectors Size Id Type
output.iso1 * 64 28695 28632 14M 83 Linux
output.iso2 28696 34455 5760 2.8M ef EFI (FAT-12/16/32)
The ISO filesystem of the overall image then claims the image file size
$ expr $(/sbin/isosize output.iso) / 512
34456
With the partition's ISO filesystem we only get the partition size:
$ dd if=output.iso bs=512 skip=64 of=partition1.iso
$ expr $(/sbin/isosize partition1.iso) / 512
28632
This is how it should be.
The ISOs of Fedora, Debian, Ubuntu, and others are MBR partitioned and
most of them have no partition offset 16. But despite that fact they can
claim the full image size as ISO 9660 filesystem size.
This is possible because partition 1 covers the whole image and partition 2
is located inside partition 1. Strictly illegal in UEFI specs, unless
the outer partition has MBR partition type 0x00 and thus does not exist
for EFI and some partition editors. (I.e. this is a really dirty hack.)
$ /sbin/fdisk -l debian-live-9.8.0-amd64-xfce.iso
...
Disklabel type: dos
...
Device Boot Start End Sectors Size Id Type
debian-live-9.8.0-amd64-xfce.iso1 * 0 3811391 3811392 1.8G 0 Empty
debian-live-9.8.0-amd64-xfce.iso2 1432 2263 832 416K ef EFI
(FAT-1
$ expr $(/sbin/isosize debian-live-9.8.0-amd64-xfce.iso) / 512
3811392
Old /sbin/gdisk only reports partition 2:
$ /sbin/gdisk -l debian-live-9.8.0-amd64-xfce.iso
...
Found valid MBR and GPT. Which do you want to use?
...
Your answer: 1
...
Number Start (sector) End (sector) Size Code Name
2 1432 2263 416.0 KiB EF00 EFI System
Have a nice day :)
Thomas
Re: [Bug-xorriso] ISO installer image: GPT versus MBR partitions, Thomas Schmitt, 2019/04/23
- Re: [Bug-xorriso] ISO installer image: GPT versus MBR partitions, pelzflorian (Florian Pelz), 2019/04/23
- Re: [Bug-xorriso] ISO installer image: GPT versus MBR partitions, Thomas Schmitt, 2019/04/23
- Re: [Bug-xorriso] ISO installer image: GPT versus MBR partitions, pelzflorian (Florian Pelz), 2019/04/23
- Re: [Bug-xorriso] ISO installer image: GPT versus MBR partitions, Thomas Schmitt, 2019/04/24
- Re: [Bug-xorriso] ISO installer image: GPT versus MBR partitions, pelzflorian (Florian Pelz), 2019/04/24
- Re: [Bug-xorriso] ISO installer image: GPT versus MBR partitions,
Thomas Schmitt <=
- Re: [Bug-xorriso] ISO installer image: GPT versus MBR partitions, Danny Milosavljevic, 2019/04/25
- Re: [Bug-xorriso] ISO installer image: GPT versus MBR partitions, Thomas Schmitt, 2019/04/25
- Re: [Bug-xorriso] ISO installer image: GPT versus MBR partitions, pelzflorian (Florian Pelz), 2019/04/25
- Re: [Bug-xorriso] ISO installer image: GPT versus MBR partitions, Thomas Schmitt, 2019/04/25
- Re: [Bug-xorriso] ISO installer image: GPT versus MBR partitions, Danny Milosavljevic, 2019/04/25
- Re: [Bug-xorriso] ISO installer image: GPT versus MBR partitions, Thomas Schmitt, 2019/04/25
- Re: [Bug-xorriso] ISO installer image: GPT versus MBR partitions, Danny Milosavljevic, 2019/04/25
- Re: [Bug-xorriso] ISO installer image: GPT versus MBR partitions, Thomas Schmitt, 2019/04/25
- Re: [Bug-xorriso] ISO installer image: GPT versus MBR partitions, Danny Milosavljevic, 2019/04/25
Re: [Bug-xorriso] ISO installer image: GPT versus MBR partitions, Ludovic Courtès, 2019/04/25