Меню Рубрики

Ubuntu mount shared windows folder

Ubuntu Wiki

MountWindowsSharesPermanently

This document 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 document also applies to SMBFS shares, which are similar to CIFS but are deprecated and should be avoided if possible (link).

(This document does not describe how to host the shares yourself, only how to access shares that are hosted somewhere else. For hosting shares, use Samba.)

Prerequisites

We’re assuming that:

    Network connections have been configured properly.

Your local (Ubuntu) username is ubuntuusername.

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.

CIFS installation

Mounting unprotected (guest) network folders

First, let’s create the mount directory. You will need a separate directory for each mount.

Then edit your /etc/fstab file (with root privileges) to add this line:

guest indicates you don’t need a password to access the share,

uid=1000 makes the Linux user specified by the id the owner of the mounted share, allowing them to rename files,

iocharset=utf8 allows access to files with names in non-English languages. This doesn’t work with shares of devices like the Buffalo Tera Station, or Windows machines that export their shares using ISO8895-15.

If there is any space in the server path, you need to replace it by \040, for example //servername/My\040Documents

After you add the entry to /etc/fstab type:

This will (re)mount all entries listed in /etc/fstab.

Mount password protected network folders

The quickest way to auto-mounting a password-protected share is to edit /etc/fstab (with root privileges), to add this line:

This is not a good idea however: /etc/fstab is readable by everyone and so is your Windows password in it. The way around this is to use a credentials file. This is a file that contains just the username and password.

Using a text editor, create a file for your remote servers logon credential:

Enter your Windows username and password in the file:

Save the file, exit the editor.

Change the permissions of the file to prevent unwanted access to your credentials:

Then edit your /etc/fstab file (with root privileges) to add this line (replacing the insecure line in the example above, if you added it):

Save the file, exit the editor.

Finally, test the fstab entry by issuing:

If there are no errors, you should test how it works after a reboot. Your remote share should mount automatically.

Special permissions

If you need special permission (like chmod etc.), you’ll need to add a uid (short for ‘user id’) or gid (for ‘group id’) parameter to the share’s mount options.

Mount password protected shares using libpam_mount (Ubuntu 9.04)

In addition to the initial assumptions, we’re assuming that

Your username and password are the same on the Ubuntu machine and on the network drive.

Edit /etc/security/pam_mount.conf.xml using your preferred text editor.

First, we’re moving the user specific config bits to a file which users can actually edit themselves: remove the commenting tags ( ) surrounding the section called . Save the file when done. With this in place, users can create their own

Troubleshooting

Login errors

If you get the error «mount error(13) permission denied», then the server denied your access. Here are the first things to check:

    Are you using a valid username and password? Does that account really have access to this folder?

Do you have whitespace in your credentials file? It should be password=mspassword, not password = mspassword.

Do you need a domain? For example, if you are told that your username is SALES\sally, then actually your username is sally and your domain is SALES. The fstab entry should read: . username=sally,password=pass,domain=SALES. Or: . credentials=/path/to/file,domain=SALES.

Is the security setting correct? The most common is sec=ntlm, but you can also try the other options listed at the mount.cifs man page. The man page list leaves out the option sec=lanman for some reason, but you should try that one as well (see discussion).

Unprotected network folder won’t automount

I’ve had a situation where an unprotected network folder wouldn’t automount during bootup, but after manually entering «sudo mount -a» was mounted correctly. I solved this by replacing the «guest» option by «username=guest,password=». If anyone has an explanation for this, please leave a comment.

Mount during login instead of boot

If for some reason/etc/rc0.d/S31umountnfs.sh (networking problems for example) the automatic mounting during boot doesn’t work, you can add the «noauto» parameter to your smbfs fstab entry and then have the share mounted at login.

Slow shutdown due to a CIFS/Network Manager bug

If you use Network Manager, and are getting really slow shutdowns, it’s probably because NM shuts down before unmounting the network shares. That will cause CIFS to hang and wait for 60 seconds or so. Here’s how to fix it:/etc/rc0.d/S31umountnfs.sh

Ubuntu 12.04 already runs umountnfs.sh at reboot and shutdown by default (/etc/rc0.d/S31umountnfs.sh and /etc/rc6.d/S31umountnfs.sh) so this is no longer necessary.

CIFS Options Deprecated

Using dmask or fmask in the fstab file produces the following warnings: WARNING: CIFS mount option ‘dmask’ is deprecated. Use ‘dir_mode’ instead. WARNING: CIFS mount option ‘fmask’ is deprecated. Use ‘file_mode’ instead.

Instead use this format: file_mode=0777,dir_mode=0777 . Or in some cases you might need to use file_mode=0777,dir_mode=0777,nounix (see discussion)

Use of tilde in pathnames such as «credentials=

Curiously, using credentials=

/.smbcredentials in fstab didn’t work. I had to use the full path, i.e. /home/username/.smbcredentials

(This is likely because the tilde «

» is only a shell short-hand alias for «$HOME»; it isn’t something recognized system-wide by all programs, especially not in a system file table where the concept of «HOME» doesn’t really exist. -Ian!)

MountWindowsSharesPermanently (последним исправлял пользователь shippj 2020-07-22 01:52:19)

The material on this wiki is available under a free license, see Copyright / License for details.

Источник

How to Mount Windows Share on Linux using CIFS

Posted Nov 23, 2019

On Linux and UNIX operating systems, a Windows share can be mounted on a particular mount point in the local directory tree using the cifs option of the mount command.

The Common Internet File System (CIFS) is a network file-sharing protocol. CIFS is a form of SMB.

In this tutorial, we will explain how to manually and automatically mount Windows shares on Linux systems.

