Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

无nbd driver情况下有没有挂载qcow2的方法? #2

Open
guodong opened this issue Oct 23, 2014 · 3 comments
Open

无nbd driver情况下有没有挂载qcow2的方法? #2

guodong opened this issue Oct 23, 2014 · 3 comments

Comments

@guodong
Copy link

guodong commented Oct 23, 2014

您好,看了您的书很受启发,请问无nbd driver情况下有没有挂载qcow2的方法?我用的centos,centos 7 默认是不带nbd的。

@guodong guodong changed the title 无nbd driver情况下有没有挂在qcow2的方法? 无nbd driver情况下有没有挂载qcow2的方法? Oct 23, 2014
@JiYou
Copy link
Owner

JiYou commented Oct 24, 2014

额,我最新的才用到CentOS 6.5。估计需要在CentOS上找一下qemu-nbd驱动吧。没有试过CentOS上的情况。研究一下。如果你有什么新的进展,麻烦也给我说一下哦。Ubuntu到是很方便的样子。

@JiYou
Copy link
Owner

JiYou commented Oct 24, 2014

看了一下,大概找到方法如下:首先你需要安装如下包:
libguestfs

我的是CentOS 6.5:安装了
libguestfs-tools-c-1.20.11-2.el6.x86_64
libguestfs-1.20.11-2.el6.x86_64
python-libguestfs-1.20.11-2.el6.x86_64

安装好之后,

    guestfish -a centos63_desktop.qcow2 --ro <<_EOF_
    run
    list-filesystems
    _EOF_

比如下面有这个分区:

/dev/vg_centosbase/lv_root

可以查看img里面的分区情况:
接下来,便可以mount。
命令如下;

For example, to mount the root partition from our centos63_desktop.qcow2 image to /mnt, we can do:

guestmount -a centos63_desktop.qcow2 -m /dev/vg_centosbase/lv_root --rw /mnt

@guodong
Copy link
Author

guodong commented Oct 27, 2014

感谢您的回复,libguestfs的确是个不错的选择,我也在尝试,不过还没成功,我的虚拟机装的是windows,ntfs文件系统,用libguestfs挂载会报错

