{"id":28766275,"url":"https://github.com/popovicu/g2disk","last_synced_at":"2026-04-15T15:35:52.522Z","repository":{"id":297824322,"uuid":"994005558","full_name":"popovicu/g2disk","owner":"popovicu","description":"Go monorepo for a framework to build Linux block devices in userspace","archived":false,"fork":false,"pushed_at":"2025-06-07T17:43:03.000Z","size":48,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-17T12:02:55.247Z","etag":null,"topics":["block-dev","go","golang","grpc","grpc-go","linux","nbdkit","userspace"],"latest_commit_sha":null,"homepage":"https://popovicu.com/g2disk/","language":"Starlark","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/popovicu.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,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-01T01:40:39.000Z","updated_at":"2025-06-12T08:12:18.000Z","dependencies_parsed_at":"2025-06-07T18:37:25.526Z","dependency_job_id":null,"html_url":"https://github.com/popovicu/g2disk","commit_stats":null,"previous_names":["popovicu/g2disk"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/popovicu/g2disk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/popovicu%2Fg2disk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/popovicu%2Fg2disk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/popovicu%2Fg2disk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/popovicu%2Fg2disk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/popovicu","download_url":"https://codeload.github.com/popovicu/g2disk/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/popovicu%2Fg2disk/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267191047,"owners_count":24050318,"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","status":"online","status_checked_at":"2025-07-26T02:00:08.937Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["block-dev","go","golang","grpc","grpc-go","linux","nbdkit","userspace"],"created_at":"2025-06-17T12:00:37.793Z","updated_at":"2026-04-15T15:35:47.492Z","avatar_url":"https://github.com/popovicu.png","language":"Starlark","funding_links":[],"categories":[],"sub_categories":[],"readme":"# g2disk\n\n**g2disk (Go Giant Disk)** is a framework for enabling potentially giant block devices (disks) in userspace for Linux, via [Linux NBD](https://docs.kernel.org/admin-guide/blockdev/nbd.html).\n\n\u003e :warning: This project is not ready for any sort of production use at this point.\n\u003e Use with caution for any non-experimental setting and please file requests for any features you'd like to see for production use.\n\u003e At the moment, consider this codebase a proof of concept only.\n\nThe concept is the following:\n1) Build on top of the [nbdkit](https://libguestfs.org/nbdkit.1.html) plugin framework in Go (via `cgo`)\n2) Define a gRPC protocol (perhaps other protocols are to follow, e.g. REST) that enables the plugin to proxy the disk requests to a gRPC (or other) service via network to another server which doesn't necessarily need to know about the Linux NBD protocol. The benefit of this is that the target server can be implemented in more modern server frameworks without needing to do anything difficult to wire in with the NBD set up.\n3) Implement the aforementioned target server.\n4) Build the `g2disk` plugin `.so` file from this repo and start `nbdkit` with it.\n5) Connect your Linux `nbd-client` to the `nbdkit` instance from the previous step, and that instance can proxy over to your target gRPC server.\n\nAt the moment, there is only a reference implementation for a gRPC-based plugin proxy and the corresponding Go \"ramdisk\" server. Please feel free to contribute new implementations and file requests for other implementations.\n\nAs mentioned above, the current implementation available is just a proof of concept and doesn't even run gRPC over TLS. If there is any interest in using this project where this would actually matter, please file a feature request.\n\n# Docs\n\nThis file only contains the instructions for the quickest way to get started. For detailed documentation, head over to [the docs index](/docs/index.md).\n\n# How to use\n\nThe intended build tool for this repository is `bazel`.\n\n## Building the `nbdkit` plugin\n\nSimply run:\n\n```\nbazel build //pkg/nbdkit/grpc:g2disk\n```\n\n\u003e :warning: If you're facing linker issues, consider using the `linkopt` flag like below, for example.\n\u003e If you customize the linking with `linkopt`, you may want to use your flag for all the builds as your Bazel cache otherwise gets discarded.\n\n```\nbazel build --linkopt=-fuse-ld=gold //pkg/nbdkit/grpc:g2disk\n```\n\nThe build should produce a file `libg2disk.so`.\n\n## Running the reference ramdisk server\n\nThis repo only provides a reference 5 MB ramdisk server, based on gRPC. To start this server, run the following:\n\n```\nbazel run //cmd/server/grpc/ramdisk:ramdisk_server\n```\n\nYou'll see something like:\n\n```\n2025/06/07 08:50:49 INFO Listening on a TCP target target=0.0.0.0:8080\n2025/06/07 08:50:49 INFO Starting the API sever target=0.0.0.0:8080\n```\n\n## Using the `nbdkit` plugin\n\n`nbdkit` needs to be used in the foreground (`-f`) mode because the Go plugin is used. Something like this should work:\n\n```\nsudo nbdkit -f -U /tmp/g2disk.sock bazel-bin/pkg/nbdkit/grpc/g2disk_/libg2disk.so endpoint=localhost:8080\n```\n\nThat runs `nbdkit` server instance that listens on a Unix socket. Alternatively, the server can listen on a TCP socket if set up that way.\n\nThe `.so` file parameter is the newly built plugin that will proxy NBD requests over to the endpoint defined at the end of the line.\n\nYou should now see output like this:\n\n```\n2025/06/01 16:57:38 INFO Configuration complete\n2025/06/01 16:57:38 INFO Creating a gRPC client\n```\n\n## Creating an NBD drive\n\nNext, you use `nbd-client` to wire things in the kernel.\n\n```\nsudo nbd-client -unix /tmp/g2disk.sock /dev/nbd1\n```\n\nThe output should be something like:\n\n```\nWarning: the oldstyle protocol is no longer supported.\nThis method now uses the newstyle protocol with a default export\nNegotiation: ..size = 5MB\nConnected /dev/nbd1\n```\n\nYou can use other `/dev/ndb*` devices, of course.\n\n## Using the NBD device\n\nYou can then proceed to use your NBD device just like any other block device.\n\n```\nsudo mkfs.ext4 /dev/nbd1\n```\n\nThat will format the device and you're ready to mount it:\n\n```\nsudo mount /dev/nbd1 /mnt/disk\n```\n\nFrom that point on, your `/mnt/disk` directory is a regular `ext4` mountpoint.\n\n## Stopping the NBD device\n\nAfter you're done with the filesystem, unmount the filesystem and stop the device with something like this:\n\n```\nsudo nbd-client -d /dev/nbd1\n```\n\nYou can then also `Ctrl-C` the main `nbdkit` server process.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpopovicu%2Fg2disk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpopovicu%2Fg2disk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpopovicu%2Fg2disk/lists"}