If you are using the mainline nbd-client, the C reference implementation might not work. Also, it is really inconvenient to modify nbd-client arguments during development. Here is a simple shell script replacement I use at work I'd like to share with you.
# start the web server
cd path/to/jsnbd
path/to/websocketd/websocketd --port=8000 --staticdir=web --binary socat - UNIX-LISTEN:/tmp/nbd.sock &
# at this point, visit http://server-ip:8000 and connect the remote file
# connecting to the NBD server
nbd-client -unix /tmp/nbd.sock /dev/nbd0 -persist -readonly -timeout 30
# disconnecting from the NBD server
nbd-client -d /dev/nbd0
# stop the web server
kill %1
rm -f /tmp/nbd.sock
If you are using the mainline
nbd-client
, the C reference implementation might not work. Also, it is really inconvenient to modifynbd-client
arguments during development. Here is a simple shell script replacement I use at work I'd like to share with you.Dependencies:
socat
(most distro have a package for it)The script:
Tested with
nbd-client
3.21.