nbdkit now ported to Windows

This week I ported nbdkit, our high performance plugin-based Network Block Device server, to Windows. Currently it’s not upstream but you can download the Windows branch from here.

There were several possible ways we could have done this including Cygwin which might have been easier, but in the end I did a port to the raw Win32/Winsock APIs. You can compile it on Fedora using the mingw-w64-based Fedora Windows Cross Compiler and run it using Wine. Familiar commands like this work:

$ ./nbdkit.exe -f -v memory 1G

Windows is such a trash pile of awful APIs it’s a wonder how anyone can use it. Like what, and huh and WTF having to split a 64 bit int across two fields in a struct?? Not to mention the whole mess which is HANDLEs vs SOCKETs vs file descriptors and errno handling in Winsock. But I got there in the end.

I got many existing plugins and filters compiled. Not all of those listed will be working, but the main features are fine. You can also write your own plugins to the same API as Linux ones. I’m hoping that someone can write a Windows block device plugin (especially one which integrates with features like VSS).

$ find \( -name '*.exe' -o -name '*.dll' \) -a -printf "%f\n" | sort -u
nbdkit-blocksize-filter.dll
nbdkit-cacheextents-filter.dll
nbdkit-cow-filter.dll
nbdkit-data-plugin.dll
nbdkit-ddrescue-filter.dll
nbdkit-delay-filter.dll
nbdkit-error-filter.dll
nbdkit-example1-plugin.dll
nbdkit.exe
nbdkit-exitlast-filter.dll
nbdkit-extentlist-filter.dll
nbdkit-file-plugin.dll
nbdkit-fua-filter.dll
nbdkit-full-plugin.dll
nbdkit-gzip-filter.dll
nbdkit-gzip-plugin.dll
nbdkit-info-plugin.dll
nbdkit-ip-filter.dll
nbdkit-limit-filter.dll
nbdkit-memory-plugin.dll
nbdkit-nocache-filter.dll
nbdkit-noextents-filter.dll
nbdkit-nofilter-filter.dll
nbdkit-noparallel-filter.dll
nbdkit-nozero-filter.dll
nbdkit-null-plugin.dll
nbdkit-offset-filter.dll
nbdkit-partition-filter.dll
nbdkit-partitioning-plugin.dll
nbdkit-pattern-plugin.dll
nbdkit-random-plugin.dll
nbdkit-rate-filter.dll
nbdkit-readahead-filter.dll
nbdkit-retry-filter.dll
nbdkit-split-plugin.dll
nbdkit-stats-filter.dll
nbdkit-swab-filter.dll
nbdkit-tls-fallback-filter.dll
nbdkit-truncate-filter.dll
nbdkit-zero-plugin.dll

5 Comments

Filed under Uncategorized

5 responses to “nbdkit now ported to Windows

  1. Impressive. Having nbdkit running natively on Windows is great!
    I think using the CreateFile API allows you to get raw disk access, so making a block device plugin on windows shouldn’t be too hard. Maybe this can be one of my weekend projects.
    Another thing to note is that someone have made this https://github.com/billziss-gh/winspd . So making a NBD client from that should be doable.
    Having both of these pieces will open up some interesting use cases, especially for system administrators working with both Windows and Linux.

    • rich

      I ported the existing file plugin and it works (surprisingly actually), but it’s completely non-native and lacks many features which would be useful even for plain files, such as hole punching and fast zeroing. And I’m pretty certain it won’t work at all for Windows block devices. A fully native alternative would be very welcome.

      The tool you linked to looks interesting – a kind of Windows loop mount?

  2. James

    Good gosh, what motivated you to do something for Windoze? Or was it required from above?

    • rich

      It wasn’t mandated, but it fits with our mission to make proprietary sources of disk images visible to free software. In this case because there are a few specialised disks/devices with Windows-only drivers, and of course Windows itself has things like VSS and LDM that would be useful to expose natively.

  3. Pingback: nbdkit Windows port contd. | Richard WM Jones

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.