I found myself in need of a SMB share as appearing to be a local, directly-attached disk recently. After stumbling around a few Reddit posts talking about setting up a "storage pool" in FlexRAID, I found Dokany.
It's essentially a file system in user space (FUSE) application for Windows. I installed the non-debug, redistributable latest version (1.0.5
of this writing) on Windows 10.
After installing, there is a command shell wrapper, mirror.exe
, for ad-hoc playing around with the Dokany libraries. Pulling up its -h
elp we see:
> cd "C:\Program Files\Dokan\Dokan Library-1.0.5\sample\"
> mirror.exe -h
mirror.exe
/r RootDirectory (ex. /r c:\test) Directory source to mirror.
/l MountPoint (ex. /l m) Mount point. Can be M:\ (drive letter) or empty NTFS folder C:\mount\dokan .
/t ThreadCount (ex. /t 5) Number of threads to be used internally by Dokan library.
More threads will handle more event at the same time.
/d (enable debug output) Enable debug output to an attached debugger.
/s (use stderr for output) Enable debug output to stderr.
/n (use network drive) Show device as network device.
/m (use removable drive) Show device as removable media.
/w (write-protect drive) Read only filesystem.
/o (use mount manager) Register device to Windows mount manager.
This enables advanced Windows features like recycle bin and more...
/c (mount for current session only) Device only visible for current user session.
/u (UNC provider name ex. \localhost\myfs) UNC name used for network volume.
/a Allocation unit size (ex. /a 512) Allocation Unit Size of the volume. This will behave on the disk file size.
/k Sector size (ex. /k 512) Sector Size of the volume. This will behave on the disk file size.
/f User mode Lock Enable Lockfile/Unlockfile operations. Otherwise Dokan will take care of it.
/i (Timeout in Milliseconds ex. /i 30000) Timeout until a running operation is aborted and the device is unmounted.
Examples:
mirror.exe /r C:\Users /l M: # Mirror C:\Users as RootDirectory into a drive of letter M:\.
mirror.exe /r C:\Users /l C:\mount\dokan # Mirror C:\Users as RootDirectory into NTFS folder C:\mount\dokan.
mirror.exe /r C:\Users /l M: /n /u \myfs\myfs1 # Mirror C:\Users as RootDirectory into a network drive M:\. with UNC \\myfs\myfs1
Unmount the drive with CTRL + C in the console or alternatively via "dokanctl /u MountPoint".
Which results in a command along the lines of:
> mirror.exe /r \\servername\share /l N /s /d /w
If your SMB share requires authentication, manually connect to
\\servername\share
first and tell Windows to save the credentials.
mirror.exe
- Wrapper around Dokany libraries/r \\servername\share
- Specifies the source or where existing data lives- (My example uses a SMB share but this could have been another directory on C: or even another drive like D:)
/l N
- "Mounts" the existing data as theN
drive- (Can be any of
N
,N:
, orN:\
)
- (Can be any of
/s /d
- Prints debug information to stdout (the Command Prompt)/w
- I don't want my Windows 10 machine to write to this network share, so it's "mounted" as read-only
/s /d
tends to cause a lot of output in the Command Prompt, so I only use them to visually inspect the processes debug information.
Also, this is something that I run manually. I'll have to edit this post when I decide how I want to automate this command at boot, as well as enforcing it to be running for the duration of the Windows machine running.