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

Richard W.M. Jones rjones at redhat.com
Thu Mar 18 11:12:32 UTC 2021


On Thu, Mar 18, 2021 at 04:10:51PM +0800, 钱非凡 wrote:
> 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!

The error comes from sgdisk running on the guest, so it is a bug in
sgdisk or maybe a problem with the guest filesystem itself.

The closest I can find is this report from a few years ago:

https://listman.redhat.com/archives/libguestfs/2018-May/msg00009.html

What is the guest?  And what version of sgdisk are you using?

You could also try something like:

  $ virt-rescue --ro -d 138093b9b33345c38e58efa014036bd8

  ><rescue> sgdisk /dev/sdb -i 1

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-builder quickly builds VMs from scratch
http://libguestfs.org/virt-builder.1.html




More information about the Libguestfs mailing list