HOWTO: Mount a Windows Network Share on Linux using SAMBA/CIFS
Purpose: This post will explain how you can mount a Windows Network Share on to your Linux machine. Note: If you are looking for how to mount a Windows NTFS partition on your local hard drive (as read-write) on to your Linux filesystem this post may not be for you, click here.
Example-Setup and Assumptions:
- You have a computer running Windows XP (or may be Vista) on your home/office network on a workgroup or domain.
- You have another computer running Linux say Debian Linux.
- You would like to mount a shared folder/drive on your Windows computer on to your Linux machine say on “/mnt/” folder so that you can access (read/write) that folder/drive.
My setup:
- Debian Linux (4.0) running 2.6.24 kernel with IP address 192.168.0.2
- Windows XP SP2 machine on a network domain called “home” with IP address 192.168.0.3
Step 1: Share a Windows folder/drive
You will first need to share a folder/drive on your Windows computer so that it can accessed through network. You can do this by right-clicking on the folder/drive that you would like to share and selecting the “Sharing” option. If you don’t know what I am talking about then you can refer to this MS tutorial which explains how to do that.
Step 2: Make sure your Kernel is configured properly
If you are using a standard Linux Kernel from any distribution then it is mostly like already configured. If not then just configure and compile your Linux Kernel with the following options in bold built-in or as a module:
# cat /boot/config-2.6.24 | grep CIFS
CONFIG_CIFS=y
# CONFIG_CIFS_STATS is not set
# CONFIG_CIFS_WEAK_PW_HASH is not set
# CONFIG_CIFS_XATTR is not set
# CONFIG_CIFS_DEBUG2 is not set
# CONFIG_CIFS_EXPERIMENTAL is not set
and
# cat /boot/config-2.6.24 | grep SMB
CONFIG_SMB_FS=y
# CONFIG_SMB_NLS_DEFAULT is not set
Step 3: Install necessary packages on your Linux machine
You will need smbfs package and also an optional smbclient package by giving the following commands:
#apt-get update
#apt-get install smbfs smbclient
The above command will also install samba-common package. If you are asked to enter a workgroup/domain name while the above packages are installed just enter the relevant information, In my case it was “home” as my domain name. You can enter your domain name or a workgroup name depending on your LAN configuration.
Step 4: Check which shares are available for mount
Now before you mount you can also check which shares (folders/drives) are available on your Windows machine that you can mount by giving the following command:
# smbclient -L infohighway -U kushal
where
infohighway = Name (NetBIOS Name) of my computer
kushal = Username on my Windows Machine
Password:
You will get an output similar to this:
Domain=[HOME] OS=[Windows 5.1] Server=[Windows 2000 LAN Manager]
Sharename Type Comment
--------- ---- -------
myshare Disk
IPC$ IPC Remote IPC
mydownloads Disk
ADMIN$ Disk Remote Admin
C$ Disk Default share
Domain=[HOME] OS=[Windows 5.1] Server=[Windows 2000 LAN Manager]
Server Comment
--------- -------
Workgroup Master
--------- -------
From the above output you can see that I have shared folders called “myshare” and “mydownloads” on my Windows XP machine as highlighted in bold letters. This means that I can mount these folders on my Linux machine.
Step 5: Mount the Windows Share
Now the real thing. There are two ways to mount: The traditional SMBFS or the newer CIFS. It seems that CIFS is going to replace SMBFS which will soon become obsolete. I will show you both the methods:
SMBFS Method Command (Old/Deprecated/Not Recommended):
# mount -t smbfs -o username=kushal,password=******** //infohighway/drivers /mnt/
where
kushal = Username on my Windows Machine
******* = Password for the user 'kushal'
infohighway = Name (NetBIOS Name) of my computer
drivers = Windows folder shared on my Windows XP machine
/mnt = Target mount directory on my Linux Machine
CIFS Method Command:
# mount -t cifs //infohighway/drivers /mnt/ -o username=home/kushal,password=*********
where
home = DomainName/Workgroup of your LAN network
Rest of the parameters are same as in SMBFS
Note: If you get any error messages after you give the mount command refer to the “Some typical errors” section below.
Now you can access the contents of the Windows share now by giving the command:
# ls /mnt/drivers
# ls /mnt/
audio INFCACHE.1 network Security storage video
#
Some typical errors:
You might see some typical error messages as follow in case if you missed any steps above:
Error 1: CIFS VFS: cifs_mount failed w/return code = -22
Solution: apt-get install smbfs
Error 2: smbfs: mount_data version 1919251317 is not supported
Solution: apt-get install smbfs
You can see the above error messages (if they do occur) by giving the following command just after you issue the mount command as mentioned in Step 5 above:
# dmesg | tail
Error 3: mount error 13 = Permission denied
Solution: Give the name of your Domain/Workgroup as shown in bold letter in Step 5 when mounting with CIFS method otherwise you will likely get this error message.
As usual, please leave a comment/feedback if you have any. Comments encourages bloggers to post more and keep their spirits high.

