Network Block Device - FAST drive-space sharing

I've recently rediscovered the benefits of NBD, the Network Block Device. Something I hadn't used in a decade. Wow, am I impressed! Also, OpenWrt's implementation is fantastic. A single config-file in /etc/config to set it up.

For those who haven't used it before, it's is a way for one device to share storage space to another device. The server takes any sort of local storage space: a whole drive, a partition, or even just a file and shares it. The remote device, when it connects, sees it as just another block device which it can do anything it wants with. You can partition it and format it as if it were a local block device.

The one major drawback is that more than one client can't use the same shared block device at one time. So it's really only good for sharing storage space from one device to one other device (at a time). But it has some major benefits too:

  1. It is blazingly fast - Linux's block-device cache makes it really efficient. With file sharing, the more smaller files you deal with, the more protocol overhead makes it less efficient. With NBD it doesn't really care.
  2. FULL support of all filesystem features (permissions, file attributes, file locking). Even NFS has limitations here.
  3. It's very kind on the server's CPU, which makes it great for OpenWrt devices to serve up.

If you implement, I recommend using a block size the same as the filesystem you will put on top of it. I used a 4k block size on the NBD device, the same as with ext4 I put on top of it.

1 Like

Thank you for sharing. Looks very useful.