{"id":21992963,"url":"https://github.com/bennyz/nbd","last_synced_at":"2025-03-23T03:42:12.858Z","repository":{"id":45351482,"uuid":"429165028","full_name":"bennyz/nbd","owner":"bennyz","description":"An attempt at an NBD server in Rust","archived":false,"fork":false,"pushed_at":"2022-10-04T14:15:50.000Z","size":82,"stargazers_count":0,"open_issues_count":7,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-28T10:18:50.366Z","etag":null,"topics":["hacktoberfest","nbd","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bennyz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-11-17T18:54:33.000Z","updated_at":"2021-12-27T17:53:05.000Z","dependencies_parsed_at":"2023-01-19T03:16:06.639Z","dependency_job_id":null,"html_url":"https://github.com/bennyz/nbd","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bennyz%2Fnbd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bennyz%2Fnbd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bennyz%2Fnbd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bennyz%2Fnbd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bennyz","download_url":"https://codeload.github.com/bennyz/nbd/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245052649,"owners_count":20553162,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hacktoberfest","nbd","rust"],"created_at":"2024-11-29T20:15:39.965Z","updated_at":"2025-03-23T03:42:12.835Z","avatar_url":"https://github.com/bennyz.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# nbd\n\nAn attempt at an NBD server in Rust.\n\nThe project is in its very early stages and is a bit of a mess.\nHowever, it is capable of doing things:\n\n## How to use?\n\n```shell\n# Clone the project\n$ git clone https://github.com/bennyz/nbd.git\n$ cd nbd/\n\n# Build it\n$ cargo build --release\n$ ./target/release/nbd --help\nnbd 0.0.1\n\nUSAGE:\n    nbd [OPTIONS] \u003cFILE\u003e [ARGS]\n\nARGS:\n    \u003cFILE\u003e           The file we want to export\n    \u003cNAME\u003e           The name of the export, empty by default [default: ]\n    \u003cDESCRIPTION\u003e    The description of the export, empty by default [default: ]\n\nOPTIONS:\n    -h, --help       Print help information\n        --unix       Whether to use a UNIX socket (additionally) along with the TCP socket by\n                     default uses /tmp/nbd.sock, in the future it will be configurable\n    -V, --version    Print version information\n```\n\n## Examples\n\nNote: These examples rely on third-party clients, like `qemu-img`, projects from `nbdkit` (`nbdinfo`) and `nbd-client`\n\n```shell\n$ qemu-img create -f raw export-file 1G\nFormatting 'export-file', fmt=raw size=1073741824 \n$ ./target/release/nbd export-file myexport exporty\nListening on port 10809\n```\n\nOn a separate shell:\n\n```shell\n$ qemu-img info nbd://localhost\nimage: nbd://localhost:10809\nfile format: raw\nvirtual size: 1 GiB (1073741824 bytes)\ndisk size: unavailable\n\n$ nbdinfo nbd://localhost\nprotocol: newstyle-fixed without TLS\nexport=\"myexport\":\n        description: exporty\n        export-size: 1073741824 (1G)\n        content: data\n        uri: nbd://localhost:10809/\n        is_rotational: false\n        is_read_only: false\n        can_cache: false\n        can_df: false\n        can_fast_zero: false\n        can_flush: false\n        can_fua: false\n        can_multi_conn: true\n        can_trim: false\n        can_zero: false\n        block_size_minimum: 1\n        block_size_preferred: 4096\n        block_size_maximum: 33554432\n```\n\nWe can even create a usable file system!\n\n```shell\n$ sudo modprobe nbd\n$ sudo nbd-client localhost 10809 /dev/nbd0\nWarning: the oldstyle protocol is no longer supported.\nThis method now uses the newstyle protocol with a default export\nNegotiation: ..size = 1024MB\nConnected /dev/nbd0\n\n# Now our export is available via /dev/nbd0\n# Let's create an XFS filesystem on it!\n$ sudo mkfs.xfs /dev/nbd0\nmeta-data=/dev/nbd0              isize=512    agcount=4, agsize=65536 blks\n         =                       sectsz=512   attr=2, projid32bit=1\n         =                       crc=1        finobt=1, sparse=1, rmapbt=0\n         =                       reflink=1    bigtime=0 inobtcount=0\ndata     =                       bsize=4096   blocks=262144, imaxpct=25\n         =                       sunit=0      swidth=0 blks\nnaming   =version 2              bsize=4096   ascii-ci=0, ftype=1\nlog      =internal log           bsize=4096   blocks=2560, version=2\n         =                       sectsz=512   sunit=0 blks, lazy-count=1\nrealtime =none                   extsz=4096   blocks=0, rtextents=0\n\n# We can then mount it and use it!\n$ sudo mount /dev/nbd0 mnt\n$ touch mnt/first_file\n\n# Close things up\n$ sudo umount /dev/nbd0\n$ sudo nbd-client -d /dev/nbd0\n\n# We can then reconnect\n$ sudo nbd-client localhost 10809 /dev/nbd0\nWarning: the oldstyle protocol is no longer supported.\nThis method now uses the newstyle protocol with a default export\nNegotiation: ..size = 1024MB\nConnected /dev/nbd0\n\n$ sudo mount /dev/nbd0 mnt\n# The file is there!\n$ ls mnt\nfirst_file\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbennyz%2Fnbd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbennyz%2Fnbd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbennyz%2Fnbd/lists"}