diskfs / go-diskfs

MIT License
515 stars 114 forks source link

non-sequential partiton numbers #254

Open toabctl opened 2 months ago

toabctl commented 2 months ago

Hi,

is there a way to create a partition table where each entry has a specific partition number? So eg. 3 partitions with the numbers, 1, 13 and 14. Like:

Device         Start     End Sectors  Size Type
/dev/nbd0p1  2099200 7339998 5240799  2.5G Linux filesystem
/dev/nbd0p15    2048  204800  202753   99M EFI System
/dev/nbd0p16  206848 2097152 1890305  923M Linux extended boot
deitch commented 2 months ago

I was about to write, "sure, just look at the type for Partition" (I assume you mean GPT), and then I saw it had nothing there. Much to my surprise. That is a good idea, so definitely open to a PR.

You would need to update gpt.Partition to include a partition number, and then update Table.toPartitionArrayBytes to account for them rather than just assigning it the next number. You also would need to be sure there were no conflicts. And tests, of course.