-
Notifications
You must be signed in to change notification settings - Fork 110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GPT table in Genimage-created images may be mangled by Windows OS #262
Comments
So my understanding was that But my understanding is clearly mistaken, or at least windows has a different understanding of what should happen here. So we should probably always do:
That's 2 + 32 = 34 for the default partition table location. If the partition table is moved to make room for a bootloader, then that should still be acceptable based on you're description above. |
Hi Michael, first of all, sorry for the delayed reply.
Well, I'd assume the same but obviously Microsoft engineers thought it's good idea to do it like this. I haven't found any reasoning why it's happening, and I think it's too esoteric to cause any other issues. Just find the cause of the problem was quite a detective work.
It's essentially the same what I ended up with: home-assistant/operating-system#3497 (just taking into the fact that FWIW, the root cause for the RPi bootloader issue has been found and fix is on the way, but I think it'd be still good to stay on the safe side and adjust the Genimage behavior, as I'm not aware of any side effects. |
Windows (at least starting with version 10) contain logic that alters the GPT table of a drive connected to it in some cases. More specifically it's been found it relocates the backup GPT table to the end of the drive and the partition array to LBA address equal to
first_usable_lba - 32
. There is no (easy) way to prevent this behavior in Genimage-created images becausefirst_usable_lba
is always set to the start of the first partition. Although this is rather a Windows bug/misfeature, images created using other utilities (likesgdisk
) are not affected by this, as they generally setfirst_usable_lba
to LBA 34, so it should be possible to achieve the same with Genimage.For details see:
These issues show a real world regression triggered by the fact that Genimage works slightly different compared to other utilities. In theory I can imagine this relocation might also overwrite data located between the GPT header and the first actual partition if this area of the disk contained for example some bootloader data - although this is purely hypothetical.
I'd like to discuss the potential ways to mitigate this issue. Should we add a flag for setting
first_usable_lba
to the lowest possible value, or an arbitrary one, or even set it always to 34 likesgdisk
does? Currently it's correlated to thealign
value but setting it to a one-sector size and juggling with offset values afterwards feels rather clumsy to me.The text was updated successfully, but these errors were encountered: