Skip to content
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

RFE: add ability to set UUID and disk name via libfdisk API calls #916

Closed
poettering opened this issue Dec 16, 2019 · 5 comments
Closed

Comments

@poettering
Copy link
Contributor

I am looking for a way to set GPT disk UUID via libfdisk API calls. i.e. i create a new GPT label and set the overall disk UUID before writing it out. There are calls for reading the this field back in fdisk_get_disklabel_id() but I want to be able to write it instead (background: a reproducible partitioning tool that generates the UUIDs from a reproducible random source so that disk images can be regenerated safely).

Or in other words: I want to be able to set the DiskGUID field mentioned in EFI spec section 5.3.2.

@karelzak
Copy link
Collaborator

There is fdisk_set_disklabel_id(), but it's dialog-driven API ;-(

Another way is to use script API and set "label-id" before you create the label.

sc = fdisk_new_script();

fdisk_script_set_header(sc, "label-id", "uuid string");
fdisk_set_script(cxt, sc);

fdisk_create_disklabel(cxt, "gpt");
... 

The script is a common way how to push many options to the label drivers when you want to avoid dialogs.

@karelzak
Copy link
Collaborator

And it's pretty simple to extend the scripts if you will need anything else in the future. It's also possible to dump/read the script to the file.

@poettering
Copy link
Contributor Author

Hmm, would still prefer if there was an explicit API for that.

(But I remember we talked about this before, and last time too I opted to use the "ask" API to solve the issue, will do so now too. I must say I would much prefer avoiding the script and ask APIs though for my purposes)

@karelzak
Copy link
Collaborator

Well, dance with ask API if do not want dialog is ugly ;-) ... but the script is an elegant way. Ignore the name of this API, it does parse anything, it's just a list of keys and values which are usable for PT driver.

Anyway, you're right for so commonly used things like ID it would be nice to have an explicit function. I'll implement it for the next release.

@poettering
Copy link
Contributor Author

excellent! thank you very much!

karelzak added a commit that referenced this issue Jan 14, 2020
We have fdisk_set_disklabel_id(), but it's old ask-API based function.
It's not comfortable if you want to avoid dialog or template.

Addresses: #916
Signed-off-by: Karel Zak <kzak@redhat.com>
karelzak added a commit that referenced this issue Jan 14, 2020
Addresses: #916
Signed-off-by: Karel Zak <kzak@redhat.com>
karelzak added a commit that referenced this issue Jan 23, 2020
We have fdisk_set_disklabel_id(), but it's old ask-API based function.
It's not comfortable if you want to avoid dialog or template.

Addresses: #916
Signed-off-by: Karel Zak <kzak@redhat.com>
karelzak added a commit that referenced this issue Jan 23, 2020
Addresses: #916
Signed-off-by: Karel Zak <kzak@redhat.com>
@karelzak karelzak closed this as completed Jun 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants