Network Block Device (TCP version)
What is it: With this compiled into your kernel, Linux can use a remote server as one of its block devices. Every time the client computer wants to read
/dev/nbd0, it will send a request to the server via TCP, which will reply with the data requested. This can be used for stations with low disk space (or even diskless - if you use an
initrd) to borrow disk space from other computers. Unlike NFS, it is possible to put any file system on it. But (also unlike NFS), if someone has mounted NBD read/write, you must assure that no one else will have it mounted.
Current state: It currently works. Network block device is pretty stable. It was originally thought that it is impossible to swap over TCP; this turned out not to be true. However, to avoid deadlocks, you will need at least Linux 3.6.
It is possible to use NBD as the block device counterpart of FUSE, to implement the block device's reads and writes in user space. To make this easer, recent versions of NBD (3.10 and above) implement NBD over a Unix Domain Socket, too.
If you're interested in the technical side of how NBD works, please see the protocol documentation.
Comments and help about the tools is always appreciated; if you're willing to help out, please subscribe to the mailing-list, and share your thoughts.
- Github repository
- In September 2006, Linux Magazine featured an article about network block devices (not just NBD, but other implementations as well). This is available for download from their website.
- Another writeup was done by that other Linux Magazine in October 2008. It's available straight from their website.
NBD on other platforms
Besides Linux, the authors have knowledge of NBD client support on the following platforms:
- The Hurd: an nbd translator was written by Rolan McGrath on September 28th, 2001
- Plan 9: Christoph Lohmann informed us on June 1st, 2006, that it can mount NBD exports with some extra code
- BSD-like systems: On SourceForge, the project nvd intends to implement NBD for BSD systems. They're not ready yet, however.
The server should theoretically work on every POSIX-compliant platform out there (provided glib is supported on that platform). If it doesn't, that's a bug and I want to know about it; if you encounter such problems, please send a mail to the mailinglist.