Chinaunix首页 | 论坛 | 博客
  • 博客访问: 300529
  • 博文数量: 108
  • 博客积分: 4260
  • 博客等级: 上校
  • 技术积分: 1145
  • 用 户 组: 普通用户
  • 注册时间: 2008-02-21 13:22
文章分类

全部博文(108)

文章存档

2011年(40)

2010年(22)

2009年(17)

2008年(29)

我的朋友

分类: LINUX

2008-11-25 15:48:25

qcow2 images are not flat files, see . KVM ships with kvm-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 (, ) 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 kvm-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 .

# 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 kvm-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

unmount a disk, such as

kvm-nbd --disconnect /dev/nbd0

阅读(942) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~