You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to create a partition on /dev/sda, but for some reason pyparted is having issues. At first I was directly creating the device based on the path, but that gave the 'unrecognized disk label' error so I tried enumerating the disks and checking the path but I had the same results. The disk is a 120GB SATA SSD on /dev/sda. It works fine and GParted isn't having issues.
libparted-dev is on version 3.3-4ubuntu0.20.04.1. I'm on Ubuntu 20.04.3 LTS with Python 3.8.10.
Offending code (args.device is '/dev/sda'):
devs=parted.getAllDevices()
dev=Nonefordindevs:
print(f'Discovered {d.path}')
ifd.path==args.device:
dev=difdevisNone:
print(f'Could not find device {args.device}')
capacity=dev.getSize("GB")
ifcapacity>200:
ans=input(f'{dev.path} is a {capacity}GB drive, are you sure you have the right device? (y/n): ')
ifans.lower() !='y':
returnprint(f'Clearing partitions on {dev.path}')
dev.clobber()
# error is on this linedisk=parted.newDisk(dev)
Console Output:
Discovered /dev/sda
Discovered /dev/nvme0n1
Discovered /dev/nvme1n1
Clearing partitions on /dev/sda
Traceback (most recent call last):
File "provision.py", line 107, in <module>
main()
File "provision.py", line 58, in main
disk = parted.newDisk(dev)
File "/home/j/projects/analysis_python/hw-provision/env/lib/python3.8/site-packages/parted/decorators.py", line 42, in new
ret = fn(*args, **kwds)
File "/home/j/projects/analysis_python/hw-provision/env/lib/python3.8/site-packages/parted/__init__.py", line 485, in newDisk
peddisk = disk_new(device.getPedDevice())
_ped.DiskException: /dev/sda: unrecognised disk label
The text was updated successfully, but these errors were encountered:
Since you are using clobber() on the device, it is destroying the disk label. newDisk() can't work without a disk label. If you want to create a new Disk object with a specific lable, you need to use freshDisk:
dev.clobber()
disk = parted.freshDisk(dev, TYPE)
Where TYPE is a value from the parted.diskType dict. Such as parted.diskType["gpt"]:
disk = parted.freshDisk(dev, parted.diskType["gpt"])
Which will create a new Disk object for dev that has a GPT disk label.
I am trying to create a partition on /dev/sda, but for some reason pyparted is having issues. At first I was directly creating the device based on the path, but that gave the 'unrecognized disk label' error so I tried enumerating the disks and checking the path but I had the same results. The disk is a 120GB SATA SSD on /dev/sda. It works fine and GParted isn't having issues.
libparted-dev is on version 3.3-4ubuntu0.20.04.1. I'm on Ubuntu 20.04.3 LTS with Python 3.8.10.
Offending code (args.device is '/dev/sda'):
Console Output:
The text was updated successfully, but these errors were encountered: