[HOW-TO] Map a permanent Windows Network share to File Station

Don't miss a thing. Post your questions and discussion about other uncategorized NAS features here.
User avatar
oyvindo
Experience counts
Posts: 1399
Joined: Tue May 19, 2009 2:08 am
Location: Norway, Oslo

[HOW-TO] Map a permanent Windows Network share to File Station

Post by oyvindo »

[Edit] Although this guide works well, with the updates to QTS, it is now easier to use "Create Remote Mount" from File Station. (See the end of the Guide)

Background
Browsing into your NAS shared folders from a Windows PC on your LAN, is easy. It typically works out-of-the-box, every time.
All you do is to launch Windows explorer and click on the Network icon and it will automatically find any QNAP NAS server on your LAN (as well as any other network-sharing device you may have).

However, going the other way, isn't a piece of cake. It beats me why. I mean, since we all expect windows to be able to find the NAS, why shouldn't the NAS be able to find my Windows PC?
This [HOW-TO] guide describe how I managed to establish a permanent link to my Windows PC so by simply opening (running) File Station (the equivalent of Windows Explorer) I can now easily access the harddrive on my Windows PC from the NAS.

Why would I want to do that?
1. Because I can and will
2. Because I have data on my Windows PC that I maintain there with no desire to have copies of it on the NAS, but I'd like the NAS to be able to read this data.
3. Because when I log into my NAS using Cloudlink, I now have access to my Windows PC as well, without the need to open any ports in my router (firewall)!
4. Can you think of any additional good reasons?

Here's how I did it:

PREREQUISITES
It's assumed that:

Network connections have been configured properly.
Your local (NAS) username is nasusername.
Share username on Windows computer is msusername.
Share password on Windows computer is mspassword.
The Windows computer's name is servername (this can be either an IP address or an assigned name).
The name of the share is sharename.
You want to mount the share in /media/windowsshare.

You can temporarely mount a Windows share from the command line of your NAS. Assuming you intend to access the remote share as part of an existing share:
Use Putty to SSH into your NAS and type the following on the command line:

Code: Select all

mkdir /media/windowsshare
mount.cifs //servername/sharename  /media/windowsshare -o iocharset=utf8,username=msusername,password=mspassword
To unmount, use:

Code: Select all

umount /media/windowsshare
The name <windowsshare> can be anything of your choice, and the path </media/> can be anything of your choice. I typically used /share/Public/WindowsShare for my testing purpose.
This is just a name for a local share folder used to point to the remote windows machine. You must create this folder somewhere on your NAS. After unmounting the share, you should delete this folder if you have no further use for it.
The iocharset parameter is to make foreign characters like (æøå) work properly in foldernames.

However, the above isn't very useful unless your need is only on a one-off basis. But I included it for the sake of completeness, understanding and testing purpose. Cause if you can't make temporary connection, then you will not be able to make the rest of this guide work for you either.

HOW TO MOUNT A WINDOWS SHARE PERMANENTLY
This guide describes how to mount CIFS shares permanently. The shares might be hosted on a Windows computer/server, or on a Linux/UNIX server running Samba. This also applies to SMBFS shares, which are similar to CIFS but are deprecated and should be avoided if possible.

MOUNT A PASSWORD PROTECTED NETWORK SHARE
The quickest way to auto-mounting a password-protected share is normally to edit /etc/fstab (with root privileges), to add this line:
//servername/sharename /media/windowsshare cifs username=msusername,password=mspassword,iocharset=utf8,sec=ntlm 0 0

But it is generally not a good idea to write down usernames and passwords in clear text, therefore, using a specially prepared credential file, is a better approach.

Using a text editor (I use the 'vi' editor in this example because it is available in all QNAPs, but you can choose to use any editor of your choice), create a file for your remote servers logon credential:
vi ~/.smbcredentials

Enter your Windows username and password in the file:
username=msusername
password=mspassword

Save the file, exit the editor. Be aware that this file will be stored in your home directory (due to the ~/) and it will be a hidden file (because it begins with a .) The home folder for admin user on QNAP is /root unless changed. Perhaps a better idea is to use the /home folder or if your're logged on a user with admin privileges, you'll be using that users home folder. As long as you know where it is stored, it doesn't really matter.

Change the permissions of the file to prevent unwanted access to your credentials:
chmod 600 ~/.smbcredentials

Since the /etc/fstab is located in a RAM-disk on the QNAP (this is not according to Lunix standard), it will be overwritten with a clean file each time you reboot. Therefore, a different approach must be used on QNAP NAS's. (The following info has been partly copied from Don Muller's excellent QNAP Guide which can be found here: download/file.php?id=2096)

CUSTOMIZING QNAP STARTUP
There are certain files and settings that get reset back to factory defaults at every reboot. In
order to set those back to what you want you need to modify the autorun.sh script. This file is
executed every time the NAS is booted. It is located on a volume that is not normally
mounted. This means that anytime you wanted to edit the file you would have to mount that
volume, edit the file, and then unmount the volume. A better way is to make the autorun.sh file
a link to your own autorun file. This way you only have to edit your autorun.sh file which you can
store anywhere you like on an unmounted volume once. To change the autorun behaviour of your NAS,
you would just have to edit your own autorun file.
Here are the steps to change the default autorun.sh file into a link pointing to your own autorun.sh

On the ARM series NAS use the following:

Code: Select all

mount /dev/mtdblock5 -t ext2 /tmp/config	#This makes that mtdblock5 folder from the NAS flash memory available (mounted) in /tmp/config
cd /tmp/config
rm autorun.sh										#Before deleting any existing autorun.sh, check to see if it contains anything valuable.
ln -sf /home/autorun.sh autorun.sh			#This creates a symlink named autorun.sh pointing to your autorun.sh which is not located on the RAM disk.
cd /
umount /dev/mtdblock5
On the Intel series NAS use the following:

Code: Select all

mount /dev/sdx6 /tmp/config
cd /tmp/config
rm autorun.sh (see note 1)
ln –sf /path to your file/autorun.sh autorun.sh
cd /
umount /dev/sdx6
If for some reason, like maybe during a firmware update, the link is replaced with the default
file, you would only have to restore the link as described above. Your autorun file would still be intact.

Notes
1. Check to see if the existing autorun.sh file has any entries in it before you delete it. If it
does copy them to you new autorun.sh file before deleting the one in /tmp/config.
2. Make sure you unmount the device before the NAS is rebooted.
3. Make sure the autorun.sh files are marked as executable (chmod +x autorun.sh).
4. Any files or executables that you reference in the autorun.sh file, or any files or
executables that are referenced by your scripts or other scripts, must use the full path
name. During the execution of autorun.sh the system will not perform a search to find
other executables or files; you must specify the full paths in everything that you
reference.

Then edit your own autorun.sh file by adding:

Code: Select all

mount.cifs //servername/sharename /media/windowsshare -o iocharset=utf8,credentials=/home/nasusername/.smbcredentials,sec=ntlm 0 0
That's it. Now reboot.
Go to File Station and browse into /media/windowsshare and viola, you're looking at your Windows machine :-0
The above assumes of course that your Windows PC is turned, on, properly connected to your LAN (cabled or WiFi), and that it has Network and File Sharing enabled and that a folder has been shared.
I typically have the root folder of my C:/ drive shared, thus having access to everything on my Windows PC.

