How to enable a Windows application in WINE to access a Samba share on a NAS
September 18, 2016 30 Comments
I recently installed the Windows application PDF-XChange Editor under WINE in Gentoo Linux on one of my laptops. The application works fine but it could not detect the SMB/CIFS (Samba) share folder on my NAS. When I clicked on ‘File
‘ > ‘Open...
‘ in the application, the left pane of the ‘Open Files
‘ dialogue window displayed the following options:
+ Favourites
– Desktop
+ My Computer
+ My Documents
Trash
+ /
If I clicked on ‘My Computer
‘, the right pane of the dialogue window then displayed the following options:
Control Panel
(C:)
(D:)
(E:)
(F:)
(G:)
(Z:)
None of the entries in either pane enabled me to get to the Samba shares on my NAS. Anyway, it turned out to be relatively easy to configure the installation on my laptop to enable the Windows application to access the Samba shared folder on the NAS, and the basic procedure was as follows:
- Create a mountpoint.
- In the directory
$WINEPREFIX/dosdevices/
create a symbolic link to the mountpoint. - Mount the network share on the mountpoint.
Let’s look in detail at the procedure…
My Clevo W230SS laptop running Gentoo Linux Stable Branch amd64 currently has KDE Plasma 5.6.5 and WINE 1.9.18 installed. I had used a WINE prefix of ~/.wine-pdfxve6
to install the Windows application in the fitzcarraldo
user account. Let us say that the hostname of my Linux NAS is ‘bsfnas1
‘, the name of the Samba shared folder on the NAS is ‘brianfolder
‘, the Samba username for that shared folder on the NAS is ‘brian
‘ and the Samba share password on the NAS is ‘enricocaruso
‘.
First I checked which drive letters were already being used by WINE:
$ ls -la ~/.wine-pdfxve6/dosdevices/
total 8
drwxr-xr-x 2 fitzcarraldo fitzcarraldo 4096 Sep 16 23:18 .
drwxr-xr-x 4 fitzcarraldo fitzcarraldo 4096 Sep 17 04:03 ..
lrwxrwxrwx 1 fitzcarraldo fitzcarraldo 10 Sep 16 23:18 c: -> ../drive_c
lrwxrwxrwx 1 fitzcarraldo fitzcarraldo 9 Sep 16 23:18 d:: -> /dev/sdb1
lrwxrwxrwx 1 fitzcarraldo fitzcarraldo 8 Sep 16 23:18 e:: -> /dev/sdc
lrwxrwxrwx 1 fitzcarraldo fitzcarraldo 9 Sep 16 23:18 f:: -> /dev/sdc1
lrwxrwxrwx 1 fitzcarraldo fitzcarraldo 8 Sep 16 23:18 g:: -> /dev/sdb
lrwxrwxrwx 1 fitzcarraldo fitzcarraldo 1 Sep 16 23:18 z: -> /
As no Windows Y:
drive was listed, I decided to use that drive letter for my network Samba share as shown in the steps below.
I created a mountpoint for the share:
$ sudo mkdir -p /media/bsfnas1/brianfolder
Then I created the symlink:
$ ln -s /media/bsfnas1/brianfolder ~/.wine-pdfxve6/dosdevices/y:
$ ls -la ~/.wine-pdfxve6/dosdevices/
total 8
drwxr-xr-x 2 fitzcarraldo fitzcarraldo 4096 Sep 17 15:38 .
drwxr-xr-x 4 fitzcarraldo fitzcarraldo 4096 Sep 17 15:39 ..
lrwxrwxrwx 1 fitzcarraldo fitzcarraldo 10 Sep 16 23:18 c: -> ../drive_c
lrwxrwxrwx 1 fitzcarraldo fitzcarraldo 9 Sep 16 23:18 d:: -> /dev/sdb1
lrwxrwxrwx 1 fitzcarraldo fitzcarraldo 8 Sep 16 23:18 e:: -> /dev/sdc
lrwxrwxrwx 1 fitzcarraldo fitzcarraldo 9 Sep 16 23:18 f:: -> /dev/sdc1
lrwxrwxrwx 1 fitzcarraldo fitzcarraldo 8 Sep 16 23:18 g:: -> /dev/sdb
lrwxrwxrwx 1 fitzcarraldo fitzcarraldo 11 Sep 17 15:37 y: -> /media/bsfnas1/brianfolder
lrwxrwxrwx 1 fitzcarraldo fitzcarraldo 1 Sep 16 23:18 z: -> /
Finally, I mounted the network share onto the symlink:
$ sudo mount.cifs //bsfnas1/brianfolder/ -o user=brian,pass=enricocarusou,id=$(id -u),gid=$(id -g) ~/.wine-pdfxve6/dosdevices/y:
As before, I see the following when I click on ‘File
‘ > ‘Open...
‘ in the Windows application running under WINE:
+ Favourites
– Desktop
+ My Computer
+ My Documents
Trash
+ /
If I click on ‘My Computer
‘ in the ‘Open File
‘ dialogue window, the following items are displayed in the right pane of the window:
Control Panel
(C:)
(D:)
(E:)
(F:)
(G:)
(Y:)
(Z:)
and I can select the ‘(Y:)
‘ and browse the contents of the shared folder brianfolder
on the NAS drive.
Although I found it was unnecessary to do it for PDF-XChange Editor, apparently some Windows applications require the use of Windows UNC syntax, so I also did the following:
$ mkdir -p ~/.wine-pdfxve6/dosdevices/unc/bsfnas1
$ ln -s /media/bsfnas1/brianfolder ~/.wine-pdfxve6/dosdevices/unc/bsfnas1/brianfolder
If I wanted to unmount the Samba share explicitly, rather than leaving it to be unmounted automatically when I shutdown the laptop, I would enter the following command:
$ sudo umount ~/.wine-pdfxve6/dosdevices/y\:/
Then the Windows application on my laptop would no longer be able to browse the unmounted network share:
$ ls ~/.wine-pdfxve6/dosdevices/
c: d:: e:: f:: g:: unc y: z:
$ ls -la /media/bsfnas1/brianfolder
total 8
drwxr-xr-x 2 root root 4096 Sep 17 15:35 .
drwxr-xr-x 4 root root 4096 Sep 17 15:35 ..
$
You may be wondering why I did not add an entry in the file /etc/fstab
on my laptop, to mount the Samba share automatically when I boot the laptop. The reason I didn’t is because I often use the laptop away from home and the NAS on my home network is then inaccessible in any case. However, to save myself the hassle of having to enter the mount
command manually when I am at home and want to use the Windows application to open a file that is in the NAS shared folder, I created two Desktop Configuration files named mount_bsfnas1_brianfolder_share.desktop
and umount_bsfnas1_brianfolder_share.desktop
with nice icons in my ~/Desktop directory on the laptop:
[Desktop Entry] Comment[en_GB]=Mount bsfnas1 brianfolder share for PDF-XChange Editor Comment=Mount bsfnas1 brianfolder share for PDF-XChange Editor Exec=sh /home/fitzcarraldo/mount_bsfnas1_brianfolder_share.sh GenericName[en_GB]=Mount bsfnas1 brianfolder share for PDF-XChange Editor GenericName=Mount bsfnas1 brianfolder share for PDF-XChange Editor Icon=media-mount MimeType= Name[en_GB]=mount_bsfnas1_brianfolder_share Name=mount_bsfnas1_brianfolder_share Path= StartupNotify=true Terminal=true TerminalOptions=\s--noclose Type=Application X-DBUS-ServiceName= X-DBUS-StartupType=none X-KDE-SubstituteUID=false X-KDE-Username=fitzcarraldo
[Desktop Entry] Comment[en_GB]=Unmount bsfnas1 brianfolder share for PDF-XChange Editor Comment=Unmount bsfnas1 brianfolder share for PDF-XChange Editor Exec=sh /home/fitzcarraldo/umount_bsfnas1_brianfolder_share.sh GenericName[en_GB]=Unmount bsfnas1 brianfolder share for PDF-XChange Editor GenericName=Unmount bsfnas1 brianfolder share for PDF-XChange Editor Icon=media-eject MimeType= Name[en_GB]=umount_bsfnas1_brianfolder_share Name=umount_bsfnas1_brianfolder_share Path= StartupNotify=true Terminal=true TerminalOptions=\s--noclose Type=Application X-DBUS-ServiceName= X-DBUS-StartupType=none X-KDE-SubstituteUID=false X-KDE-Username=fitzcarraldo
and the Bash scripts mount_bsfnas1_brianfolder_share.sh
and umount_bsfnas1_brianfolder_share.sh
launched by the above two Desktop Configuration files are, respectively:
#!/bin/bash echo "This will mount the Samba share folder brianfolder on the bsfnas1 machine." echo echo "Enter your Linux account password below..." echo sudo mount.cifs //bsfnas1/brianfolder/ -o user=brian,pass=enricocaruso,uid=$(id -u),gid=$(id -g) ~/.wine-pdfxve6/dosdevices/y: echo if grep -q "/media/bsfnas1/brianfolder" /proc/mounts; then echo "Samba share //bsfnas1/brianfolder is mounted." else echo "Samba share //bsfnas1/brianfolder is not mounted." fi echo echo "You may now close this window."
#!/bin/bash echo "This will unmount the Samba share folder brianfolder on the bsfnas1 machine." echo echo "Enter your Linux account password below..." echo sudo umount ~/.wine-pdfxve6/dosdevices/y: echo if grep -q "/media/bsfnas1/brianfolder" /proc/mounts; then echo "Samba share //bsfnas1/brianfolder is mounted." else echo "Samba share //bsfnas1/brianfolder is not mounted." fi echo echo "You may now close this window."
Don’t forget to make the two shell scripts executable:
$ chmod +x /home/fitzcarraldo/mount_bsfnas1_brianfolder_share.sh
$ chmod +x /home/fitzcarraldo/umount_bsfnas1_brianfolder_share.sh
If I was doing this on a desktop PC instead of a laptop, instead of creating the above-mentioned .desktop
files and Bash scripts I would have added the following line in the file /etc/fstab
to mount the NAS Samba shared folder automatically at boot:
//bsfnas1/brianfolder /media/bsfnas1/brianfolder cifs rw,iocharset=utf8,user=brian,pass=enricocaruso 0 0
It works (I’ve tried it).
Further reading
WineHQ Forums – Mapped network drive in wine.
Estendendo suporte a UNC no Wine.
Pingback: Completing PDF forms and adding your signature without having to print the form | Fitzcarraldo's Blog
Dear team, I used Mint 19 so can you please help to send the script for this mounting automatically at boot.
There is no team, just me. I don’t understand your question; the article already explains how to mount a Samba share automatically at boot (see the last paragraph with the entry to /etc/fstab).
Sorry man, I did follow your steps but when I use Microsoft to access network share then do not see ‘(Y:)’ drive so I have to access to /media/windowsshare to open files. Can you please help on this?
I still do not understand what you did or are doing. If you list all the commands you entered in Linux, and the terminal output resulting from those commands, that may help me to understand what you did or are doing.
I did map windows share as yours but when I click to “My Computers” in the right pane of windows still not show ‘(Y:)’ drive
Please paste here all the commands you entered in the terminal, and paste here all the output in the terminal resulting from those commands.
Thanks man, maybe somethings wrong with my typo… 😦
BTW, do you have solution for installing Office 365 on Linux also? If yes, please help…
No, I don’t. I don’t use Office 365.
See the WINEHQ AppDB:
Category: Main > Productivity > Office Suites > Microsoft Office (installer only) > 365 Personal (32 bit)
https://appdb.winehq.org/objectManager.php?sClass=version&iId=36804
Category: Main > Productivity > Office Suites > Microsoft Office (installer only) > 365 ProPlus (2016)
https://appdb.winehq.org/objectManager.php?sClass=version&iId=35527
Seems some people have had some success. I have not tried either myself, as I don’t use Microsoft Office 365.
Hi again, I open files from windows share but can not save the content, it said: word cannot complete the save due to a file permission error. Please help…
how can I paste the pictures on this? I want to share with you some pics…
You cannot paste pictures here. Upload them to an image sharing Web site and paste the links to the pictures here.
sudo mkdir -p /media/quang111
ln -s /media/quang111 ~/.wine/dosdevices/x:
ls -la /media/quang111 -> total 8
But when I click to “My Computers” in the right pane of windows still not show ‘(X:)’ drive
https://ibb.co/pL74brF
https://ibb.co/ZKBQnYd
If the ‘
ln -s
‘ command didn’t work in the first place it is obvious that clicking on ‘My Computer’ will not show the drive. Why didn’t you say in your first comment that the command failed, to avoid wasting time? What made you think that you would see the drive if a preceding step in the procedure failed? That’s illogical. 🙄I don’t use Linux Mint but I have just installed Linux Mint 64-bit 19.2 in a virtual machine and installed WINE in it to check that command. I checked which drive letters were already being used by WINE:
I created a mountpoint for the share:
Then I created a symlink to it and checked it had been created correctly:
So the command works fine in Linux Mint. As I do not use Linux Mint I suggest you post your problem on the Linux Mint Forums. Linux Mint users will be able to help you better because they will know any Linux Mint idiosyncrasies.
You are super, thanks for your quickly action. I did as your steps and I can see the network share at boot already but still not see those drive (x:,y:,…) when I used Ms Office save as files from “My Computers” on below pics.
Sorry if it made you confuse… My main purpose: Open files on Network share with Ms Office and Save all content directly (same as Windows sharing)
https://ibb.co/TcmCRRC
https://ibb.co/ZKBQnYd
If you cannot open the drive (shared folder) you linked to (which is Y: in my example), i.e. if you cannot view its contents nor open a file that is stored on it, then you must be doing something incorrectly. As my article points out, you need to mount the network share onto the symlink in order to be able to access the drive (shared folder).
Sorry, if its made you confuse…
I can map network share at boot already.
But my main purpose is opeing files on network sharing (mapped drive) and save again it directly.
Did you try to do this?
Yes, I did try it. If you have followed exactly my article and you are able to open a document (SMB share on another machine) in PDF-XChange Editor running under WINE but are unable to save that document as an SMB share on another machine, you need to change the ownership. Therefore, instead of the following command:
the command would be:
See: https://unix.stackexchange.com/questions/68079/mount-cifs-network-drive-write-permissions-and-chown
I have edited my article to make that clear.
still not overwrite the edited files but can save to the other files name
Why don’t you experiment with different Windows applications in WINE instead of Microsoft Office? Any Windows application that saves files would do, such as a text editor, a PDF editor or an image editor. Those Windows applications work for me using the method described in my blog post. That way you will find out if your problem is specifically due to the Microsoft Office you are using. Microsoft Office saves files in a complicated way (see the link below), so that may be causing your problem.
https://support.microsoft.com/en-us/help/211632/description-of-how-word-creates-temporary-files
Thanks a lot man. I have to find the other softs instead… BTW, you are very nice… 🙂
See my comment of October 25, 2019 regarding editing the WINE Registry for Microsoft Office 2007. I don’t know which version of Microsoft Office you are using, but it might help you.
For the Microsoft Word Registry key in different versions of Microsoft Office, see the following:
https://docs.microsoft.com/en-us/office/troubleshoot/word/reset-options-and-settings-in-word#word-key
I have experimented with Microsoft Office 2007 running via WINE in Gentoo Linux on one of my laptops. After configuring my laptop according to the procedure given in my blog post (but using a WINEPREFIX of
~/.wine-office2007
instead of~/.wine-pdfxve6
, as I had used~/.wine-office2007
as the WINEPREFIX when installing Microsoft Office 2007) it is possible for Microsoft Word running on my laptop to open .docx SMB shares on my NAS, but Microsoft Word was unable to save any file back to the NAS (neither to overwrite the original file nor to save with a different file name). The error message displayed by Microsoft Word in a pop-up window was:I searched the Web, and there are plenty of posts about this and similar problems saving Microsoft Office files to a networked Samba server. The articles make various suggestions, such as additional options in the
smb.conf
file on the server. I tried many of the suggestions, but they made no difference. The impression I get from reading all these posts is that the problem is caused by the way Microsoft Office saves files (see the link I gave in my previous comment). Then I came across an article titled ‘Saving messages to a network share creates tmp-files‘. Although not the same error as I saw with Microsoft Word 2007, it seems to me to be related. I therefore made the following Registry changes in WINE (see the above-mentioned article):To edit the Registry for the WINEPREFIX
~/.wine-office2007
I did the following in a terminal window on my laptop:I set
~/.wine-office2007
as the default WINEPREFIX in winetricks, and I used winetricks to run the Registry Editor. I then added the above-mentioned value to the Registry key (which clearly is not only for Outlook 2007). Microsoft Word in WINE now can save files to my remote SMB server, although I have to save twice, because the first attempt still results in a zero-length file.After mounting the SMB shared folder I do the following:
1. Click on ‘Open’ in Microsoft Word.
2. Click on ‘My Computer’.
3. Double-click on ‘(Y:)’ to view the files on the NAS.
4. Select a file to open and click ‘Open’. Make any changes you want to the document.
5. Select ‘Save As’ > ‘Word Document’.
6. Enter a file name in the ‘Save As’ window, and click ‘Save’. This creates a zero-length file.
7. The ‘Save As’ window then reappears. Enter the file name again and click ‘Save’.
8. Another window pops up with three options to select: ‘Replace existing file’, ‘Save changes with a different name’ and ‘Merge changes into existing file’.
9. Select ”Replace existing file’ and click ‘OK’. The file is now saved correctly.
The design of Microsoft Office leaves a lot to be desired.
thanks a lot man, I will try on….
You still have not mentioned what version of Microsoft Office you are using via WINE. Which version of Microsoft Office is it?
Pingback: How to enable a Windows application in WINE to access a Samba share on a NAS (continued) | Fitzcarraldo's Blog
Office 365, I try to use on CrossOver
If you have already got Microsoft Office 365 installed via CrossOver, and if disabling Robustified UNC still does not enable you to save Microsoft Office 365 files to a remote SMB share drive, have you contacted CodeWeavers to ask for help? As you have purchased CrossOver from them, they should be able to advise you.