On Mon, Sep 29, 2014 at 11:15:59PM +0000, Marcos Amorim wrote:
Is there any way to change the partition type using python-guestfs?
I'm trying to recreate an NTFS partition, but can not change the
type to NTFS (7 identifier in frisk)
Filesystem from my disk
g.list_filesystems()
{'/dev/sda1': 'ntfs', '/dev/sda2': 'ntfs’}
Fdisk
print g.sfdisk_l(device)
Disk /dev/sda: 51200 cylinders, 64 heads, 32 sectors/track
Units = cylinders of 1048576 bytes, blocks of 1024 bytes, counting from 0
Device Boot Start End #cyls #blocks Id System
/dev/sda1 * 1 100 100 102400 7 HPFS/NTFS
/dev/sda2 101 51199 51099 52325376 83 Linux
/dev/sda3 0 - 0 0 0 Empty
/dev/sda4 0 - 0 0 0 Empty
If it's MBR, then you can use g.part_set_mbr_id ("/dev/sda", 2, 7)
For GPT use part_set_gpt_type which is similar but you have to use
a GUID.
Rich.
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
Read my programming and virtualization blog:
http://rwmj.wordpress.com
libguestfs lets you edit virtual machines. Supports shell scripting,
bindings from many languages.
http://libguestfs.org