挂载raw和qcow2格式的KVM硬盘镜像

int32位 posted @ May 26, 2014 04:14:17 PM in linux , 6264 阅读
转载请注明:http://krystism.is-programmer.com/若有错误,请多多指正,谢谢!
from:http://lazyhack.net/mount-raw-and-qcow2-kvm-disk-images/
raw格式
对于未分区镜像文件直接使用loop:
mount -o loop image.img /mnt/image
已分区的镜像文件:
如果已知分区的起始位置
mount -o loop,offset=32256 image.img /mnt/image
或者使用losetup + kpartx
losetup /dev/loop0 image.img
kpartx -a /dev/loop0
mount /dev/mapper/loop0p1 /mnt/image
kpartx命令的作用,是让Linux内核读取一个设备上的分区表,然后生成代表相应分区的设备。
kpartx -l imagefile 可以查看一个映像文件中的分区,使用 kpartx -a imagefile 命令后,就可以通过 /dev/mapper/loop0pX (其中X是 分区号)来访问映像。
 
qcow2格式
对于qcow2格式需要使用qemu-nbd这个工具
modprobe nbd max_part=63
qemu-nbd -c /dev/nbd0 image.img
mount /dev/nbd0p1 /mnt/image
如果是LVM格式的镜像:
vgscan
vgchange -ay
mount /dev/VolGroupName/LogVolName /mnt/image
最后使用结束需释放资源:
umount /mnt/image
vgchange -an VolGroupName
killall qemu-nbd
kpartx -d /dev/loop0
losetup -d /dev/loop0
转载请注明:http://krystism.is-programmer.com/若有错误,请多多指正,谢谢!
  • 无匹配
  • 无匹配
AP SSC Maths Model P 说:
2022年9月11日 18:04

Mathematics is one of the tough subjects and also an easy subject for class 10th standard students of TM, EM, AP SSC Maths Model Paper UM and HM studying at government and private schools of the state. Department of School Education and teaching staff of various institutions have designed and suggested the Mathematics question paper with solutions for all chapters topic wide for each lesson of the course, and the AP SSC Maths Model Paper 2023 Pdf designed based on the new revised syllabus and curriculum.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter