arm-linux

http://armboard.taobao.com/

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

       qemu-nbd在有的系统上叫kvm-nbd,qemu-nbd-xen等。基本上都一样啦。

       用qemu-nbd实现mount虚拟硬盘到Host上的功能,需要这么做:

      rmmod nbd

      modprobe nbd max_part=8

     因为默认,nbd的增加分区的功能是关闭的,需要指定max_part这个参数。这个参数指定了一个nbd设备可以有多少个分区。

     qemu-nbd --connect=/dev/nbd0 ./testxp.img

     现在已经在localhost1024端口上安装上该设备了。

 

       ls /dev/ | grep nbd

nbd0

nbd0p1

上面这样显示就对了。因为我的那个虚拟磁盘只有一个分区。如果你的虚拟磁盘有多个分区,应该显示更多。

 

      fdisk -l /dev/nbd0   查看虚拟磁盘和分区状况:

Disk /dev/nbd0: 10.7 GB, 10737418240 bytes

255 heads, 63 sectors/track, 1305 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x6f106f10

Device Boot Start End Blocks Id System

/dev/nbd0p1 * 1 1304 10474348+ 7 HPFS/NTFS


     我们可以把/dev/nbd0p1这个ntfs格式的设备mount到我们的Host上。

 

       fdisk /dev/nbd0 可以进入交互式命令行。

Command (m for help): m

Command action

a toggle a bootable flag

b edit bsd disklabel

c toggle the dos compatibility flag

d delete a partition

l list known partition types

m print this menu

n add a new partition

o create a new empty DOS partition table

p print the partition table

q quit without saving changes

s create a new empty Sun disklabel

t change a partition's system id

u change display/entry units

v verify the partition table

w write table to disk and exit

x extra functionality (experts only)

       可以列出,增加,删除分区。

 

                                                                                        感谢同事Cooper告知的max_part参数。谢谢!

posted on 2010-08-09 11:15  arm-linux  阅读(2819)  评论(0编辑  收藏  举报