On Fri, Aug 20, 2010 at 6:05 AM, Jasper Hartline
<jasper.hartline(a)gmail.com> wrote:
On Thu, Aug 19, 2010 at 11:15 PM, Jasper Hartline
<jasper.hartline(a)gmail.com> wrote:
> On Thu, Aug 19, 2010 at 3:20 PM, Jasper Hartline
> I'll keep workking with this and update you with the latest, as soon
> as I get more done.
>
Well. I have failed to decrypt the FileSystem class for pyparted.
It seems you create a format object
and then pass that to Partition, like this.. below
however, upon looking at the loop device and using hexdump, and dumpe2fs
and trying to mount it, etc. It seems it is corrupt or is not a valid
filesystem.
So I'm not sure what is going on.
Also, to get the size we can just use size divided by 512.
That gives us the maximum number of sectors minus 1 for the MBR.
#!/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 = 2
end = sectors
new_geom = parted.Geometry(device=device,
start=start,
end=end)
format = parted.FileSystem(type="ext2", geometry=new_geom).create()
partition = parted.Partition(disk=disk,
fs=format,
type=82,
geometry=new_geom)
constraint = parted.Constraint(exactGeom=new_geom)
disk.addPartition(partition=partition,
constraint=constraint)
disk.commit()
So here attached is what I have so far, it is what I would like to
continue to work on and
fox the format routing when we figure out how to use pyparted properly.
So far I have it setting up correctly and the master boot record is proper.
/dev/loop0 on /tmp/tmprjsmh3 type ext3 (rw)
/dev/loop1 on /tmp/tmpKTCs75 type iso9660 (rw)
/dev/loop2 on /tmp/tmpLi76ER type iso9660 (rw)
[root@localhost tmp]# ls -l /tmp/tmprjsmh3
total 28
drwx------ 2 root root 16384 Aug 20 03:54 lost+found
drwxr-xr-x 2 root root 4096 Aug 20 03:54 syslinux
drwxr-xr-x 2 root root 4096 Aug 20 03:54 x64
drwxr-xr-x 2 root root 4096 Aug 20 03:54 x86
[root@localhost tmp]#
I'll keep banging away at it. I'm digging through the pyparted source.
Richard