Use qemu-NBD to mount a virtual hard disk to the host.

Source: Internet
Author: User

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!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.