Thanks for replying, rich.

here are some informations i gathered. the guest is linux (centos) and i find 
out the guest's file system is 'xfs' using `df -hT`:


```
$ df -hT
Filesystem              Type    
  Size  Used Avail Use% Mounted on
/dev/mapper/centos-root xfs       8.0G  1003M  
7.1G   13% /
devtmpfs                devtmpfs  
484M     0  484M    0% /dev
tmpfs                  
 tmpfs     496M     0  496M  
  0% /dev/shm
tmpfs                  
 tmpfs     496M  6.8M  489M    2% /run
tmpfs                  
 tmpfs     496M     0  496M  
  0% /sys/fs/cgroup
/dev/vda1               xfs  
    1014M  132M  883M   14% /boot
tmpfs                  
 tmpfs     100M     0  100M  
  0% /run/user/0
```


and sgdisk version is 0.8.10:


```
$ sgdisk --version
GPT fdisk (sgdisk) version 0.8.10

```


also, i tried the command you gave. it came out the same output:


```
$ virt-rescue --ro -d 138093b9b33345c38e58efa014036bd8
&gt;<rescue&gt; sgdisk /dev/sdb -i 1
Invalid partition data!

```


but strange things happened when i tried some other reports' suggestions:


https://listman.redhat.com/archives/libguestfs/2016-February/msg00145.html
https://listman.redhat.com/archives/libguestfs/2018-November/msg00026.html



i did these things:


1. set LIBGUESTFS_BACKEND to direct;
2. recompile the `libguestfs-1.40.2-10.el7.src.rpm` without the 
`XXXX-RHEL-7-Reject-use-of-libguestfs-winsupport-features-.patch `;
3. run the `virt-rescue` command again.


```
$ virt-rescue --ro -d 138093b9b33345c38e58efa014036bd8
&gt;<rescue&gt; sgdisk /dev/sdb -i 1
Creating new GPT entries.
Partition #1 does not exist.

```


and the command works somehow. apparently, i still dont understand what 
happened indeed. and i have read about the official explanation of 
LIBGUESTFS_BACKEND, is this something to do with libvirt? is it a bug or 
something?


https://libguestfs.org/libguestfs-test-tool.1.html#trying-out-with-without-libvirt




------------------&nbsp;Original&nbsp;------------------
From: &nbsp;"Richard W.M. Jones";<[email protected]&gt;;
Send time:&nbsp;Thursday, Mar 18, 2021 7:12 PM
To:&nbsp;"??????"<[email protected]&gt;; 
Cc:&nbsp;"libguestfs"<[email protected]&gt;; 
Subject: &nbsp;Re: [Libguestfs] error invalid partition data while using 
libguestfs-tools




On Thu, Mar 18, 2021 at 04:10:51PM +0800, ?????? wrote:
&gt; I'm trying to upload a file to guest os by using libguestfs api. but a
&gt; partition error occurs during the `virt-copy-in` command. it seems its some
&gt; problems with the `sgdisk` command, but i have no idea how to fix this. is 
this
&gt; some problems with the host os or the guest os? or maybe is the version of
&gt; libguestfs? btw, my host os is centos 7.6 with libguestfs 1.40.
&gt; 
&gt; ```
&gt; $ virt-copy-in -d 138093b9b33345c38e58efa014036bd8 1.txt /root/
&gt; libguestfs: error: inspect_os: sgdisk: Invalid partition data!
&gt; $ cat /etc/redhat-release
&gt; CentOS Linux release 7.6.1810 (Core)
&gt; $ yum list installed | grep libguestfs
&gt; 
libguestfs.x86_64&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 
1:1.40.2-10.el7&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 @base
&gt; ...
&gt; ```
&gt; 
&gt; and after turning on LIBGUESTFS_DEBUG and LIBGUESTFS_TRACE flag, i found 
out
&gt; the error was happening which calling `guestfs_inspect_os()` function. but 
i
&gt; still dont know how to fix this. here are part of the output:
&gt; 
&gt; ```
&gt; ...
&gt; calling: settle
&gt; commandrvf: stdout=n stderr=y flags=0x0
&gt; commandrvf: udevadm --debug settle
&gt; calling: settle
&gt; command: sfdisk '--print-id' '/dev/sdb' '1'
&gt; [&nbsp;&nbsp;&nbsp; 2.400992]&nbsp; sdb: sdb1 sdb2
&gt; command: sfdisk returned 0
&gt; command: sfdisk: stdout:
&gt; 0
&gt; commandrvf: stdout=n stderr=y flags=0x0
&gt; commandrvf: udevadm --debug settle
&gt; calling: settle
&gt; commandrvf: stdout=n stderr=y flags=0x0
&gt; commandrvf: udevadm --debug settle
&gt; calling: settle
&gt; command: fold-stdout-on-stderr sgdisk '/dev/sdb' '-i' '1'
&gt; [&nbsp;&nbsp;&nbsp; 2.427088]&nbsp; sdb: sdb1 sdb2
&gt; command: sgdisk returned 2
&gt; command: sgdisk: stderr:
&gt; 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?&nbsp; And what version of sgdisk are you using?

You could also try something like:

&nbsp; $ virt-rescue --ro -d 138093b9b33345c38e58efa014036bd8

&nbsp; &gt;<rescue&gt; 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
_______________________________________________
Libguestfs mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/libguestfs

Reply via email to