<meta http-equiv="Content-Type" content="text/html; charset=GB18030"><div>Thanks for replying, rich.</div><div><br></div><div>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`:</div><div><br></div><div>```</div><div>$ df -hT</div><div>Filesystem              Type      Size  Used Avail Use% Mounted on</div><div>/dev/mapper/centos-root xfs       8.0G  1003M  7.1G   13% /</div><div>devtmpfs                devtmpfs  484M     0  484M    0% /dev</div><div>tmpfs                   tmpfs     496M     0  496M    0% /dev/shm</div><div>tmpfs                   tmpfs     496M  6.8M  489M    2% /run</div><div>tmpfs                   tmpfs     496M     0  496M    0% /sys/fs/cgroup</div><div>/dev/vda1               xfs      1014M  132M  883M   14% /boot</div><div>tmpfs                   tmpfs     100M     0  100M    0% /run/user/0</div><div>```</div><div><br></div><div>and sgdisk version is 0.8.10:</div><div><br></div><div>```</div><div><div>$ sgdisk --version</div><div>GPT fdisk (sgdisk) version 0.8.10</div></div><div>```</div><div><br></div><div>also, i tried the command you gave. it came out the same output:</div><div><br></div><div>```</div><div>$ virt-rescue --ro -d 138093b9b33345c38e58efa014036bd8</div><div><div>><rescue> sgdisk /dev/sdb -i 1</div><div>Invalid partition data!</div></div><div>```</div><div><br></div><div><div>but strange things happened when i tried some other reports' suggestions:</div><div><br></div><div>https://listman.redhat.com/archives/libguestfs/2016-February/msg00145.html</div><div>https://listman.redhat.com/archives/libguestfs/2018-November/msg00026.html</div></div><div><br></div><div>i did these things:</div><div><br></div><div>1. set LIBGUESTFS_BACKEND to direct;</div><div>2. recompile the `libguestfs-1.40.2-10.el7.src.rpm` without the `<span style="white-space: pre-wrap;">XXXX-RHEL-7-Reject-use-of-libguestfs-winsupport-features-.patch </span>`;</div><div>3. run the `virt-rescue` command again.</div><div><br></div><div>```</div><div>$ virt-rescue --ro -d 138093b9b33345c38e58efa014036bd8</div><div><div>><rescue> sgdisk /dev/sdb -i 1</div><div>Creating new GPT entries.</div><div>Partition #1 does not exist.</div></div><div>```</div><div><br></div><div>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?</div><div><br></div><div>https://libguestfs.org/libguestfs-test-tool.1.html#trying-out-with-without-libvirt</div><div><br></div><div><br></div><div><div style="font-size: 12px;font-family: Arial Narrow;padding:2px 0 2px 0;">------------------ Original ------------------</div><div style="font-size: 12px;background:#efefef;padding:8px;"><div><b>From: </b> "Richard W.M. Jones";<rjones@redhat.com>;</div><div><b>Send time:</b> Thursday, Mar 18, 2021 7:12 PM</div><div><b>To:</b> "Ç®·Ç·²"<b3ale693592@foxmail.com>; <wbr></div><div><b>Cc:</b> "libguestfs"<libguestfs@redhat.com>; <wbr></div><div><b>Subject: </b> Re: [Libguestfs] error invalid partition data while using libguestfs-tools</div></div><div><br></div><br>On Thu, Mar 18, 2021 at 04:10:51PM +0800, Ç®·Ç·² wrote:<br>> I'm trying to upload a file to guest os by using libguestfs api. but a<br>> partition error occurs during the `virt-copy-in` command. it seems its some<br>> problems with the `sgdisk` command, but i have no idea how to fix this. is this<br>> some problems with the host os or the guest os? or maybe is the version of<br>> libguestfs? btw, my host os is centos 7.6 with libguestfs 1.40.<br>> <br>> ```<br>> $ virt-copy-in -d 138093b9b33345c38e58efa014036bd8 1.txt /root/<br>> libguestfs: error: inspect_os: sgdisk: Invalid partition data!<br>> $ cat /etc/redhat-release<br>> CentOS Linux release 7.6.1810 (Core)<br>> $ yum list installed | grep libguestfs<br>> libguestfs.x86_64                     1:1.40.2-10.el7            @base<br>> ...<br>> ```<br>> <br>> and after turning on LIBGUESTFS_DEBUG and LIBGUESTFS_TRACE flag, i found out<br>> the error was happening which calling `guestfs_inspect_os()` function. but i<br>> still dont know how to fix this. here are part of the output:<br>> <br>> ```<br>> ...<br>> calling: settle<br>> commandrvf: stdout=n stderr=y flags=0x0<br>> commandrvf: udevadm --debug settle<br>> calling: settle<br>> command: sfdisk '--print-id' '/dev/sdb' '1'<br>> [    2.400992]  sdb: sdb1 sdb2<br>> command: sfdisk returned 0<br>> command: sfdisk: stdout:<br>> 0<br>> commandrvf: stdout=n stderr=y flags=0x0<br>> commandrvf: udevadm --debug settle<br>> calling: settle<br>> commandrvf: stdout=n stderr=y flags=0x0<br>> commandrvf: udevadm --debug settle<br>> calling: settle<br>> command: fold-stdout-on-stderr sgdisk '/dev/sdb' '-i' '1'<br>> [    2.427088]  sdb: sdb1 sdb2<br>> command: sgdisk returned 2<br>> command: sgdisk: stderr:<br>> Invalid partition data!<br><br>The error comes from sgdisk running on the guest, so it is a bug in<br>sgdisk or maybe a problem with the guest filesystem itself.<br><br>The closest I can find is this report from a few years ago:<br><br>https://listman.redhat.com/archives/libguestfs/2018-May/msg00009.html<br><br>What is the guest?  And what version of sgdisk are you using?<br><br>You could also try something like:<br><br>  $ virt-rescue --ro -d 138093b9b33345c38e58efa014036bd8<br><br>  ><rescue> sgdisk /dev/sdb -i 1<br><br>Rich.<br><br>-- <br>Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones<br>Read my programming and virtualization blog: http://rwmj.wordpress.com<br>virt-builder quickly builds VMs from scratch<br>http://libguestfs.org/virt-builder.1.html<br><br></div>