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

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/shendl/article/details/5798333

       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)

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

 


展开阅读全文

mount 不上

04-29

root@arago:/# mount /dev/mtdblock4 /mnt/aaa/rnmtdblock_openrnokrnmtdblock: read on "filesystem" at 0x0, size 0x200rnend_request: I/O error, dev mtdblock4, sector 0rnFAT: unable to read boot sectorrnmtdblock_releasernnand_sync: calledrnokrnmtdblock_openrnokrnmtdblock: read on "filesystem" at 0x400, size 0x200rnmtdblock: read on "filesystem" at 0x600, size 0x200rnmtdblock_releasernnand_sync: calledrnokrnmtdblock_openrnokrnmtdblock: read on "filesystem" at 0x400, size 0x200rnmtdblock: read on "filesystem" at 0x600, size 0x200rnmtdblock_releasernnand_sync: calledrnokrnmtdblock_openrnokrnmtdblock: read on "filesystem" at 0x400, size 0x200rnmtdblock: read on "filesystem" at 0x600, size 0x200rnmtdblock_releasernnand_sync: calledrnokrnmtdblock_openrnokrnmtdblock: read on "filesystem" at 0x400, size 0x200rnmtdblock: read on "filesystem" at 0x600, size 0x200rnmtdblock_releasernnand_sync: calledrnokrnmtdblock_openrnokrnmtdblock: read on "filesystem" at 0x0, size 0x200rnmtdblock: read on "filesystem" at 0x200, size 0x200rnmtdblock: read on "filesystem" at 0x400, size 0x200rnmtdblock: read on "filesystem" at 0x600, size 0x200rnmtdblock: read on "filesystem" at 0x800, size 0x200rnend_request: I/O error, dev mtdblock4, sector 0rnBuffer I/O error on device mtdblock4, logical block 0rnmtdblock: read on "filesystem" at 0x0, size 0x200rnend_request: I/O error, dev mtdblock4, sector 0rnBuffer I/O error on device mtdblock4, logical block 0rnmtdblock: read on "filesystem" at 0x1000, size 0x200rnend_request: I/O error, dev mtdblock4, sector 8rnBuffer I/O error on device mtdblock4, logical block 1rnmtdblock: read on "filesystem" at 0x1000, size 0x200rnmtdblock: read on "filesystem" at 0x1200, size 0x200rnmtdblock: read on "filesystem" at 0x1400, size 0x200rnmtdblock: read on "filesystem" at 0x1600, size 0x200rnmtdblock: read on "filesystem" at 0x1800, size 0x200rnend_request: I/O error, dev mtdblock4, sector 8rnBuffer I/O error on device mtdblock4, logical block 1rnmtdblock: read on "filesystem" at 0x2000, size 0x200rnend_request: I/O error, dev mtdblock4, sector 16rnBuffer I/O error on device mtdblock4, logical block 2rnmtdblock: read on "filesystem" at 0x2000, size 0x200rnmtdblock: read on "filesystem" at 0x2200, size 0x200rnmtdblock: read on "filesystem" at 0x2400, size 0x200rnmtdblock: read on "filesystem" at 0x2600, size 0x200rnmtdblock: read on "filesystem" at 0x2800, size 0x200rnend_request: I/O error, dev mtdblock4, sector 16rnBuffer I/O error on device mtdblock4, logical block 2rnmtdblock: read on "filesystem" at 0x3000, size 0x200rnend_request: I/O error, dev mtdblock4, sector 24rnBuffer I/O error on device mtdblock4, logical block 3rnmtdblock: read on "filesystem" at 0x3000, size 0x200rnmtdblock: read on "filesystem" at 0x3200, size 0x200rnmtdblock: read on "filesystem" at 0x3400, size 0x200rnmtdblock: read on "filesystem" at 0x3600, size 0x200rnmtdblock: read on "filesystem" at 0x3800, size 0x200rnend_request: I/O error, dev mtdblock4, sector 24rnBuffer I/O error on device mtdblock4, logical block 3rnmtdblock_releasernnand_sync: calledrnokrnmtdblock_openrnokrnmtdblock: read on "filesystem" at 0x0, size 0x200rnend_request: I/O error, dev mtdblock4, sector 0rnFAT: unable to read boot sectorrnmtdblock_releasernnand_sync: calledrnokrnmtdblock_openrnokrnmtdblock: read on "filesystem" at 0x0, size 0x200rnmtdblock_releasernnand_sync: calledrnokrnmtdblock_openrnokrnmtdblock_releasernnand_sync: calledrnokrnmount: mounting /dev/mtdblock4 on /mnt/aaa/ failed: Invalid argumentrnroot@arago:/# 论坛

没有更多推荐了,返回首页