How to mount OneDrive using WinFSP

First, I am completely new to rclone. Please take it into consideration if you find I completely misunderstood something. Thank you in advance.

What I would like to achieve with rclone?

I was able to succesfully mount my OneDrive as drive T using this command in foreground mode, that is, entering the command in Windows Command prompt:

rclone mount OneDrive_AB: T: --fuse-flag --VolumePrefix=\server\OneDrive --vfs-cache-mode writes

(I mounted it as Network Share because of what I read here: https://rclone.org/commands/rclone_mount/#mount-as-a-network-drive)

Now, I would like to mount my OneDrive using WinFSP. As I understood it, in this way I can mount my OneDrive automatically when WinFSP service is started. Also, in this way I would like to prevent a problem of not being able to access my OneDrive files from a program that is running with elevated privileges. (See this part of docs: https://rclone.org/commands/rclone_mount/#windows-caveats)

What is the problem you are having with rclone?

After configuring WinFSP, the OneDrive is not mounted (I cannot see drive T: in file commanders)

What is your rclone version (output from rclone version)

rclone v1.53.3

  • os/arch: windows/amd64
  • go version: go1.15.5

Which OS you are using and how many bits (eg Windows 7, 64 bit)

OS Name:                   Microsoft Windows 10 Pro
OS Version:                10.0.18363 N/A Build 18363
System Type:               x64-based PC

Which cloud storage system are you using? (eg Google Drive)

OneDrive

The command you were trying to run (eg rclone copy /tmp remote:tmp)

This is my WinFSP command and the output:

C:\Program Files (x86)\WinFsp\bin>diag.bat
HKEY_LOCAL_MACHINE\SOFTWARE\WinFsp\Services\OneDrive_AB
    Executable    REG_SZ    C:\Program Files\Nastroje\Rclone\rclone.exe
    CommandLine    REG_SZ    mount OneDrive_AB: T: --config rclone.conf --fuse-flag --VolumePrefix=\server\OneDrive --vfs-cache-mode writes -o uid=197608,gid=544
    JobControl    REG_DWORD    0x1
    Security    REG_SZ    D:P(A;;RPWPLC;;;WD)

See also screenshot from my regedit:

I have also tried different variations. For example I have used escaped backslashes, as well as quotes (mentioned as possible problem here):

Executable    REG_SZ    C:\\Program Files\\Nastroje\\Rclone\\rclone.exe
or
Executable    REG_SZ    "C:\\Program Files\\Nastroje\\Rclone\\rclone.exe"
CommandLine    REG_SZ    mount OneDrive_AB: T: --config rclone.conf --fuse-flag --VolumePrefix=\\server\\OneDrive --vfs-cache-mode writes -o uid=197608,gid=544

I have also used uid=-1,gid=-1 and some other values that were mentioned in this post.

After this setup, I have restarted WinFSP service and expected that my OneDrive will appear as disk T:
Unfortunately, it did not happen.

Could anyone point me what I am doing wrong?

hello and welcome to the forum,

if you are going to run rclone as a background service and have a problem, then use a rclone debug log.

if you run rclone as system user, then all processs can see it.

you can use windows task scheduler to run any task at system startup as system user.

Hi, thank you for your answer.
I have adjusted CommandLine entry in registry to read:

mount OneDrive_AB: T: --config rclone.conf -vv --log-file=C:\Users\XXXX\.config\rclone\debug.log --fuse-flag --VolumePrefix=\server\OneDrive --vfs-cache-mode writes -o uid=197608,gid=544

Is it correct? As I mentioned, I am new to rclone and even though I try to read docs, probably I do not always get it right.

Then I restarted WinFsp.Launcher service in services.msc console. But no debug file was created in the given location. To be honest, I am not sure whether the process has started even for a moment. Process Explorer does not show any process containing string "rclone".

imho, always use full paths for all parameters.

make sure the command runs from the command prompt before trying to run it as a service.

i have never used winfsp as a launcher; always used task scheduler.

This was a good point and reminder (I found out that the rclone could not locate correct conf file). Still, even after adjusting the command line arguments, the T: drive does not show up when WinFSP service is started. And no debug log is created. When I run the same command from cmd.exe, it is successful - both T: drive shows up and debug.log is created.
Here is excerpt from the debug.log when rclone is run from cmd.exe.

2021/01/16 16:30:06 DEBUG : rclone: Version "v1.53.3" starting with parameters ["C:\\Program Files\\Nastroje\\Rclone\\rclone.exe" "mount" "OneDrive_AB:" "T:" "--config" "C:\\Users\\XXXX\\.config\\rclone\\rclone.conf" "-vv" "--log-file=C:\\Users\\XXXX\\.config\\rclone\\debug.log" "--fuse-flag" "--VolumePrefix=\\server\\OneDrive" "--vfs-cache-mode" "writes"]
2021/01/16 16:30:06 DEBUG : Creating backend with remote "OneDrive_AB:"
2021/01/16 16:30:06 DEBUG : Using config file from "C:\\Users\\XXXX\\.config\\rclone\\rclone.conf"
2021/01/16 16:30:06 DEBUG : OneDrive_AB: Loaded invalid token from config file - ignoring
2021/01/16 16:30:10 DEBUG : Keeping previous permissions for config file: -rw-rw-rw-
2021/01/16 16:30:10 DEBUG : OneDrive_AB: Saved new token in config file
2021/01/16 16:30:13 INFO  : One drive root '': poll-interval is not supported by this remote
2021/01/16 16:30:13 DEBUG : vfs cache: root is "\\\\?\\C:\\Users\\XXXX\\AppData\\Local\\rclone\\vfs\\OneDrive_AB"
2021/01/16 16:30:13 DEBUG : vfs cache: metadata root is "\\\\?\\C:\\Users\\XXXX\\AppData\\Local\\rclone\\vfs\\OneDrive_AB"
2021/01/16 16:30:13 DEBUG : Creating backend with remote "\\\\?\\C:\\Users\\XXXX\\AppData\\Local\\rclone\\vfs\\OneDrive_AB"
2021/01/16 16:30:13 DEBUG : fs cache: renaming cache item "\\\\?\\C:\\Users\\XXXX\\AppData\\Local\\rclone\\vfs\\OneDrive_AB" to be canonical "//?/C:/Users/XXXX/AppData/Local/rclone/vfs/OneDrive_AB"
2021/01/16 16:30:13 DEBUG : fs cache: switching user supplied name "\\\\?\\C:\\Users\\XXXX\\AppData\\Local\\rclone\\vfs\\OneDrive_AB" for canonical name "//?/C:/Users/XXXX/AppData/Local/rclone/vfs/OneDrive_AB"
2021/01/16 16:30:13 DEBUG : One drive root '': Mounting on "T:"
2021/01/16 16:30:13 INFO  : vfs cache: cleaned: objects 0 (was 0) in use 0, to upload 0, uploading 0, total size 0 (was 0)
2021/01/16 16:30:13 DEBUG : One drive root '': Mounting with options: ["-o" "fsname=OneDrive_AB:" "-o" "subtype=rclone" "-o" "max_readahead=131072" "-o" "attr_timeout=1" "-o" "atomic_o_trunc" "-o" "uid=-1" "-o" "gid=-1" "--FileSystemName=rclone" "-o" "volname=OneDrive_AB" "--VolumePrefix=\\server\\OneDrive"]
2021/01/16 16:30:14 DEBUG : One drive root '': Init: 
2021/01/16 16:30:14 DEBUG : One drive root '': >Init: 

I have tried to run rclone in task scheduler but the task creates a console window that needs to stay opened. If I close the console, rclone is terminated and the disk is unmounted. Running rclone as a WinFSP service would enable it to run seamlessly in background.

Edit: Actually, if I run the task under SYSTEM account, console window is not visible. However, I would like to have the T: drive visible only for me and Administrators (that is, me in elevated prompt).

*have you tried to click hidden?
image

  • have you tried `run whether user is logged on or not?
    image

  • if you run rclone as system user, then there is no console.

  • you can use nircmd from the nirsoft collection of over 200 free windows tools.
    https://www.nirsoft.net/
    nircmd exec hide c:\path\to\batchfile.cmd

First and foremost, thank you for your patience and help.

Yes, but the console is still being shown.

When running the command as SYSTEM, the console is not shown (it seems I edited my post roughly in the same time as you posted your answer :grinning:). However, I decided I do not want all users to have access to my OneDrive.

So far I stick with the nircmd + task scheduler option you have mentioned. I know NirSoft utilities but I was not aware of this specific functionality. So thank you for this suggestion. :+1: This setup will be good enough most of the time.

Still, I would like to know whether there is any option to run rclone mount in such a way that I could have access to mounted drive no matter whether I am using elevated application** or non-elevated application*** (while not accessible to all other users).

** elevated application = with this I mean an application that runs in my admin account with admin privileges elevated through UAC prompt
*** non-elevated application = an application that runs in my admin account but without elevated admin privileges

you can more about that here
https://docs.microsoft.com/en-us/troubleshoot/windows-client/networking/mapped-drives-not-available-from-elevated-command

i mount to a folder, not to a drive letter, and that seems to work around that problem.
rclone mount remote: b:\mount\remote

1 Like

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