Mount to a UNC path without a drive letter

When mounting using --network-mode, a drive letter.is required, even when a UNC path is specified.

For example, rclone mount box: \\rclone\box will still mount it as drive Z:, and the files in it are not accessible via the UNC path \\rclone\box.

It's possible to avoid mounting to drive letters when not using --network-mode. But File Explorer tends to analyze the content type before opening a new folder on a local drive, which could hang Explorer when I'm opening a folder full of picture/video files in a drive mounted without --network-mode.

WinFsp comes with a sample in-memory file system, with a UNC path \\memfs64\share that can actually be accessed by other programs. It should be mapped to a network drive before use to avoid "bad network path" error, but you can also just use net use \\memfs64\share to activate it without assigning a drive letter.

Then I found the WinFsp documentation about WinFsp Service Architecture.

I tried to manually register rclone.exe as a service controlled by WinFsp Launcher, by creating a registry key as follows:

[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\WinFsp\Services\rclone]
"Executable"="path-to-rclone\\rclone.exe"
"CommandLine"="mount box: %2 --network-mode --config path-to-config-file\\rclone.conf --fuse-flag --VolumePrefix=%1"
"Security"="D:P(A;;RPWPLC;;;WD)"
"JobControl"=dword:00000001

Then, when I try to map \\rclone\box as a network drive or use net use \\rclone\box, rclone will be launched as local system (so the --config path is necessary). %1 will be replaced by the UNC path "\rclone\box" but with single backslash. %2 will be replaced by the specified drive letter, or an empty string "" if no letter is specified. After that, I can finally access mapped files via the UNC path \\rclone\box.

In fact, now every UNC paths starting with \\rclone\ will be redirected to the rclone instance. The "server" part must be the registry key name (rclone), but the "share" part can be anything. As for now, different "shares" on \\rclone\ maps to the same box: remote.

There's still a problem, though. Providing an empty string as the mount point still makes rclone assign a free drive letter automatically. An option to prevent assigning drive letters when mount point is an empty string and a UNC path is provided would be appreciated.

Hi, welcome to the forum.

WinFsp.Launcher integration has been discussed a bit in the past, but not picked up or investigated in detail by a developer yet as far as I know.

The following is related, in case you haven't found it: Feature Request: Support for WinFsp Launcher · Issue #3340 · rclone/rclone · GitHub. If I understand it correctly, that FR describes a more generic approach to "net use" any remote, while you manually configure a specific remote in the launcher registry settings.

Do you mean that your setup works well for your case, but you just want to avoid the unnecessary assigning to a drive letter, or have I misunderstood?

hello and welcome to the forum, great first post.

if you want:
--- prevent assigning drive letters
--- UNC path is provided would be appreciated

then i think this does that

rclone mount remote: b:\rclone\mount\remote --no-console

net share share=b:\rclone\mount
share was shared successfully.

dir \\localhost\share\remote
Directory of \\localhost\share\remote
01/01/2023  12:35 PM    <DIR>          zork
               0 File(s)              0 bytes

My main purpose is to mount remotes in network mode without assigning drive letters, yet still have some way to access the mounted remotes.

Mounting to a local path first and then creating a network share surely is a possible workaround. Thanks.

However, as for now, rclone does not support mounting (creating the file system) without a mount point. Providing an empty string as the mount point is the same as providing "*" as the mount point. WinFsp sample utilities like memfs will not assign mounted drive a drive letter when the mount point is an empty string, by skipping the call to FspFileSystemSetMountPoint(). So WinFsp does support this feature, but you may have to use native WinFsp API to make this work.

True. I touched a bit into this in mount: docs: make note about mounting as network drive in windows less confusing by albertony · Pull Request #4714 · rclone/rclone · GitHub

Found out you can actually supply empty string as mountpoint argument, rclone mount remote: "" --fuse-flag --VolumePrefix=\server\share , and it works... But it will still map to a drive letter - first free letter counting backwards from Z:, logic from WinFsp method FspFileSystemSetMountPoint . So somewhere between rclone and winfsp this method is being called regardless if mountpoint is empty, while WinFsp sample utilities airfs/memfs skips this call if no mountpoint specified. I could not see where this is happening. Anyway, most users probably want to map to drive letter, so perhaps it would be mostly of academic interest to track this down.

So not only of "academic interest" I guess... :blush:

Do you think your use case is covered by the previously mentioned Feature Request, or is it something that you think should be done independent of that?

When I was googling this issue I found this: How to mount as network drive in FUSE API (google.com)

where it's mentioned that the WinFsp implementation of fuse_mount

treats an empty mount point as an instruction to mount on the next available drive counting backwards from drive Z:
winfsp/fuse.c at v1.10 · winfsp/winfsp · GitHub

As fuse_main calls fuse_mount, to avoid calling FspFileSystemSetMountPoint, the WinFsp implementation of fuse_main and fuse_mount cannot be used.

The feature request about WinFsp Launcher mainly talks about how rclone could integrate with the launcher automatically. But even if it can't be done automatically, I can add the registry entries manually, and write some scripts to convert the command line arguments if necessary. After that, rclone can support the use of net use X: \\rclone\remote and net use * \\rclone\remote. However, net use \\rclone\remote without a drive letter will not work correctly, as a drive letter is always assigned. As a user, I can follow the documentation and modify the registry accordingly, but trying to modify the program code of rclone is probably out of my depth.

This "no mount point" feature would only be useful when integrating rclone with WinFsp Launcher, though.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.