Andy's Portable NBD Server July 13, 2004 adi@hexapodia.org This is a POSIX implementation of a server for the Linux Network Block Device (nbd). It has been tested on OpenBSD/x86 3.4 with a Linux/x86 2.4.25 client using nbd 2.7.1 from nbd.sourceforge.net. nbd-2.7.1 includes a client, but that client only compiles on Linux; this 'nbdsvr' is designed to run on any POSIX system supporting 'long long'. nbdsvr can be used to serve blocks from a regular file, in which case it can autodetect the length; or blocks from a block device, in which case the length must be specified on the command line. Usage: obsd% sudo disklabel wd1 ... i: 68372577 63 ext2fs # (Cyl. 0*- 67829) ... obsd% cd nbdsvr-0.1 obsd% make obsd% sudo ./nbdsvr [-d] 4444 /dev/wd1i $((68372577 * 512)) linux# nbd-client pirx 4444 /dev/nd0 linux# mount /dev/nd0 /mnt/tmp linux# ls /mnt/tmp ... linux# umount /mnt/tmp linux# nbd-client -d /dev/nd0 Pass multiple -d options to nbdsvr to get more verbose debugging output. TODO: 1. Test on a variety of client and server platforms (32be, 64le, 64be) 2. Use mmap(2) rather than lseek(2)/read(2)/write(2) for I/O 3. Use mincore(2) and I/O helper processes to do async I/O and service requests out of order 4. Statistics including average request latency, bandwidth, etc. BLUE SKY: 5. Extend nbd protocol for authentication, privacy, and data integrity (Possibly leverage IPSec for privacy and integrity) 6. Clients for non-Linux platforms