In some systems, qemu-NBD is called KVM-NBD and qemu-NBD-xen. It's basically the same.
Use qemu-NBD to mount the virtual hard disk to the host. You need to do this:
Rmmod
NBD
Modprobe
NBD max_part = 8
By default, the function of adding partitions to NBD is disabled. You need to specify the max_part parameter. This parameter specifies how many partitions an NBD device can have.
Qemu-NBD
-- Connect =/dev/nbd0./testxp. img
Now you have installed the device on port 1024 of localhost.
Ls
/Dev/| grep NBD
Nbd0
Nbd0p1
As shown above, it is correct. Because my virtual disk has only one partition. If your virtual disk has multiple partitions, more should be displayed.
Fdisk
-L/dev/nbd0: view the status of the Virtual Disk and partition:
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: 0x6f0000f10
Device
Boot start end blocks ID system
/Dev/nbd0p1
* 1 1304 10474348 + 7 HPFs/NTFS
We can mount the/dev/nbd0p1 NTFS-format device to our host.
Fdisk
/Dev/nbd0 can enter interactive command lines.
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)
You can list, add, and delete partitions.
I would like to thank my colleague Cooper for the max_part parameter. Thank you!