e42.uk Circle Device

 

Quick Reference

Manual NBD Server Connectivity

Manual NBD Server Connectivity

NBD or Network Block Device is an efficient way of sharing a block device over a network... the example here is a completely insecure way of doing things. Please take additional care if you want to use this mechanism over an untrusted network or the internet.

Server Setup

Assuming that you have a client on 192.168.80.25 that you want to permit access to /dev/sda1. The config file /etc/nbd-server/config:

[generic]
    user = root
    group = root
    allowlist = true
[export1]
    exportname = /dev/sda1
    timeout = 30

Also, because allowlist is true a file must be provided containing the ip addresses that are allowed to connect to this server, /etc/nbd-server/allow:

192.168.80.25

Execute the server:

nbd-server --nodeamon --dont-fork

Client Setup

The default port for nbd is 10809, that can be identified with ss -lntp, to connect /dev/nbd0 to the server on 192.168.80.20:

modprobe nbd
nbd-client -N export1 192.168.80.20 10809 /dev/nbd0
Negotiation: ..size = 1024MB
Connected /dev/nbd0

Now the device may be mounted or partprobed (if it has a partition table) or even mapped using device mapper. /dev/nbd0 can be used as a local block device would be used.

Quick Links: Techie Stuff | General | Personal | Quick Reference