nbd-bind: a tool to access disk images as block devices

This forums is for OS project announcements including project openings, new releases, update notices, test requests, and job openings (both paying and volunteer).
Post Reply
madanra
Member
Member
Posts: 149
Joined: Mon Sep 07, 2009 12:01 pm

nbd-bind: a tool to access disk images as block devices

Post by madanra »

One of the reasons I switched from Windows to Linux was to be able to use mount, and generally be able to deal with devices properly. For OS development, however, this still isn't enough; it doesn't let you mount eg. a VDI disk image from VirtualBox. I found that QEMU had a rather useful tool called qemu-nbd, which would let you bind a disk image to a block device, with all the partitions available as block devices as well, which is what I wanted. But qemu-nbd has to be run as root, and you can't be sure of the name of the block device in advance, which makes it tricky to use in a Makefile. So, a few months ago I wrote nbd-bind, a wrapper around qemu-nbd to solve these problems, and I've finally got round to releasing it.

The source is available on GitHub: https://github.com/mark-raymond/nbd-bind, and there's more info there about how it works, along with an example of how it can be used in a Makefile.

The general usage is like this:

Code: Select all

nbd-bind disk-image.vdi device-name
which will make disk-image.vdi available as a block device called device-name, and its partitions available as block devices called device-name-p1, device-name-p2 etc. Once you're finished, you just run:

Code: Select all

nbd-unbind device-name
I hope that this is of some use to the OSDev community, and any feedback - on the code, the (minimal) docs, or the general premise - would be appreciated!
Post Reply