How to use REMOTE MOUNT from File Station instead
You can use the Remote Mount feature built into File Station as an alternative, but for some reason (don't ask me why), QNAP still - in 2020 - only support SMB 1.0
This protocol is inherently insecure and old fashion, and has been disabled by default in Windows for at least five years, but you can re-enable it.
And you must re-enable SMB 1.0 on every windows machine that you wish to mount as remote shares in a QNAP NAS.

The process is fairly straight forward:
1. Select a folder on your Windows machine using File Explorer, and share it using File Share and give your share a logical name of your choice
You can of course share the whole C:\ drive and thereby allow access to everything. (For some reason you cannot use the administrative share c$)
Choose Read Only or Read/Write access depending on your need.

2. Enable SMB 1.0 server protocol under Control Panel --> Programs and Features --> Turn Windows Feature On or Off
Scroll down the list and expand SMB 1.0/CIFS File Sharing Protocol Then tick only the server component, and click OK.

3. Back at you NAS, in File Station, click on Remote Mount in the upper right corner of the window and select Create Remote Mount in the menu.
Check the CIFS/SMB blue icon and click Next
In the configuration box, enter the IP address of your windows machine. It is highly preferable to have static IP addresses. If not, you should be able to use the NetBIOS name instead.
Type in a valid Username/Password combination that actually do have access to the share on your Windows machine.
In the Mount Specific Folder field, type the name you gave the share in 1 and press the Tab-key on your keyboard.
Note the peculiar name automatically assigned to your Mount in the field Connection Name. You can change this to anything you'd like it to be.

4. That' it. Click Create and after a while everything should be done and you'll find your new share in the folder list in File Station at the end of the list under CIFS/SMB

Happy browsing.
Last edited by oyvindo on Thu Jan 30, 2020 7:28 pm, edited 3 times in total.
ImageImageImage
ggibby
Starting out
Posts: 22
Joined: Sat Nov 19, 2011 2:48 am

Re: [HOW-TO] Map a permanent Windows Network share to File Station

Post by ggibby »

THANK YOU!
User avatar
oyvindo
Experience counts
Posts: 1399
Joined: Tue May 19, 2009 2:08 am
Location: Norway, Oslo

Re: [HOW-TO] Map a permanent Windows Network share to File Station

Post by oyvindo »

ggibby wrote:THANK YOU!
You're welcome! :)
I'm glad it worked for you as well
ImageImageImage
ggibby
Starting out
Posts: 22
Joined: Sat Nov 19, 2011 2:48 am

Re: [HOW-TO] Map a permanent Windows Network share to File Station

Post by ggibby »

OK, while your directions have really helped me along, things are still not working.

My mount commands:
# mount.cifs //192.168.168.15/m/movies /share/MD0_DATA/Movies -o iocharset=utf8,username=graham,password=<redacted>
# mount.cifs //192.168.168.50/tv /share/MD0_DATA/TV -o iocharset=utf8,username=graham,password=<redacted>

result in another PuTTY prompt, no error, and at least once the Movies command worked,
but now they don't actually mount.

TS419P II on QTS 4.3.3

A new install of Plex also isn't working, but I doubt they are related.

-G
User avatar
OneCD
Guru
Posts: 12037
Joined: Sun Aug 21, 2016 10:48 am
Location: "... there, behind that sofa!"

Re: [HOW-TO] Map a permanent Windows Network share to File Station

Post by OneCD »

Might be related: you're mounting into the NAS share-root (/share/MD0_DATA/).

Oyvindo's notes indicate a path off the root such as /media/windowsshare.

ImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImage
ggibby
Starting out
Posts: 22
Joined: Sat Nov 19, 2011 2:48 am

Re: [HOW-TO] Map a permanent Windows Network share to File Station

Post by ggibby »

oyvindo:
"The name <windowsshare> can be anything of your choice, and the path </media/> can be anything of your choice.
I typically used /share/Public/WindowsShare for my testing purpose."

Also, when you create folders in QTS, that's the default path.
Anywhere else and they aren't accessible via the web GUI, and I don't know how I'd verify the mount was active.
User avatar
OneCD
Guru
Posts: 12037
Joined: Sun Aug 21, 2016 10:48 am
Location: "... there, behind that sofa!"

Re: [HOW-TO] Map a permanent Windows Network share to File Station

Post by OneCD »

ggibby wrote:oyvindo:
"The name <windowsshare> can be anything of your choice, and the path </media/> can be anything of your choice.
I typically used /share/Public/WindowsShare for my testing purpose."
Yes, I just noticed that he said that. I was interpreting too literally. ;)
ggibby wrote:Also, when you create folders in QTS, that's the default path.
Anywhere else and they aren't accessible via the web GUI, and I don't know how I'd verify the mount was active.
Correct, although a bind mount from outside the share root will solve that. But it has to be back into a known QTS share to be visible in File Station, so that's the long way around.

Have you tried mounting in verbose mode? What is displayed?

ImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImage
ggibby
Starting out
Posts: 22
Joined: Sat Nov 19, 2011 2:48 am

Re: [HOW-TO] Map a permanent Windows Network share to File Station

Post by ggibby »

I tried '--verbose' ahead of -o but no change in result - just a new prompt.
Maybe that's not the right switch?

The scope of command info on SSH is widely spread and poorly indexed =0)

-G
User avatar
OneCD
Guru
Posts: 12037
Joined: Sun Aug 21, 2016 10:48 am
Location: "... there, behind that sofa!"

Re: [HOW-TO] Map a permanent Windows Network share to File Station

Post by OneCD »

If you're using BusyBox mount, it usually prefers shortcodes, so try it with '-v' instead of '--verbose'
ggibby wrote:The scope of command info on SSH is widely spread and poorly indexed =0)
SSH is just a protocol to remote access the OS.

The specific commands available once you're in the OS environment can change from device-to-device. It takes time to learn. :DD

I can't advise on your CIFS mount specifics though as I don't use CIFS. So, I'll leave that to the experts.
Last edited by OneCD on Sat Oct 21, 2017 10:11 am, edited 1 time in total.

ImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImage
ggibby
Starting out
Posts: 22
Joined: Sat Nov 19, 2011 2:48 am

Re: [HOW-TO] Map a permanent Windows Network share to File Station

Post by ggibby »

'-v' didn't help either. Grrr...

QTS 4.3.3 claims to have a remote mounting feature via the UI, but it's **.
Not your thing, I know, but still frustrating.

I have a TS412 on the way to be set up as JBOD and move the files off the Windows machines.
May the NAS gods smile upon me and reveal how much easier two QNAP boxes will talk to each other.
User avatar
OneCD
Guru
Posts: 12037
Joined: Sun Aug 21, 2016 10:48 am
Location: "... there, behind that sofa!"

Re: [HOW-TO] Map a permanent Windows Network share to File Station

Post by OneCD »

After you've run your mount.cifs command, have you checked the active mounts?

This can be shown by just typing:

Code: Select all

mount
... with nothing else. The NAS will then display all its current mounted filesystems.

Or you could use:

Code: Select all

df -h
... which has a more organised display.

ImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImage
ggibby
Starting out
Posts: 22
Joined: Sat Nov 19, 2011 2:48 am

Re: [HOW-TO] Map a permanent Windows Network share to File Station

Post by ggibby »

That is very useful - thanks!

The GUI remote mounts actually took,
and they show in SSH, handily.

I have made progress since the morning,
and now need to let it perk through my brain.

Best to stop banging my head against this and go read a book.

No more screen time today. =0)

I appreciate your time and knowledge on this,

-G
User avatar
OneCD
Guru
Posts: 12037
Joined: Sun Aug 21, 2016 10:48 am
Location: "... there, behind that sofa!"

Re: [HOW-TO] Map a permanent Windows Network share to File Station

Post by OneCD »

No worries. :)

ImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImageImage
ggibby
Starting out
Posts: 22
Joined: Sat Nov 19, 2011 2:48 am

Re: [HOW-TO] Map a permanent Windows Network share to File Station

Post by ggibby »

Since discovering that Plex ended support for x19 devices and hid all the .qpkg archives,
I'm experimenting with the native DLNA, which will apparently only find files in /share/,
so the GUI remote mounts aren't visible.

And mount.cifs isn't working, despite no errors.
Thanks to OneCD I can test quickly, and it's just not there.

Could there be something different in the x51 and x53 from my x19?
oyvindo - did this work on your TS-119?

Recognizing some of this could be solved with newer hardware,
my bank account won't allow that.

-G
ggibby
Starting out
Posts: 22
Joined: Sat Nov 19, 2011 2:48 am

Re: [HOW-TO] Map a permanent Windows Network share to File Station

Post by ggibby »

Bottom line,

# mount.cifs //192.168.168.15/m/movies /share/MD0_DATA/Movies -o -rw username=graham,password=<redacted>
does not work on my TS-419P II.

I'll keep bashing away at it, but this seems like a dead end.
Locked

Return to “Miscellaneous”