用qemu-nbd实现mount虚拟硬盘到Host上的功能

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

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

      rmmod nbd

      modprobenbd 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

255heads, 63 sectors/track, 1305 cylinders

Units= cylinders of 16065 * 512 = 8225280 bytes

Sectorsize (logical/physical): 512 bytes / 512 bytes

I/Osize (minimum/optimal): 512 bytes / 512 bytes

Diskidentifier: 0x6f106f10

DeviceBoot 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

Commandaction

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)

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


转自:http://blog.csdn.net/shendl/article/details/5798333

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值