[Fedora-livecd-list] List of previous issues with livecd-tools which should be addressed
Jasper Hartline
jasper.hartline at gmail.com
Fri Aug 20 06:15:29 UTC 2010
On Thu, Aug 19, 2010 at 3:20 PM, Jasper Hartline
<jasper.hartline at gmail.com> wrote:
> On Thu, Aug 19, 2010 at 3:04 PM, Richard Shaw <hobbes1069 at gmail.com> 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.
Well, this looks like it is going to do it:
[root at localhost tmp]# fdisk -l /dev/loop0
Disk /dev/loop0: 102 MB, 102400000 bytes
4 heads, 32 sectors/track, 1562 cylinders
Units = cylinders of 128 * 512 = 65536 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0000804e
Device Boot Start End Blocks Id System
/dev/loop0p1 1 1563 99999+ 83 Linux
[root at localhost tmp]#
Here is how I decide to get the number of sectors:
#!/usr/bin/python
import os
import sys
import parted
size = os.stat("/tmp/file").st_size
sectors = size / 512 - 1
device = parted.Device(path="/dev/loop0")
disk = parted.freshDisk(device, 'msdos')
start = 1
end = sectors
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()
I'll keep workking with this and update you with the latest, as soon
as I get more done.
More information about the livecd
mailing list