centos 7 kvm 尝试挂载 qcow2 映像时出错

centos 7 kvm 尝试挂载 qcow2 映像时出错

我有一台 CentOS 7 KVM 主机。其中一台虚拟机上的分区似乎已损坏。图像是 qcow2。当尝试安装图像进行故障排除时,我收到以下错误:

[root@vmhost02 images]# guestmount -a cpanel-vm.qcow2 -m /dev/sbcd /mnt/temp
libguestfs: error: vfs_type: vfs_type_stub: /dev/sbcd: No such file or directory
libguestfs: error: mount_options: mount_options_stub: /dev/sbcd: No such file or directory
guestmount: '/dev/sbcd' could not be mounted.
guestmount: Did you mean to mount one of these filesystems?
guestmount:     /dev/sda1 (xfs)
guestmount:     /dev/centos/home (xfs)
guestmount:     /dev/centos/root (xfs)
guestmount:     /dev/centos/swap (swap)

[root@vmhost02 images]# guestmount -a cpanel-vm.qcow2 -m /dev/centos/root /mnt/temp
libguestfs: error: mount_options: /dev/centos/root on / (options: ''): mount: mount /dev/mapper/centos-root on /sysroot failed: Structure needs cleaning
guestmount: '/dev/centos/root' could not be mounted.

我不确定如何修复这个问题,因为据我所知我只能使用 guestmount 来访问分区,但失败了?

答案1

我想知道该设备是否/dev/sbcd不正确。您可以尝试guestfish首先使用来启动虚拟机。guestfish然后您可以从中列出可用的文件系统。

例如,假设我有一个名为disk

$ guestfish --rw -a disk
Welcome to guestfish, the guest filesystem shell for
editing virtual machine filesystems and disk images.
Type: 'help' for help on commands
      'man' to read the manual
      'quit' to quit the shell
><fs> run
 100% ⟦▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒⟧ 00:00

然后您可以像这样列出文件系统,甚至尝试挂载它们:

><fs> list-filesystems
/dev/sda1: xfs
><fs> mount /dev/sda1 /

安装后您就可以查看了,这里我正在查看文件/etc/shadow

><fs> edit /etc/shadow
...
root:$6$2c908VsVmGs.TSdO$eiSIj7k1vqMAQaW1ipKYxWhNFXYIaXHN1XbQ00oi8ZeDcR4QNo2aN4pCpmU8tP8KjwyXeyng5q3sAxT/XQO8n.:16259:0:99999:7:::
bin:*:16231:0:99999:7:::
daemon:*:16231:0:99999:7:::
adm:*:16231:0:99999:7:::
lp:*:16231:0:99999:7:::
sync:*:16231:0:99999:7:::
shutdown:*:16231:0:99999:7:::
halt:*:16231:0:99999:7:::
...

当你完成后退出:

><fs> edit /etc/shadow
><fs> quit
$

相关内容