找回密码
 注册
搜索
热搜: 回贴
微赢网络技术论坛 门户 服务器 Linux/BSD 查看内容

Mounting KVM qcow2 qemu disk images

2009-12-20 13:38| 发布者: admin| 查看: 40| 评论: 0|原作者: 江月



qcow2 images are not flat files, see
qemu-img(1)
. KVM ships with qemu-nbd, which lets you use the NBD protocol to share the disk image on the network.
First, for partition nbd partition support you need to be running kernel 2.6.26 (
commit
,
changelog
) or greater. For ubuntu users, that means it’s time to upgrade to intrepid ibex. Load the nbd module with:
sudo modprobe nbd max_part=8
If you leave off the max_part attribute, partitions are not
supported and you’ll be able to access the disk, but not have device
nodes for any of the partitions. Running
sudo qemu-nbd root.qcow2
will bind to all interfaces (0.0.0.0) and share the disk on the
default port (1024). It’s important to note that the nbd kernel module
produces /dev/nbd0 while the nbd-client man page recommends /dev/nb0 in
it’s examples. The error message isn’t so clear, see
lp:290076
.
# nbd-client localhost 1024 /dev/nb0
Error: Can not open NBD: No such file or directory
This can all be reduced in steps using the ‘–connect’ option of qemu-nbd, like this:
sudo qemu-nbd --connect=/dev/nbd0 root.qcow2
At which point you can view the disk partitions:
sudo fdisk /dev/nbd0
or mount a disk, such as
mount /dev/nbd0p1 /mnt








最新评论

QQ|小黑屋|最新主题|手机版|微赢网络技术论坛 ( 苏ICP备08020429号 )

GMT+8, 2024-9-30 13:19 , Processed in 0.217069 second(s), 12 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

返回顶部