How can I label a disk?
I want to do the equivalent of parted /dev/sdb mklabel gpt using pyparted but I can't figure this out from the (slim) documentation or by inspecting the pyparted source code and examples.
Any hints?
there is a very similar (but unmaintained) package called python-parted that has the necessary functionality.
https://github.com/dkmstr/python-parted
In this other package, the syntax is:
dsk = dev.new_table(disk.DiskType.WNT.GPT)
Answering my own question:
disk = parted.freshDisk(dev, "gpt")
disk.commit()
is the non-intuitive equivalent of mklabel gpt.
I would be happy to write this up. It might be good as part of the README to have a section that describes the equivalence between common parted idioms like this and the python code that can be used to implement them.
Thoughts?