Skip to content

SalmaElsoly/nbd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NBD Server Implementation in Rust

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.

Features

  • 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

Prerequisites

  • Rust
  • Cargo package manager

Installation

Clone the repository and build the project:

git clone [repository-url]
cd nbd
cargo build --release

Usage

To 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")

Supported Commands

The server supports the following NBD commands:

Handshake Phase Commands

  • NBD_OPT_INFO - Request information about an export
  • NBD_OPT_GO - Request to use an export
  • NBD_OPT_LIST - List available exports
  • NBD_OPT_ABORT - Abort the negotiation
  • NBD_OPT_EXPORT_NAME - Legacy command to request an export

Transmission Phase Commands

  • NBD_CMD_READ - Read data from the export
  • NBD_CMD_WRITE - Write data to the export
  • NBD_CMD_DISC - Disconnect from the server

Dependencies

  • byteorder (1.5.0) - For handling endianness in network protocol
  • clap (4.5.38) - For command-line argument parsing
  • log (0.4) - For logging functionality
  • env_logger (0.10) - For environment-based logging configuration

References

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages