[Libguestfs] error invalid partition data while using libguestfs-tools

钱非凡 b3ale693592 at foxmail.com
Thu Mar 18 08:10:51 UTC 2021


I'm trying to upload a file to guest os by using libguestfs api. but a partition error occurs during the `virt-copy-in` command. it seems its some problems with the `sgdisk` command, but i have no idea how to fix this. is this some problems with the host os or the guest os? or maybe is the version of libguestfs? btw, my host os is centos 7.6 with libguestfs 1.40.


```
$ virt-copy-in -d 138093b9b33345c38e58efa014036bd8 1.txt /root/
libguestfs: error: inspect_os: sgdisk: Invalid partition data!

$ cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)

$ yum list installed | grep libguestfs
libguestfs.x86_64                     1:1.40.2-10.el7            @base
...
```


and after turning on LIBGUESTFS_DEBUG and LIBGUESTFS_TRACE flag, i found out the error was happening which calling `guestfs_inspect_os()` function. but i still dont know how to fix this. here are part of the output:


```
...
calling: settle
commandrvf: stdout=n stderr=y flags=0x0
commandrvf: udevadm --debug settle
calling: settle
command: sfdisk '--print-id' '/dev/sdb' '1'
[    2.400992]  sdb: sdb1 sdb2
command: sfdisk returned 0
command: sfdisk: stdout:
0
commandrvf: stdout=n stderr=y flags=0x0
commandrvf: udevadm --debug settle
calling: settle
commandrvf: stdout=n stderr=y flags=0x0
commandrvf: udevadm --debug settle
calling: settle
command: fold-stdout-on-stderr sgdisk '/dev/sdb' '-i' '1'
[    2.427088]  sdb: sdb1 sdb2
command: sgdisk returned 2
command: sgdisk: stderr:
Invalid partition data!
ocaml_exn: 'inspect_os' raised 'Failure' exception
guestfsd: error: sgdisk: Invalid partition data!
guestfsd: => inspect_os (0x1e0) took 0.41 secs
libguestfs: trace: inspect_os = NULL (error)
libguestfs: error: inspect_os: sgdisk: Invalid partition data!

...
```
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/libguestfs/attachments/20210318/c1e51383/attachment.htm>


More information about the Libguestfs mailing list