您可以使用 guestmount 命令来挂载 KVM 磁盘镜像并从中提取文件,以下是具体操作步骤: 安装 libguestfs 工具包: sudo apt-get install libguestfs-tools sudo yum install libguestfs-tools 使用 guestmount 命令挂载 KVM 磁盘镜像: sudo guestmount -a /path/to/kvm-image-file.qcow2 -m /dev/sda1 /mnt 在此命令中,/path/to/kvm-image-file.qcow2 是您要挂载的磁盘镜像文件的路径; /dev/sda1 是磁盘上想要挂载的分区设备名称,可以通过 fdisk -l kvm-image-file.qcow2 命令来查看。 /mnt 是用于挂载磁盘镜像内容的目录。 挂载成功后,您可以访问 /mnt 目录并将其中的数据复制到任何其他目录中: sudo cp -r /mnt/path/to/file /path/to/destination 在此命令中,/mnt/path/to/file 是在虚拟机磁盘镜像中的文件路径;/path/to/destination 是要将文件复制到的目标路径。 复制完成后,确保安全卸载磁盘镜像并卸载挂载目录: sudo umount /mnt 现在,您应该可以通过 /path/to/destination 目录中找到从 KVM 磁盘镜像提取出来的文件。