- Network block device
-
In Linux, a network block device is a device node whose content is provided by a remote machine. Typically, network block devices are used to access a storage device that does not physically reside in the local machine but on a remote one. As an example, the local machine can access a fixed disk that is attached to another computer.
Contents
Kernel client/userspace server
Technically, a network block device is realized by two components. In the client machine, where the device node is to work, a kernel module named
nbd
controls the device. Whenever a program tries to access the device, this kernel module forwards the request to the server machine, where the data physically resides.On the server machine, requests from the client are handled by a userspace program called
nbd-server
. This program is not implemented as a kernel module because all it has to do is to serve network requests, which in turn just requires regular access to the server filesystem.Example
If the file
/tmp/xxx
on ComputerA has to be made accessible on ComputerB, one performs the following steps:On ComputerA:
nbd-server 2000 /tmp/xxx
On ComputerB:
modprobe nbd nbd-client ComputerA 2000 /dev/nbd0
The file is now accessible on ComputerB as device
/dev/nbd0
. If the original file was for example a disk image, it could be mounted for example viamount /dev/nbd0 /mnt/whatever
.The command
modprobe nbd
is not necessary if module loading is done automatically. Once the module is in the kernel,nbd-client
is used to send commands to it, such as associating a given remote file to a given local nb device. To finish using/dev/nbd0
, that is, to destroy its association with the file on other computer, one can runnbd-client -d /dev/nbd0
on ComputerB.In this example, 2000 is the number of the server port through the file is made accessible. Any available port could be used.
Availability
The network block device client module is available on Linux and GNU Hurd.
Since the server is a userspace program, it can potentially run on every Unix-like platform. It is known to have been ported to Solaris [1].
See also
- Loop device: a similar mechanism, but uses a local file instead of a remote one
- DRBD: Distributed Replicated Block Device is a distributed storage system for the Linux platform
External links
- Network Block Device on Sourceforge
- The Network Block Device, the Linux Journal
- ggate in FreeBSD handbook, FreeBSD GEOM Gate presentation
- Enhanced Network Block Device
Categories:- Computer networking
- Computer storage technologies
- Linux kernel features
Wikimedia Foundation. 2010.