{"id":21540596,"url":"https://github.com/tchajed/rust-nbd","last_synced_at":"2025-04-10T03:33:47.014Z","repository":{"id":147768272,"uuid":"500965094","full_name":"tchajed/rust-nbd","owner":"tchajed","description":"Network Block Device (NBD) server and client written in Rust","archived":false,"fork":false,"pushed_at":"2024-03-18T16:02:57.000Z","size":182,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-03-19T17:07:56.280Z","etag":null,"topics":["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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tchajed.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,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2022-06-07T18:47:09.000Z","updated_at":"2024-03-03T08:22:21.000Z","dependencies_parsed_at":"2023-04-02T11:17:18.089Z","dependency_job_id":null,"html_url":"https://github.com/tchajed/rust-nbd","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tchajed%2Frust-nbd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tchajed%2Frust-nbd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tchajed%2Frust-nbd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tchajed%2Frust-nbd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tchajed","download_url":"https://codeload.github.com/tchajed/rust-nbd/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226123519,"owners_count":17577058,"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":["nbd","rust"],"created_at":"2024-11-24T04:19:31.373Z","updated_at":"2024-11-24T04:19:32.145Z","avatar_url":"https://github.com/tchajed.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rust-nbd\n\n[![CI](https://github.com/tchajed/rust-nbd/actions/workflows/build.yml/badge.svg)](https://github.com/tchajed/rust-nbd/actions/workflows/build.yml)\n\nImplementation of a basic Network Block Device (NBD) server and client written\nin Rust.  NBD is a Linux kernel feature that exports a block device over the\nnetwork, with commands for reading and writing blocks of the device by offset.\nThe kernel natively supports NBD, but you do need `sudo modprobe nbd` to\ninitialize the kernel module.\n\nThis code implements:\n- Rust modules that implement the client and server parts of the NBD protocol.\n- A userspace NBD server that is compatible with Linux.\n- A Rust re-implementation of the `nbd-client` utility (from the [standard userland tools](https://github.com/NetworkBlockDevice/nbd)). This avoids needing to install anything extra to use NBD.\n\nAll of the interactions with the kernel are very Linux-specific.\n\nmacOS does not provide an nbd kernel component, but it can run the server.\nThere is also a Rust library to interact with the server that would work if you\nwanted to use nbd from userspace.\n\nHere's a quick demo of running the server and connecting with the client:\n\n```\n$ cargo run --release -- --size 1000 disk.img \u0026\n$ sudo modprobe nbd\n$ cargo run --bin client -- /dev/nbd0\n```\n\nThe client automatically escalates to root with `sudo` in order to have the\nnecessary privilege to set up the block device.  Now we can interact with\n`/dev/nbd0` as with any other block device, for example with `dd` (more\ninterestingly, you can use `mkfs.ext` to create a file system there and then\n`mount` it):\n\n```\n$ sudo chown $USER /dev/nbd0\n$ dd if=/dev/zero of=/dev/nbd0 bs=4096\n```\n\nFinally, make sure to disconnect before running again:\n\n```\n$ cargo run --bin client -- --disconnect /dev/nbd0\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftchajed%2Frust-nbd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftchajed%2Frust-nbd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftchajed%2Frust-nbd/lists"}