-
Notifications
You must be signed in to change notification settings - Fork 27
Windows HOWTO
This quick guide will explain the basic steps to run rar2fs on Windows using WinFSP and Cygfuse. The instructions are written primarily for use with WinFSP and 64-bit Windows 10 but most of the guide should work also for e.g. Dokany and other Windows versions, including 32-bit.
Download Cygwin from here.
You install by running setup-x86_64.exe (64-bit installation) or setup-x86.exe (32-bit installation). To complete the build and run rar2fs requires at least the following packages to be installed:
- automake (install wrapper + latest version)
- autoconf (install wrapper + latest version)
- binutils
- gcc-core
- gcc-g++
- make
- git
- wget
After the installation completes, run the Cygwin64- or Cygwin32 Terminal depending on what version you selected (should be located somewhere on your desktop).
In the Cygwin Terminal run the following commands. In this and following sections the output presented are examples only. The actual output may deviate slightly but should otherwise look very similar or something is most certainly wrong.
$ git clone https://github.com/hasse69/rar2fs.git
Cloning into ‘rar2fs’…
remote: Counting objects: 773, done.
remote: Total 773 (delta 0), reused 0 (delta 0), pack-reused 773
Receiving objects: 100% (773/773), 548.34 KiB | 684.00 KiB/s, done.
Resolving deltas: 100% (555/555), done.
$ cd rar2fs/
$ autoreconf -fi
configure.ac:20: installing ‘config/compile’
configure.ac:8: installing ‘config/config.guess’
configure.ac:8: installing ‘config/config.sub’
configure.ac:9: installing ‘config/install-sh’
configure.ac:9: installing ‘config/missing’
Makefile.am: installing ‘./INSTALL’
Makefile.am: installing ‘config/depcomp’
From the rar2fs folder run wget to download the latest version of UnRAR source. In the example below the latest version at that time was 5.6.5. You can find the most recent version here.
$ wget https://www.rarlab.com/rar/unrarsrc-5.6.5.tar.gz
–2018-09-01 13:00:18-- https://www.rarlab.com/rar/unrarsrc-5.6.5.tar.gz
Resolving www.rarlab.com (www.rarlab.com)… 5.135.104.98
Connecting to www.rarlab.com (www.rarlab.com)|5.135.104.98|:443… connected.
HTTP request sent, awaiting response… 200 OK
Length: 226296 (221K) [application/x-gzip]
Saving to: ‘unrarsrc-5.6.5.tar.gz’
unrarsrc-5.6.5.tar.gz 100%[========================================================================>] 220.99K --.-KB/s in 0.1s
2018-09-01 13:00:18 (1.73 MB/s) - ‘unrarsrc-5.6.5.tar.gz’ saved [226296/226296]
$ tar -zxf unrarsrc-5.6.5.tar.gz
$ cd unrar
$ make lib
After building the library, sitting in the unrar folder, double check that the following file was created
$ ls -l libunrar.a
-rw-r--r-- 1 User None 408K Aug 8 21:34 libunrar.a
Now it is time to install WinFSP. Download latest stable version from here and run the installer. Select both fuse and core for installation. The development part is not needed unless you plan to write your own WinFSP enabled file systems. From a Cygwin-terminal, change to the WinFSP cygfuse installation folder and run install.sh.
$ cd /cygdrive/c/Program\ Files\ \(x86\)/WinFsp/opt/cygfuse
$ ./install.sh
FUSE for Cygwin installed.
Now double check that all necessary files were installed (the below comes from a more recent version of WinFSP).
$ find / -name *fuse*
/bin/cygfuse-2.8.dll
/bin/cygfuse-3.2.dll
/lib/libfuse-2.8.dll.a
/lib/libfuse-3.2.dll.a
/lib/libfuse.dll.a
/lib/libfuse3.dll.a
/lib/pkgconfig/fuse.pc
/lib/pkgconfig/fuse3.pc
/usr/include/fuse
/usr/include/fuse/fuse.h
/usr/include/fuse/fuse_common.h
/usr/include/fuse/fuse_opt.h
/usr/include/fuse/winfsp_fuse.h
/usr/include/fuse3
/usr/include/fuse3/fuse.h
/usr/include/fuse3/fuse_common.h
/usr/include/fuse3/fuse_opt.h
/usr/include/fuse3/winfsp_fuse.h
/usr/libexec/git-core/mergetools/diffuse
/usr/bin/cygfuse-2.8.dll
/usr/bin/cygfuse-3.2.dll
/usr/lib/libfuse-2.8.dll.a
/usr/lib/libfuse-3.2.dll.a
/usr/lib/libfuse.dll.a
/usr/lib/libfuse3.dll.a
/usr/lib/pkgconfig/fuse.pc
/usr/lib/pkgconfig/fuse3.pc
Note that if you chose to install Dokany instead the set of files and their names will differ slightly.
That does not matter, rar2fs is clever enough to pick up the correct files automatically.
The important thing to remember here is that WinFSP and Dokany should never co-exist. Chose one or the other.
Otherwise there is a huge risk for conflicts.
From a Cygwin-terminal enter the rar2fs folder
$ cd rar2fs
$ ./configure --with-fuse=/usr/include/fuse
…
<lots of output>
…
configure: creating ./config.status
config.status: creating Makefile
config.status: creating config.h
config.status: executing depfiles commands
$ make
$ make install
$ which rar2fs
/usr/local/bin/rar2fs
$ rar2fs
Usage: rar2fs source mountpoint [options]
Try rar2fs -h' or rar2fs --help’ for more information.
Now you have a working rar2fs executable possible to run from a Cygwin-terminal.
The WinFSP/Cygwin build of rar2fs introduces a few different mount options compared to legacy FUSE, most of which you normally do not need to worry about. The rar2fs --help command will always show the latest set of options available to you. Here is an example of the WinFSP/Cygfuse specific options available at time of writing:
WinFsp-FUSE options:
-o umask=MASK set file permissions (octal)
-o create_umask=MASK set newly created file permissions (octal)
-o uid=N set file owner (-1 for mounting user id)
-o gid=N set file group (-1 for mounting user group)
-o rellinks interpret absolute symlinks as volume relative
-o volname=NAME set volume label
-o VolumePrefix=UNC set UNC prefix (/Server/Share)
--VolumePrefix=UNC set UNC prefix (\Server\Share)
-o FileSystemName=NAME set file system name
-o DebugLog=FILE debug log file (requires -d)
WinFsp-FUSE advanced options:
-o FileInfoTimeout=N metadata timeout (millis, -1 for data caching)
-o DirInfoTimeout=N directory info timeout (millis)
-o VolumeInfoTimeout=N volume info timeout (millis)
-o KeepFileCache do not discard cache when files are closed
-o ThreadCount number of file system dispatcher threads
What is important is to set the uid and gid to -1. This will make sure the mount is performed with credentials belonging to current user and group rather than System, which is otherwise the default. Another thing to remember is how Cygfuse works with mount points. If you chose to mount to a folder that folder must not exist under Cygwin prior to the mount (compare with Linux for which the folder must exist or else the mount will fail). It is also possible to mount to a Windows drive letter instead of a local folder. Below is an example of such a mount to drive P:
$ rar2fs /cygdrive/x/files/ p: -ouid=-1,gid=-1
The P: drive can now be accessed as any other drive from the Windows explorer or from Cygwin as /cygdrive/p.
It is possible to run rar2fs and mount folders and/or drives directly from the Windows environment / Command Prompt. You do not need to run it through the Cygwin shell. Actually, to be able to setup the Windows service and explorer integration later you must make sure rar2fs can run outside of the Cygwin environment. To allow this there is only one thing you need to do and that is to add the path to some required DLLs to the Windows System Path.
Here are a few simple steps to do that on Windows 10 and Windows 8.
- In Search, search for and then select: Control Panel
- Select System and Security and then select System
- Click the Advanced System Settings link.
- Click Environment Variables. In the section System Variables (not User Variables), find the Path environment variable and select it. Click Edit. If the Path environment variable does not exist, click New.
- In the Edit system variable (or New system variable) window, specify the value of the Path environment variable. For a Cywgin 64-bit default install, the value to add is
%SYSTEMDRIVE%\cygwin64\bin - Click OK. Close all remaining windows by clicking OK.
To verify that is works, start the Windows Command Prompt (In Search, search for cmd).
Microsoft Windows [Version 10.0.18362.295]
(c) 2019 Microsoft Corporation. All rights reserved.
C:\Users\User>cd c:\cygwin64\home\User\rar2fs
c:\cygwin64\home\User\rar2fs>rar2fs.exe
Usage: rar2fs source mountpoint [options]
Try `rar2fs -h' or `rar2fs --help' for more information.
c:\cygwin64\home\User\rar2fs>
If you get the same output as shown above when trying to execute rar2fs.exe then everything is ready to go.
The WinFSP/launcher can be made fully aware of the rar2fs file system.
This will enable the use of e.g. the net use command or mounting the file system as a
drive using the Windows Explorer Map Network Drive feature. The benefit of going for
this approach is that the network drives are usually (unless explicitly told not to) restored
automatically after system boot. It is also possible to disconnect such drives from the
Windows explorer directly.
The launcher recently had some new features added which this guide will make use of.
For that reason we need to make sure a version of WinFSP is installed that supports them.
At time of writing that means we need to install at least WinFSP 2019.3 B2 which can be downloaded here.
If an older stable version was used in the previous steps there is no real need to redo all of them.
Simply uninstall the old version and upgrade to the new one. And to be on the safe side,
make sure to also re-install cygfuse using install.sh in the WinFSP/opt installation folder.
Rebuilding rar2fs should not really be necessary, but it does not hurt either.
To enable the launcher integration we need to add a few entries in the Windows registry.
Create a file named e.g. rar2fs.reg somewhere easily found (we need to execute it later)
that contains the following lines:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\WinFsp\Services\rar2fs]
"Executable"="c:\\cygwin64\\home\\User\\rar2fs\\rar2fs.exe"
"JobControl"=dword:00000001
"Security"="D:P(A;;RPWPLC;;;WD)"
"CommandLine"="-f /cygdrive/%\\/b/_1 %2 --VolumePrefix=%1 -o UserName=%\\+_U"
"RunAs"="."
Once the file has been created, browse to it and double-click. This should install the rar2fs key in the registry.
Note that the Executable entry must be adjusted according to your own setup.
The RunAs entry is optional but is required if you wish to mount already mounted network drives.
Due to that the laucher is by default executing using the SYSTEM account there are limitations to what this account can access across network shares (e.g. Samba/CIFS) unless explicit permission has been given from the server side. Setting RunAs to a single . forces the launcher to execute in the context of the current user. But please read this since there might be security implications using this approach. For now this the only way to be able to access such drives (to my knowledge at least). Feel free to experiment and get back to me if you find some better solution.
Now to test if everything works, right-click This PC and chose Map network drive.
If we have a directory D:\myfiles that contains the archives we wish to mount, then
in the pop-up dialog enter \\rar2fs\d\myfiles as the Folder. Note the double backslash before rar2fs.
Also, make sure to replace \d\myfiles\ with whatever path you have to your archives.
If everything went well a new drive letter (whatever you selected) should now be visible under This PC in the
Network Locations section.
Links
External Links
RARLAB Home
FUSE Home
AVI-Mux GUI Home
MacFUSE Home
Fuse4x Home
OSXFUSE Home
Mailing List Archives on Nabble
WinFSP
Cygwin