Show HN: go-nbd – A Pure Go NBD Server and Client (github.com)
Hey HN! I just released go-nbd, a lightweight Go library for effortlessly creating NBD servers and clients. Its a neat tool for creating custom Linux block devices with arbitrary backends, such as a file, byte slice or what I'm planning to use it for, a tape drive. While there are a few partially abandoned projects like this out there already, this library tries to be as maintainable as possible by only implementing the most recent handshake revision and baseline functionality for both the client and the server, while still having enough support to be useful.
I'd love to get your feedback :)
45 comments
[ 2.2 ms ] story [ 1246 ms ] threadbeyond likely being simpler to understand/manage, i mean.
It's possibly more idiomatically Linux. But the Linux iSCSI initiator might (last I checked?) do a better job of utilizing the kernel block multiqueue interface than nbd, and thus might get higher I/O performance.
nbd is extremely simple to set up; iSCSI less so.
NBD is much more narrowly focused. It exposes a single block device to the kernel, with a minimal set of commands focused on that use case (e.g. read, write, trim, prefetch, etc). It doesn't do as many things as iSCSI, but that's probably for the better.
I had heard of it, but I had to read "NBD" far too many times in that repo before I saw what it stood for.
[0] https://github.com/panjf2000/gnet
I used it for a tcp connection (json-rpc) workload and it was far better and the code was cleaner.
Defering overhead is very small nowdays.
Edit: Oh I just saw the addition to your comment - that is exactly what I was thinking of ^^
> This release improves the performance of most uses of defer to incur almost zero overhead compared to calling the deferred function directly. As a result, defer can now be used in performance-critical code without overhead concerns.
EDIT: https://github.com/golang/go/issues/14939 I believe is the main tracking bug for this.
https://github.com/pepaslabs/nbdkit-baddisk-plugin
https://github.com/pepaslabs/nbdkit-badsector-plugin
[0] https://dev.to/rkeene/raid5-lost-raid5-recovered-3kld
[1] https://www.rkeene.org/projects/info/resources/diatribes/blo...
I'm not sure what you mean regarding how I wrote it, it's a single C file I wrote on my workstation that I had attached the enclosure to in JBOD mode so I could read every disk directly.
The system managing the physical block devices never sees unencrypted data.
Such a setup shines when you use a laptop as your main machine and wish to have a lot of secure storage. The approach I chose was to bond ethernet & wifi6e, use wireguard (w/ PSK). And wonder the house with uninterrupted access.
Could you elaborate on your NBD setup? (What do you use for the server?) And what kind of latencies do you see when you're at home / not at home? How do you handle backups? (Do you back up the encrypted blob server-side or do you back up the unencrypted data client-side, at the cost of having to deal with (probably) limited bandwidth & latencies.)
I do backups with borg while connected to the NAS with ethernet.
> While at home things are fine, when not at home things can get bad
What does "bad" mean exactly? Unrecoverable errors / faulty writes? It might be an irrational gut feeling on my part but for some reason operating a block device over a network makes me feel uneasy. How easy is it to mess up one's data?
Imagine you had a physical drive which had unreliable reads and writes but that would always go through eventually. In that scenario I believe you would just have abysmal latency as the OS keeps retrying - and if the latency between retries was in milliseconds the actual speed would drop next to 0.
That said, sudden unrecoverable loss of connectivity would be equivalent of yanking out a physical drive. You would want to use a journaling filesystem.
0. https://github.com/rvalles/pyamigadebug/blob/master/NBDServe...