| 13 Dec 2023 |
lassulus | yeah | 16:16:50 |
matthewcroughan | * You mean in gpt.nix as-is? | 16:16:50 |
matthewcroughan | _create and _hybridCreate? | 16:16:59 |
matthewcroughan | Here's how _create looks from the hybrid PR:
_create = diskoLib.mkCreateOption {
inherit config options;
default = { dev }: ''
${(config.content._create { inherit dev; })}
sgdisk -h \
${lib.concatMapStringsSep ":" (hp: (toString hp.gptPartitionNumber)) config.hybrid_partitions}${lib.optionalString (!config.efiGptPartitionFirst) ":EE"} \
${dev}
${lib.concatImapStrings (i: hp: hp._create {inherit dev; partNum = i + (if config.efiGptPartitionFirst then 1 else 0 );}) config.hybrid_partitions}
'';
};
| 16:17:58 |
lassulus | maybe just an optionalString in the create, which only runs if any of the partitions has the hybrid flag set (and no more than 3 have it set) and then does the collection of the partitions | 16:18:36 |
matthewcroughan | This flag is used in startlingly few places https://sourcegraph.com/search?q=context:global+sgdisk+-h&patternType=standard&sm=1&groupBy=repo | 16:25:32 |
matthewcroughan | https://gist.github.com/syzdek/ac4bb4ddc9414839474dbea64cdc5897 | 16:28:49 |
matthewcroughan | a good example of using it | 16:28:54 |
matthewcroughan | * a good example of using it with --hybrid | 16:29:01 |
matthewcroughan | Ah I see, you're saying to run a second sgdisk command if the partition is marked as hybrid, I was trying to shove it all into one invocation | 16:30:27 |
lassulus | maybe it's easier to do in in a postCreateHook first on the table | 16:32:28 |
lassulus | and then make it options afterward | 16:32:36 |
matthewcroughan | Yeah, given that this is non-standard is it even a good idea to add it to disko? | 16:32:45 |
lassulus | if it's justa few lines sure | 16:32:55 |
lassulus | if it's significantly more, probably an example would be better | 16:33:13 |
matthewcroughan | hybrid is a hack, and if you use a partitioning tool other than sgdisk on the drive could fsck the disk up | 16:33:06 |
lassulus | yeah, just do the example route for now | 16:33:29 |
lassulus | and add it as one to the repo, so we can test it | 16:33:43 |
matthewcroughan | so if disko ever migrated away from sgdisk, the aspirations of an updateScript would break drives done this way | 16:33:49 |
lassulus | not sure an updateScript can ever touch the parition tables. but yeah :D | 16:34:19 |
matthewcroughan | Oh okay, that makes sense then. | 16:35:06 |
matthewcroughan | I'm wondering about the erase-your-darlings setup now, and how you could use disko to repartition/reorganize the drives on each boot, how abusive is that to the drive? | 16:41:26 |
lassulus | usually partition tables and partitions are quite small in size. it's the stuff you put on there that makes more writes. so I guess should be fine? | 16:52:28 |
matthewcroughan | Been having no luck with hybrid mbr stuff and the Pi | 18:14:47 |
matthewcroughan | A good blog post on it https://www.eisfunke.com/posts/2023/uefi-boot-on-raspberry-pi-3.html | 18:27:01 |
matthewcroughan |
Again, I recommend leaving your fingers off the partitioning now that we’re done. The hybrid MBR in combination with the somewhat finicky RPi bootloader really is quite fragile. For example, at one point in a test run I had the disk flag pmbr_boot shown on the SD card in parted. I guess that stemmed from me setting the bootable flag when hybridizing, I’m not 100% sure. Anyway, I tried to disable it with disk_toggle pmbr_boot in parted, which promptly broke the boot – the UEFI firmware didn’t load anymore, and toggling the flag again didn’t fix it.
| 18:28:14 |
matthewcroughan | amazing | 18:28:15 |
matthewcroughan | lassulus: after the past 3-4 hours of debugging, it turns out that the raspberry pi 3 needs the fat32 partition to be the first partition which is impractical to work around with disko atm | 20:27:32 |
matthewcroughan | ditching gpt is the only sensible way, even with hybrid mbr it's just totally messed up | 20:27:50 |
matthewcroughan | sgdisk --hybrid puts the protective mbr (0xee) as the first partition, but the pi's firmware (bootcode.bin) doesn't like that | 20:28:58 |