WinBtrfs - an open-source btrfs driver for Windows
WinBtrfs is a Windows driver for the next-generation Linux filesystem Btrfs. A reimplementation from scratch, it contains no code from the Linux kernel, and should work on any version from Windows XP onwards. It is also included as part of the free operating system ReactOS.
If your Btrfs filesystem is on a MD software RAID device created by Linux, you will also need WinMD to get this to appear under Windows.
See also Quibble, an experimental bootloader allowing Windows to boot from Btrfs, and Ntfs2btrfs, a tool which allows in-place conversion of NTFS filesystems.
First, a disclaimer:
You use this software at your own risk. I take no responsibility for any damage it may do to your filesystem. It ought to be suitable for day-to-day use, but make sure you take backups anyway.
Everything here is released under the GNU Lesser General Public Licence (LGPL); see the file LICENCE for more info. You are encouraged to play about with the source code as you will, and I'd appreciate a note ([email protected]) if you come up with anything nifty.
See at the end of this document for copyright details of third-party code that's included here.
mkbtrfs.exe and ubtrfs.dllfree_space_cache)To install the driver, download and extract the latest release, right-click btrfs.inf, and choose Install. The driver is signed, so should work out of the box on modern versions of Windows.
If you using Windows 10 or 11 and have Secure Boot enabled, you may have to make a Registry change in order for the driver to be loaded - see below. It's easier though just to turn off Secure Boot in your BIOS, unless you have a particular need for it. Bear in mind that Windows 11 soft-requires Secure Boot to be installed, but will work fine afterwords with it turned off.
WinBtrfs is also available on the following package managers:
choco install winbtrfsscoop bucket add nonportable
scoop install winbtrfs-np -gIf you want to uninstall, from an elevated command prompt first run:
pnputil /enum-drivers
There should be two entries for btrfs.inf and btrfs-vol.inf, with files of
the form oemNN.inf. Make a note of their names.
Then for each run...
pnputil /delete-driver oemNN.inf /uninstall /force...and reboot.
If you need to uninstall via the registry, open regedit and set the value of HKLM\SYSTEM\CurrentControlSet\services\btrfs\Start to 4, to disable the service. After you reboot, you can then delete the btrfs key and remove C:\Windows\System32\drivers\btrfs.sys.
To compile with Visual C++ 2019, open the directory and let CMake do its thing. If you have the Windows DDK installed correctly, it should just work.
To compile with GCC on Linux, you will need a cross-compiler set up, for either
i686-w64-mingw32 or x86_64-w64-mingw32. Create a build directory, then use
either mingw-x86.cmake or mingw-amd64.cmake as CMake toolchain files to
generate your Makefile.
The user mappings are stored in the registry key HKLM\SYSTEM\CurrentControlSet\services\btrfs\Mappings. Create a DWORD with the name of your Windows SID (e.g. S-1-5-21-1379886684-2432464051-424789967-1001), and the value of your Linux uid (e.g. 1000). It will take effect next time the driver is loaded.
You can find your current SID by running whoami /user.
Similarly, the group mappings are stored in under GroupMappings. You can find
your group SIDs by running whoami /groups. The default entry maps Windows'
Users group to gid 100, which is usually "users" on Linux.
You can also specify user SIDs here to force files created by a user to belong to a certain group. The setgid flag also works as on Linux.
Note that processes running under User Access Control tokens create files as the BUILTIN\Administrators SID (S-1-5-32-544), rather as a user account.
The driver will passthrough Linux metadata to recent versions of LXSS, but you
will have to let Windows know that you wish to do this. From a Bash prompt on
Windows, edit /etc/wsl.conf to look like the following:
[automount]
enabled = true
options = "metadata"
mountFsTab = falseIt will then take effect next time you reboot. Yes, you should be able to chroot into an actual Linux installation, if you wish.
The DLL file shellbtrfs.dll provides the GUI interface, but it can also be used with rundll32.exe to carry out some tasks from the command line, which may be useful if you wish to schedule something to run periodically.
Bear in mind that rundll32 provides no mechanism to return any error codes, so any of these commands may fail silently.
rundll32.exe shellbtrfs.dll,CreateSubvol <path>
rundll32.exe shellbtrfs.dll,CreateSnapshot <source> <destination>
rundll32.exe shellbtrfs.dll,ReflinkCopy <source> <destination>
This also accepts wildcards, and any number of source files.
The following commands need various privileges, and so must be run as Administrator to work:
rundll32.exe shellbtrfs.dll,SendSubvol <source> [-p <parent>] [-c <clone subvol>] <stream file>
The -p and -c flags are as btrfs send on Linux. You can specify any number of
clone subvolumes.
rundll32.exe shellbtrfs.dll,RecvSubvol <stream file> <destination>
rundll32.exe shellbtrfs.dll,StartScrub <drive>
rundll32.exe shellbtrfs.dll,StopScrub <drive>
On the releases page, there's zip files to download containing the PDBs. Or you can try the symbols server http://symbols.burntcomma.com/ - in windbg, set your symbol path to something like this:
symsrv*symsrv.dll*C:\symbols*http://msdl.microsoft.com/download/symbols;symsrv*symsrv.dll*C:\symbols*http://symbols.burntcomma.com
The driver assumes that all filenames are encoded in UTF-8. This should be the default on most setups nowadays - if you're not using UTF-8, it's probably worth looking into converting your files.
For the later versions of Windows 10, Microsoft introduced more onerous requirements for signing, which seemingly aren't available for open-source drivers.
To work around this, go to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\CI\Policy in Regedit,
create a new DWORD value called UpgradedSystem and set to 1, and reboot.
Or you could always just turn off Secure Boot in your BIOS settings.
This is something Microsoft hardcoded into LXSS, presumably to stop people hosing
their systems by running mkdir /mnt/c/WiNdOwS.
With the shell extension installed, right-click the drive in Explorer, click Properties, and go to the Btrfs tab. There should be a button which allows you to change the drive letter.
In Regedit, try deleting the relevant entries in HKEY_LOCAL_MACHINE\SYSTEM\MountedDevices,
then rebooting.
Use the included command line program mkbtrfs.exe. We can't add Btrfs to Windows' own
dialog box, unfortunately, as its list of filesystems has been hardcoded. You can also
run format /fs:btrfs, if you don't need to set any Btrfs-specific options.
If Windows' Format dialog box refuses to appear, try running format.com with the /fs
flag, e.g. format /fs:ntfs D:.
Synology seems to use LVM for its block devices. Until somebody writes an LVM driver for Windows, you're out of luck.
Thecus uses Linux's MD raid for its block devices. You will need to install WinMD as well.
Make sure that you have KB3033929 installed. Or consider installing from an "escrow" ISO which includes all updates.
Paragon's filesystem-reading software is known to disable automount. Disable or
uninstall Paragon, then re-enable automount by running diskpart and typing
automount enable.
On very old versions of Windows (XP, Server 2003?), Windows ignores Linux partitions
entirely. If this is the case for you, try running fdisk on Linux and changing your
partition type from 83 to 7.
There's no mapping between Windows and POSIX permission models, they're too different for this to be practical. If this bothers you, you can create a Windows ACL on files that you don't want to be able to edit.
No, sorry, you can't. We use a fake block device so that RAID works properly, and diskmgmt doesn't know anything about this. Your volume should appear in Explorer, and you can use the property sheet to change the drive letter if you wish.
ARM seems to be funny in that requires you to be in test mode to install the
driver, but not to use it otherwise. From an elevated command prompt, run
bcdedit /set testsigning on and reboot, then try again. You can turn test
mode off again afterwards: bcdedit /set testsigning off.
Recent versions of MSVC have dropped support for userspace programs on Windows XP - only the driver itself works. You might have some success with compiling shellbtrfs.dll yourself with mingw.
Recent versions of Windows 11 have added a driver whitelist, but o
Explorer Freezes when modifying files owned by linux
Performance - NTFS vs WinBtrfs
Regression; drive on a removable usb device does not mount
Constant Freezes
Kernel pool buffer overflow when setting extended attributes (uint16 size wraparound)
Deadlock: flush_thread vs Cc write-behind on sustained heavy writes (v1.10, #345 family still present)
The correct way to run upgrade the driver (and to switch between the debug and release builds)
v1.10 goes into BSOD on file removal, writing, even on idling: `SYSTEM_THREAD_EXCEPTION_NOT_HANDLED`
Support for deduplication
send: WRITE offsets wrong for extents with nonzero extent offset (silent corruption on receive); OOB reads; unchecked buffer growth; uint16 path wraparound