首页 > 其他 > 详细

挂载qcow2

时间:2020-06-30 21:56:53      阅读:82      评论:0      收藏:0      [点我收藏+]

 

[root@localhost images]# ls
centos7.qcow2
[root@localhost images]# qemu-img convert  -f  qcow2  -O raw centos7.qcow2  centos7.raw
[root@localhost images]# ls
centos7.qcow2  centos7.raw
[root@localhost images]# losetup -f 
/dev/loop0
[root@localhost images]# losetup /dev/loop0  centos7.raw
[root@localhost images]# kpartx /dev/loop0
loop0p1 : 0 4774528 /dev/loop0 2048
[root@localhost images]# ls /dev/mapper/loop0p1
ls: cannot access /dev/mapper/loop0p1: No such file or directory
[root@localhost images]# kpartx -d  /dev/loop0
[root@localhost images]# kpartx -av   /dev/loop0
add map loop0p1 (253:0): 0 4774528 linear /dev/loop0 2048
[root@localhost images]# ls /dev/mapper/loop0p1
/dev/mapper/loop0p1
[root@localhost images]# mount  /dev/mapper/loop0p1 /mnt
[root@localhost images]# ls
centos7.qcow2  centos7.raw
[root@localhost images]# mount --bind /dev /mnt/dev
[root@localhost images]# chroot /mnt /bin/bash
[root@localhost /]# PATH=$PATH:/bin:/sbin:/usr/sbin:/usr/bin
[root@localhost /]# mount -t proc none /proc
[root@localhost /]# mount -t sysfs none /sys
[root@localhost /]# ls

 

 

 

install virt-manager   libguestfs-tools

 

[root@localhost images]# guestmount -a centos7.qcow2  -i --rw /mnt
libvirt: XML-RPC error : Failed to connect socket to /var/run/libvirt/libvirt-sock: No such file or directory
libguestfs: error: could not connect to libvirt (URI = qemu:///system): Failed to connect socket to ‘/var/run/libvirt/libvirt-sock‘: No such file or directory [code=38 int1=2]
[root@localhost images]# systemctl restart libvirt
Failed to restart libvirt.service: Unit not found.
[root@localhost images]#  systemctl restart  libvirtd 
[root@localhost images]# yum install libguestfs-tools

 

挂载qcow2

原文:https://www.cnblogs.com/dream397/p/13215786.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!