Installing CIFS Utilities Packages #

To mount a Windows share on a Linux system, first you need to install the CIFS utilities package.

Installing CIFS utilities on Ubuntu and Debian:

Installing CIFS utilities on CentOS and Fedora:

The package name may differ between Linux distributions.

Mounting a CIFS Windows Share #

Mounting a remote Windows share is similar to mounting regular file systems.

First, create a directory to serve as the mount point for the remote Windows share:

Run the following command as root or user with sudo privileges to mount the share:

You will be prompted to enter the password:

On success, no output is produced.

To verify that the remote Windows share is successfully mounted, use either the mount or df -h command.

Once the share is mounted, the mount point becomes the root directory of the mounted file system. You can work with the remote files as if they were local files.

The password can also be provided on the command line:

If the user is in windows workgroup or domain you can set it as follows:

For better security it is recommended to use a credentials file, which contains the share username, password and domain.

The credentials file has the following format:

The file must not be readable by users. To set the correct permissions and ownership , run:

To use the credentials file, define it as follows:

By default of the mounted share is owned by root, and the permissions are set to 777.

Use the dir_mode option to set the directory permission and file_mode to set the file permission:

The default user and group ownership can be changed with the uid and gid options:

To set additional options , add them as a comma-separated list after the -o option. To get a list of all mount options type man mount in your terminal.

Auto Mounting #

When the share is manually mounted with the mount command, it does not persist after a reboot.

The /etc/fstab file contains a list of entries that define where how and what filesystem will be mounted on system startup.

To automatically mount a Windows share when your Linux system starts up, define the mount in the /etc/fstab file. The line must include the hostname or the IP address of the Windows PC, the share name, and the mount point on the local machine.

Open the /etc/fstab file with your text editor :

Add the following line to the file:

Run the following command to mount the share:

The mount command, will read the content of the /etc/fstab and mount the share.

Next time you reboot the system, the Windows share will be mounted automatically.

Unmounting Windows Share #

The umount command detaches (unmounts) the mounted file system from the directory tree.

To detach a mounted Windows share, use the umount command followed by either the directory where it has been mounted or remote share:

If the CIFS mount has an entry in the fstab file, remove it.

The umount command will fail to detach the share when it is in use. To find out which processes are accessing the windows share, use the fuser command:

Once you find the processes, you can stop them with the kill command and unmount the share.

If you still have problems unmounting the share, use the -l ( —lazy ) option, which allows you to unmount a busy file system as soon as it is not busy anymore.

Conclusion #

In Linux, you can mount a Windows shared using the mount command with the cifs option.

If you have any questions or feedback, feel free to leave a comment.

Источник

Access Windows 10 Shared Folder from Ubuntu 18.04

I would like to share files between Windows and Ubuntu.

In Ubuntu 16.04 LTS, I could access shared folder on a Windows machine on my local network my navigating to Other locations in Files (Nautilus), accessing the Windows network, and browse. After upgrading to Ubuntu 18.04 LTS, this no longer works for me.

How can I get access to folder shared in Windows 10 from Ubuntu 18.04?

3 Answers 3

There was a change in both Windows 10 and Samba. Some of the details are explained here.

The browse by just clicking isn’t working, but you can get there by entering the shared folder link in the address field. Use the server’s IP address or the computer name for the share. In the example I’m using the IP address of the Windows 10 server:

Use Keyboard shortcut Ctrl + L to type in pathname:

Typing that in the file browser will bring up authorization prompt. Use the credentials from your Windows 10 server. This will display all the available shares. You can then click on the share you want access to.

There are two changes steps you may have to do. Set client max protocol = NT1 for the downward compatibility in the /etc/samba/smb.conf file. Place the entry just below the workgroup = WORKGROUP line.

It should look like this:

Once you have manually accessed the desired share, you can make it easily accessible in the future by bookmarking it. You can do this with the keyboard shortcut: Ctrl + D .

You can easily rename your bookmarks to something friend and meaningful by right-clicking the name that appears in the File Browser’s sidebar.

Install necessary packages:

You may have to install smbclient , which will ensure you have the necessary dependents such as the cifs-utils and the actual /etc/samba/smb.conf file.

On 18.04, I have just had success with the following:

On Ubuntu: Install smbclient and add client max protocol = NT1 to /etc/samba/smb.conf as per L.D. James’ answer (see this post for more info).

On Windows: Create a folder in Windows to share, e.g. named shared . Make sure the folder is shared: I created a new user on Windows, keeping the NewUser name and selected a simple password (I first tried changing the name, but found that change was apparently only skin deep. Perhaps if I had rebooted. ). I logged in with NewUser , then logged back in with my admin account. I activated network sharing on my private network and for the folder specifically (see e.g. this post). Then I right clicked the folder and chose Give access to. , choosing NewUser (you may want additional permissions: see the just linked to post). Under the Sharing tab, the folder now has a network path: //COMPUTERNAME/shared .

Still on Windows: To gain access to the shared folder, I used the IP of the Windows machine instead of the COMPUTERNAME , cf. this.

To find the IP of your Windows machine, right click the network logo, open Network and Sharing Settings and choose Change connection properties . Take note of the IPv4 near the bottom.

In Ubuntu: Finally, open a terminal on you Ubuntu machine and execute

and provide the password for NewUser when prompted.

This mounts the shared Windows shared folder as a folder shared in your Ubuntu user’s home directory.

The command is based on suggestions from here, where there are also suggestions for storing login credentials.

I hope it works. Good luck!

Источник

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *

  • Ubuntu installer usb windows
  • Ubuntu from windows install
  • Ubuntu customization kit для windows
  • Ubuntu cursors for windows 7
  • Ubuntu bootable flash windows