How to mount a windows/samba windows share under Linux?
Under Linux (Ubuntu 12.04) I want to mount a windows share / windows partition named
//winsharedon the network. I do not know the IP or anything else.
On one Ubuntu system, I am able to mount a directory with
mount //winshared/mypath /mnt/win
while on one other Ubuntu system the exact same command just gives
mount error: could not resolve address for winshared: Unknown error
Network settings seem to be same on both systems, and I installed
samba(the latter with errors). Do I need to instal something else? Do I need to configure something? How to find out the crucial differences between both systems to get the same mount work on both systems?
When I use
smbclientto connect to the windows partition/share/whatever, it works on the first system but not on the other system. The error is:
Connection to winshared failed (Error NT_STATUS_BAD_NETWORK_NAME)
Following this tutorial I installed
cifs-utils, but the
mountcommand from above still gives the same error, which is NOT described in the tutorial.
I also have an entry in
//winshared/mypath /mnt/win cifs uid=alexander,credentials=/etc/samba/wincred 0 0
with the file
/etc/samba/wincredidentical to a same file on the system the mount works. The md5sum of both files are identical. Therefore, an error regarding credentials can be excluded.
See the tutorial on the Ubuntu Wiki: https://wiki.ubuntu.com/MountWindowsSharesPermanently
I have updated the question; I posted the line of fstab, and I have verified the credential file is correct.
I would get this working from the command line 1st, putting the line in /etc/fstab is just making it more complicated to debug it to start. If you can't mount from the command line then it's something else. I use this everyday: `mount -t cifs -o rw,netbiosname=serv1,credentials=/etc/creds.txt //192.168.1.1/somedir /mnt`
Are both systems on the same network? Does it work if you use winshared's IP instead of the name?
Does this directory exist? `/mnt/win`. Also check it's permissions too. Most users can't do anything under `/mnt`.
Become root and do these commands. `sudo -i`. Also add the switch `--verbose` to the mount command.
I tried: `sudo -i mount -t cifs -o uid=alexander,credentials=/etc/samba/wincred //winshared/mypath /mnt/win` but get the same error again.
What exactly do you mean by that? I do not understand. Do you mean to add it to `/etc/fstab`?
No please post the actual mount command that you're running from the terminal. Similar to the one that I posted. You are trying to mount it that way now, correct?
`mount -t cifs -o rw,netbiosname=serv1,credentials=/etc/creds.txt //192.168.1.1/somedir /mnt`
To just get it to work I try it on the command line. When the mount works, I plan to add it to `/etc/fstab`. Here is the command again: `sudo -i mount -t cifs -o rw,netbiosname=serv1,uid=alexander,credentials=/etc/samba/wincred //winshared/mypath /mnt/win' although I do not unerstand what `netbiosname=serv1` stands for. Anyway, error again.
There MUST be a very easy solution, as this works fine on a different machine with SAME operating system in the SAME network. Some package is missing or I need to reboot or start a service or something. it HAS to be something easy. But I do not see it
Agreed, but don't let perceptions fool you. There are a multitude of ways that things that look identical can be different. We'll figure it you, and it will be something silly no doubt, but you have to debug things this way to get to the root cause 8-)
netbiosname=serv1 is what name you want to present yourself as to the server when mounting. It shouldn't matter.
I am able to mount the windows share with its IP addres. This finally works!! Thanks for you help so far, but I think I will give up to solve the mystery of why the name cannot be resolved.
Either you have name resolver issue (which you can check by e.g. pinging the host winshared from your Ubuntu host) or smbfs module is not loaded.
You might have to install smbfs first with
apt-get -y install smbfsand then insert the module with
modprobe smbfs, but after that you should be good to go with
mount -t smbs.
What you're looking for is
mount -t smbfs -o username=<your_username>,password=<your_password> //server/share /mountpoint.
`smbfs` is installed, but a `modprobe smbfs` returns `FATAL: Module smbfs not found.` Do I need to start `smbfs` first? If so, how? How to make it start automatically after a reboot?
@Alex - see this Ubuntu tutorial, it has everything you need: https://wiki.ubuntu.com/MountWindowsSharesPermanently
Necro or future travelers. smbfs is missing on new systems. Use sudo apt-get install cifs-utils instead. And if that's so, then the 'modprobe smbfs' also wont work. So this answer doesn't work on new systems.
FWIW: On Ubuntu 16 client, the suggested answer did work for me if I simply omitted the "-t smbfs" flag.
On Ubunut 18.04, I skipped installing smbfs and just used `-t cifs`. Also, you can omit the password argument if you're running interactively as mount will ask you for your password.
I'm using a BeagleBone Black running Debian 4.9 and, due to it's limited storage capacity, I needed to mount a remote folder hosted on a Windows 10 desktop. (I know this is probably not the best from a system design standpoint, but business needs often leave little room for that.) So, having to improvise, a mounted remote folder is what I came up with.
After running into many, many problems attempting to mount a Windows 10 shared folder, here's my solution, so that others can hopefully benefit from my experience.
Windows 10 "Remote" Host
- Enable SMB1.0/CIFS File Sharing Support in Windows Features (details).
- Start the Windows NetLogon service.
- Enable Sharing on the folder you want to share.
Debian Linux Client
Install support packages:
sudo apt-get install smbclient sudo apt-get install cifs-utils
Create target directory to mount remote share:
sudo mkdir -p /mnt/my_mount_dir
Mount remote folder:
sudo mount -t cifs -o "domain=MYDOMAIN,username=MyUserName,password=myPas$werd,sec=ntlm" //(your windows host ip)/(your remote share name) /mnt/my_mount_dir
UPDATE: After updating my local install of Debian to version 6.3, my
mountcommand broke requiring me to add the
versoption to specify SMB1:
sudo mount -t cifs -o "domain=MYDOMAIN,username=MyUserName,password=myPas$werd,sec=ntlm,vers=1.0" //(your windows host ip)/(your remote share name) /mnt/my_mount_dir
SMB1 is outdated, and you really should try to avoid using it where possible. If you include `vers=2.1` in the `mount` options you'll get SMB 2. You'd also be better off using `credentials` instead of `username` and `password`. And you may not need the `sec=ntml` after all that.
@roaima Thanks for the tips, but I'm stuck using the old stuff. Thanks for fixing the code formatting as well. It wasn't letting me put the code between the list items.
`mount` didn't break; it moved to using SMB2 or possibly 3. SMB1 has been deprecated for well over ten years and you shouldn't still be using it.
@roaima That's good to know, but unfortunately Windows 10 appears to only support "SMB1.0/CIFS". Plus this is for a private network, so I'm not overly concerned about security.
Windows 10 supports SMB2 and SMB3. You had to install a support package to allow it to fall back to SMB1.
@roaima I'm getting `error 2 (No such file or directory) opening credential file` when using `credentials=` but the file exists and has `rw` permissions for user, group and owner. Do you know what could be wrong?
Check that winbind is installed; then, in your
/etc/nsswitch.conffile, there must be
winslisted in the
hosts: files wins dns
There may be other modules listed, depending on what packages are installed on your system.
Tried this solution yesterday on Ubuntu 12.04 64bit and it worked great. Thanks. Today I'm doing the same on Ubuntu 12.04 32bit and it fails, strange.