问题描述
该笔记将记录:如何挂载和访问 qcow2 镜像文件,以及相关问题的解决办法。
解决方案
第一步、安装工具
yum install libguestfs-tools libguestfs
第二步、挂载镜像
guestmount -a "/path/to/image.qcow2" -i --ro "/mnt"
其他方法
nbd
How to mount a qcow2 disk image · GitHub
第一步、加载内核模块:
# Step 1 - Enable NBD on the Host modprobe nbd max_part=8
第二步、挂载 qcow2 文件:
# Step 2 - Connect the QCOW2 as network block device qemu-nbd --connect=/dev/nbd0 /var/lib/vz/images/100/vm-100-disk-1.qcow2 # Step 3 - Find The Virtual Machine Partitions fdisk /dev/nbd0 -l # Step 4 - Mount the partition from the VM mount /dev/nbd0p1 /mnt/
第三步、卸载 qcow2 文件:
# Step 5 - After you done, unmount and disconnect umount /mnt/somepoint/ qemu-nbd --disconnect /dev/nbd0 rmmod nbd
参考文献