This project implements a Network Block Device (NBD) server in Rust, following the NBD protocol specification. NBD allows a client system to use a remote block device as if it were a local disk.
- Modern NBD protocol implementation (fixed newstyle negotiation)
- Support for multiple exports
- Configurable block sizes
- Export information handling including:
- Export name
- Description
- Block size constraints (minimum, preferred, maximum)
- Transmission flags
- Robust handshake protocol implementation
- Comprehensive logging
- Rust
- Cargo package manager
Clone the repository and build the project:
git clone [repository-url]
cd nbd
cargo build --releaseTo run the NBD server:
cargo run --bin nbd-server -- [options]Available options:
-f, --file <FILE>- Path to the file to export-p, --port <PORT>- Port to listen on (default: 10809)-H, --host <HOST>- Host address to bind to (default: 127.0.0.1)-n, --name <NAME>- Export name (default: "export")-d, --description <DESC>- Export description (default: "NBD Export")
The server supports the following NBD commands:
NBD_OPT_INFO- Request information about an exportNBD_OPT_GO- Request to use an exportNBD_OPT_LIST- List available exportsNBD_OPT_ABORT- Abort the negotiationNBD_OPT_EXPORT_NAME- Legacy command to request an export
NBD_CMD_READ- Read data from the exportNBD_CMD_WRITE- Write data to the exportNBD_CMD_DISC- Disconnect from the server
byteorder(1.5.0) - For handling endianness in network protocolclap(4.5.38) - For command-line argument parsinglog(0.4) - For logging functionalityenv_logger(0.10) - For environment-based logging configuration