Free Email Subscription









July 19th, 2008 at 12:44 am
[...] Why this Blog? It’s Purpose? Blog > Linux > Blog article: Access/Mount a Linux filesystem ext3 on a Windows XP machine over a LAN/Domain network « Mount a Windows Network Share on Linux using SAMBA/CIFS [...]
July 19th, 2008 at 2:02 pm
found your site on del.icio.us today and really liked it.. i bookmarked it and will be back to check it out some more later ..
Reply to this comment
August 12th, 2008 at 2:26 pm
I found your site on technorati and read a few of your other posts. Keep up the good work. I just added your RSS feed to my Google News Reader. Looking forward to reading more from you down the road!
Reply to this comment
August 14th, 2008 at 11:23 am
Your blog is interesting!
Keep up the good work!
Reply to this comment
December 31st, 2008 at 6:35 am
I am using Suse 11.0 and tried to access windows network share via above mentioned cifs command. The command is not mounting shared directory and also not outputting any error.
Reply to this comment
Kushal Reply:
January 5th, 2009 at 7:29 pm
Hi Rakesh,
Can you tell me what error are you getting? Can you output your error messages?
Reply to this comment
Rakesh Rawat Reply:
January 6th, 2009 at 5:38 am
linux-ca7b:/mnt # mount -t cifs -o username=Administrator,password= //192.168.0.163/Dropbox /mnt/manoj/
mount error: can not change directory into mount target /mnt/manoj/
Reply to this comment
Kushal Reply:
January 6th, 2009 at 5:54 pm
Hi Rakesh.
I think I know why you are getting error. It seems that you are using CIFS method but you command looks more like SMBFS method. If you carefully see my blog post I have shown two methods on how to do this. Try this:
# mount -t cifs //192.168.0.163/Dropbox /mnt/manoj/ -o username=Administrator,password=
Let me know if this works or not.
Thank you.
Reply to this comment
February 11th, 2009 at 8:06 pm
LastChance:~# cat /boot/config-2.6.18-6-amd64 |grep CIFS
CONFIG_CIFS=m
# CONFIG_CIFS_STATS is not set
# CONFIG_CIFS_WEAK_PW_HASH is not set
# CONFIG_CIFS_XATTR is not set
# CONFIG_CIFS_DEBUG2 is not set
# CONFIG_CIFS_EXPERIMENTAL is not set
—-= so right away I’m in trouble.
do I need to rebuild the kernel?
Reply to this comment
Kushal Reply:
February 11th, 2009 at 8:15 pm
No you are not. I have a good news for you. You have CONFIG_CIFS=m which is just fine. ‘m’ means that the driver is compiled as module instead of built into the kernel. If you notice in my post I do mention, “following options in bold built-in (Y) or as a module (m):”.
In short you don’t need to recompile the kernel. Btw, are you using a default Debian stock kernel?
Thanks
Reply to this comment
February 11th, 2009 at 8:13 pm
there definitely is confusion here,
as you can see, when I do a the 1st
commandI can see the windows machine
in the workgroup
LastChance:~# smbclient -L LastChance -N
Anonymous login successful
Domain=[WORKGROUP] OS=[Unix] Server=[Samba 3.0.24]
Sharename Type Comment
——— —- ——-
print$ Disk Printer Drivers
data Disk Data
IPC$ IPC IPC Service (LastChance server)Anonymous login successful
Domain=[WORKGROUP] OS=[Unix] Server=[Samba 3.0.24]
Server Comment
——— ——-
AKRODHA
LASTCHANCE LastChance server
Workgroup Master
——— ——-
WORKGROUP LASTCHANCE
LastChance:~# mount -t cifs //AKRODHA/c /WinFS
mount error: could not find target server. TCP name AKRODHA/c not found
No ip address specified and hostname not found
LastChance:~# ping //AKRODHA
ping: unknown host //AKRODHA
LastChance:~#
This is a very new install of Debian, so I
am sure I’ve not hosed this up …yet.
So what’s next?
Larry
Reply to this comment
Kushal Reply:
February 11th, 2009 at 8:30 pm
Ok, once you are able to ping to your Windows machine, try giving the following command:
mount -t cifs //AKRODHA/data /mnt/ -o username=WORKGROUP/,password=*********
i did noticed that in your smbclient command you did not mentioned any username, rather you used a anonymous login. In the mount command you need to use your username that is there on the Windows machine.
Reply to this comment
February 11th, 2009 at 8:14 pm
oh yeah, btw… I also tried the ip
address rather than the computer name, but
I could ping neither?
Reply to this comment
Kushal Reply:
February 11th, 2009 at 8:26 pm
Well if you cannot ping to the IP address of your computer then first you need to solve your network problems. If you cannot ping to your Windows machine using “ping” command, CIFS or SMBFS cannot work.
Check your /etc/resolv.conf file.
Reply to this comment
February 12th, 2009 at 1:24 am
OK , got my ping problem taken care of . Got Mount command to work —
My d: drive on the XP is CD-Rom. I was able to mount and read it.
My C: drive is shared as C. It is marked as readonly for sharing. I was able to mount it. I mounted in /WinFS.
When I tried: # ls -al /WinFS
I got permission denied.
How come? What can I do to fix this.
Thanks
Larry
Reply to this comment
Kushal Reply:
February 12th, 2009 at 1:38 am
I just made one of my Windows share folder as read-only and I was able to an ls -al. All I can think of is to make sure that you added the proper user in the shared folder properties in Windows. The user should be the same one which you are using in your cifs mount command.
Also try restarting your Windows machine.
Good luck.
Reply to this comment
February 15th, 2009 at 9:23 am
Oh man.. Thank you very much for this tutorial. I can do it without any problem, and you really help me…
Enjoy the Day…
Reply to this comment
Kushal Reply:
February 17th, 2009 at 6:25 pm
Hi,
Thank you for your comment. I am glad that it worked for you.
Reply to this comment
February 17th, 2009 at 4:04 am
Tried your tutorial, but get an error message you don’t list. Step 4 works, but at step 5 I do
sudo mount -t smbfs -o username=xxxx,password=**** //aztec/data1 /media/test
and get
mount: wrong fs type, bad option, bad superblock on //aztec/data1,
missing codepage or helper program, or other error
(for several filesystems (e.g. nfs, cifs) you might
need a /sbin/mount. helper program)
In some cases useful info is found in syslog – try
dmesg | tail or so
Same error message if I try CIFS. Trying to access WindowsXP share from Ubuntu. Can you help decipher that?
Reply to this comment
Kushal Reply:
February 17th, 2009 at 4:18 am
The format for CIFS and SMBFS method are different. Also CIFS is now the preferred method: Try this:
mount -t cifs //aztec/data1 /media/test -o username=/xxxxxx,password=*********
I think you are missing the workgroup name from your command. Check what is your Windows workgroup name and use that in your mount command. If that does not work, send me the output of your:
#smbclient -L aztec -U
command.
Also I am assuming that aztec is your Windows machine.
Thanks.
Reply to this comment
March 12th, 2009 at 8:27 pm
[...] would like to access your Windows XP partition on your Linux box over your LAN network then click here. You will require CIFS/SAMBA support in your [...]
April 27th, 2009 at 2:09 pm
very nice guide
steps 1-4 worked just fine for me, however at step 5, I encountered this error :
~$ sudo mount -t cifs //xp_hostname/my_share/ /mnt/ -o username=xp_user%password
mount error: could not find target server. TCP name xp_hostname/my_share not found
No ip address specified and hostname not found
replaced xp_hostname with 192.168.xxx.xxx and it worked
(but hostname/ip resolution worked at step 4, strange…)
any idea concerning this behaviour?
Reply to this comment
Admin Reply:
April 29th, 2009 at 5:14 pm
Hi OuT, thank you for your comment.
Are you sure that you did not make any mistake/typos in Step 5. Usually the hostname itself should work just fine. I myself always use the hostname. Moreover nobody so far has encountered this kind of problem before.
Reply to this comment
OuT Reply:
April 30th, 2009 at 4:35 am
problem resolved, this is simply because I was working on stock VMs and forgot to install “samba” package
you might add in this how-to that “samba” package is of course also required
thanks for your support
Reply to this comment
Admin Reply:
April 30th, 2009 at 8:01 am
I see. In a way you are right that samba package is required but it depends what distro are you using. In Debian the samba package consists of different packages like samba-common, smbclient, etc. Technically one can get away without install the entire samba package and if you are following my tutorial then you only need smbclinet and samba-common.
See here for more details:
http://packages.debian.org/lenny/samba
Reply to this comment
OuT Reply:
April 30th, 2009 at 5:14 am
Ah, I also installed “winbind” package then configured it properly (in /etc/nsswitch.conf, line “hosts: files…”, add “wins” right after “files”)
In fact, it is this one which let me ping Windows box with its hostname.
However I noticed pinging with hostname is significantly slower than with IP : ping duration is the same but hostname resolution take some time, at each ping. Any idea about this performance issue, maybe some caching system disabled?
Reply to this comment
May 25th, 2009 at 5:15 am
Hi Kushal
Thanks for the steps given.
But while I try to run I get this error
#smbclient -L abcd-efg -U pqr
Password:
session setup failed: NT_STATUS_LOGON_FAILURE
Please help.
Reply to this comment
Admin Reply:
May 27th, 2009 at 1:32 am
Do you have the user “pqr” setup on your Windows machine?
Reply to this comment
August 10th, 2009 at 11:46 pm
Hmm, here’s an oddball thing I just discovered. I had to use the -o CIFS method, with usernbame=domain/user,password=$password$ listed but I still got the error 13. Root cause –> Oddball characters in the password!!! I tested this simply by just removing the password= from the command line and then the Windows box asked for password and let the mount occur. (Verified df -k). I don’t think the command line likes passwords with odd symbols like I had in my password (two $ signs).
Reply to this comment
October 21st, 2009 at 3:40 am
If you have special signs in the password take your password in ”
example:
mount -t cifs //hostname/share /lin_mount_point/ -o username=domain_name/username,password=’liN2003!09′
Reply to this comment
February 23rd, 2010 at 6:31 am
I am using this to mount:
mount -t cifs //ccadwin/limst10 /ora/limst10 -o rw,username=WORKGROUP/myuser,password=mypasswd!
It mounts great, I can read the files on the partition, however, I can not write to the partition.
How do I configure to write to the partition?
any ideas
Reply to this comment