[root@localhost ~]# guestfish -a /var/lib/libvirt/images/win8.1.qcow2 -i
libguestfs: trace: set_verbose true
libguestfs: trace: set_verbose = 0
libguestfs: create: flags = 0, handle = 0x7fb67a560d40, program = guestfish
libguestfs: trace: set_pgroup true
libguestfs: trace: set_pgroup = 0
libguestfs: trace: add_drive "/var/lib/libvirt/images/win8.1.qcow2"
libguestfs: trace: add_drive = 0
libguestfs: trace: is_config
libguestfs: trace: is_config = 1
libguestfs: trace: launch
libguestfs: trace: get_tmpdir
libguestfs: trace: get_tmpdir = "/mnt"
libguestfs: trace: get_backend
libguestfs: trace: get_backend = "libvirt"
libguestfs: launch: backend=libvirt
libguestfs: launch: tmpdir=/mnt/libguestfsFEVfFH
libguestfs: launch: umask=0022
libguestfs: launch: euid=0
libguestfs: libvirt version = 1001001 (1.1.1)
libguestfs: [00000ms] connect to libvirt
libguestfs: opening libvirt handle: URI = NULL, auth = virConnectAuthPtrDefault, flags = 0
libguestfs: successfully opened libvirt handle: conn = 0x7fb67a5623a0
libguestfs: [00009ms] get libvirt capabilities
libguestfs: [00018ms] parsing capabilities XML
libguestfs: [00019ms] build appliance
libguestfs: command: run: supermin-helper
libguestfs: command: run: \ --verbose
libguestfs: command: run: \ -f checksum
libguestfs: command: run: \ /usr/lib64/guestfs/supermin.d
libguestfs: command: run: \ x86_64
supermin helper [00000ms] whitelist = (not specified), host_cpu = x86_64, kernel = (null), initrd = (null), appliance = (null)
supermin helper [00000ms] inputs[0] = /usr/lib64/guestfs/supermin.d
checking modpath /lib/modules/3.10.0-123.el7.x86_64 is a directory
checking modpath /lib/modules/3.10.0-123.8.1.el7.x86_64 is a directory
picked vmlinuz-3.10.0-123.el7.x86_64
supermin helper [00000ms] finished creating kernel
supermin helper [00000ms] visiting /usr/lib64/guestfs/supermin.d
supermin helper [00001ms] visiting /usr/lib64/guestfs/supermin.d/base.img.gz
supermin helper [00001ms] visiting /usr/lib64/guestfs/supermin.d/daemon.img.gz
supermin helper [00001ms] visiting /usr/lib64/guestfs/supermin.d/hostfiles
supermin helper [00036ms] visiting /usr/lib64/guestfs/supermin.d/init.img
supermin helper [00036ms] visiting /usr/lib64/guestfs/supermin.d/ntfs.hostfiles
supermin helper [00036ms] visiting /usr/lib64/guestfs/supermin.d/ntfs.img
supermin helper [00036ms] visiting /usr/lib64/guestfs/supermin.d/udev-rules.img
supermin helper [00036ms] adding kernel modules
supermin helper [00065ms] finished creating appliance
libguestfs: checksum of existing appliance: f1e42ac7dbc482bca1bd582f9ac8725ba3e064454b30b68f032e7998118a8c3c
libguestfs: trace: get_cachedir
libguestfs: trace: get_cachedir = "/mnt"
libguestfs: trace: get_cachedir
libguestfs: trace: get_cachedir = "/mnt"
libguestfs: [00091ms] begin building supermin appliance
libguestfs: [00091ms] run supermin-helper
libguestfs: command: run: supermin-helper
libguestfs: command: run: \ --verbose
libguestfs: command: run: \ --copy-kernel
libguestfs: command: run: \ -f ext2
libguestfs: command: run: \ /usr/lib64/guestfs/supermin.d
libguestfs: command: run: \ x86_64
libguestfs: command: run: \ /mnt/guestfs.hr5Q9G/kernel
libguestfs: command: run: \ /mnt/guestfs.hr5Q9G/initrd
libguestfs: command: run: \ /mnt/guestfs.hr5Q9G/root
supermin helper [00000ms] whitelist = (not specified), host_cpu = x86_64, kernel = /mnt/guestfs.hr5Q9G/kernel, initrd = /mnt/guestfs.hr5Q9G/initrd, appliance = /mnt/guestfs.hr5Q9G/root
supermin helper [00000ms] inputs[0] = /usr/lib64/guestfs/supermin.d
checking modpath /lib/modules/3.10.0-123.el7.x86_64 is a directory
checking modpath /lib/modules/3.10.0-123.8.1.el7.x86_64 is a directory
picked vmlinuz-3.10.0-123.el7.x86_64
supermin helper [00008ms] finished creating kernel
supermin helper [01123ms] finished mke2fs
supermin helper [01125ms] visiting /usr/lib64/guestfs/supermin.d
supermin helper [01125ms] visiting /usr/lib64/guestfs/supermin.d/base.img.gz
supermin helper [04521ms] visiting /usr/lib64/guestfs/supermin.d/daemon.img.gz
supermin helper [04541ms] visiting /usr/lib64/guestfs/supermin.d/hostfiles
supermin helper [09935ms] visiting /usr/lib64/guestfs/supermin.d/init.img
supermin helper [09937ms] visiting /usr/lib64/guestfs/supermin.d/ntfs.hostfiles
supermin helper [09946ms] visiting /usr/lib64/guestfs/supermin.d/ntfs.img
supermin-helper: ext2fs_read_inode: Illegal inode number
libguestfs: error: supermin-helper exited with error status 1, see debug messages above
libguestfs: command: run: rm
libguestfs: command: run: \ -rf /mnt/guestfs.hr5Q9G
libguestfs: trace: launch = -1 (error)
libguestfs: trace: close
libguestfs: closing guestfs handle 0x7fb67a560d40 (state 0)
libguestfs: command: run: rm
libguestfs: command: run: \ -rf /mnt/libguestfsFEVfFH

看样子是倒数第10行supermin-helper: ext2fs_read_inode: Illegal inode number的报错信息导致supermin-helper出错,不知道您有没有这样的问题?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants