On Thu, Aug 19, 2010 at 3:04 PM, Richard Shaw <[email protected]> wrote:
> Ok, here's where I am with pyparted:
>
> # python
> Python 2.6.4 (r264:75706, Jun 4 2010, 18:20:31)
> [GCC 4.4.4 20100503 (Red Hat 4.4.4-2)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>>>> import parted
>>>> device = parted.Device("/root/disk_test.img")
>>>> disk = parted.freshDisk(device, 'msdos')
>>>>
>
> There's no reference to the "freshDisk" method that I could find the
> the parted module. I found it by downloading the source for anaconda
> and digging through the code.
>
> Now we have a disk image with a blank msdos partition table. Now we
> need to add the primary partition.
Right.
Well. We need to somehow get the maximum length a partition can be in the file.
If we do get this information, I suspect start, end here are sector
numbers.. we can do that rather easily. Note that in the file below,
sdb is being used.. not a file yet. It is just my local testing thing
which will add a partition properly. Unfortunately we need to make
start and end with the right
values. I've seen Gemetry.getMaxGeometry I think in the text you sent..
but after trying to get some geometry or a maximum start and end
sector a partition can be
I have still not been able to come up with the right function. The
code below will add a partition though.
#!/usr/bin/python
import os
import sys
import parted
device = parted.Device(path="/dev/sdb")
disk = parted.Disk(device=device)
start = 1
end =
new_geom = parted.Geometry(device=device,
start=start,
end=end)
partition = parted.Partition(disk=disk,
type=82,
geometry=new_geom)
constraint = parted.Constraint(exactGeom=new_geom)
disk.addPartition(partition=partition,
constraint=constraint)
disk.commit()
--
livecd mailing list
[email protected]
https://admin.fedoraproject.org/mailman/listinfo/livecd