How to mount remote windows partition (windows share) under Linux

by nixcraft on April 26, 2004 · 47 comments

All files accessible in a Linux (and UNIX) system are arranged in one big tree, the file hierarchy, rooted at /. These files can be spread out over several devices. The mount command serves to attach the file system found on some device to the big file tree.

Use the mount command to mount remote windows partition or windows share under Linux as follows:

Procedure to mount remote windows partition (NAS share)

1) Make sure you have following information:
==> Windows username and password to access share name
==> Sharename (such as //server/share) or IP address
==> root level access on Linux

2) Login to Linux as a root user (or use su command)

3) Create the required mount point:
# mkdir -p /mnt/ntserver
4) Use the mount command as follows:
# mount -t cifs //ntserver/download -o username=vivek,password=myPassword /mnt/ntserver

Use following command if you are using Old version such as RHEL <=4 or Debian <= 3:
# mount -t smbfs -o username=vivek,password=D1W4x9sw //ntserver/download /mnt/ntserver

5) Access Windows 2003/2000/NT share using cd and ls command:
# cd /mnt/ntserver; ls -l
Where,

  • -t smbfs : File system type to be mount (outdated, use cifs)
  • -t cifs : File system type to be mount
  • -o : are options passed to mount command, in this example I had passed two options. First argument is password (vivek) and second argument is password to connect remote windows box
  • //ntserver/download : Windows 2000/NT share name
  • /mnt/ntserver Linux mount point (to access share after mounting)

See also:

Updated for accuracy on Aug-8-2007, 8:19PM.

Featured Articles:

Share this with other sys admins!
Facebook it - Tweet it - Print it -

We're here to help you make the most of sysadmin work. So, subscribe!

{ 47 comments… read them below or add one }

1 D'Angelo February 2, 2007

I Have two Operating System, Windows XP the other is Fedora how can I make them talk to each other, how can I make them file share?

Reply

2 nixcraft February 2, 2007

D’Angelo,

Is it a dual boot system or networked system?

Reply

3 Nandkishor May 8, 2007

Hi,

I have used dual boot system, using Windows 2001 & Red Hat Linux.
1) How make them to speak or share etch other files.
2) How I login Linux & windows without restarting the computer. There is any utility for this.

Regards,
Nandkishor

Reply

4 nadav May 8, 2007

using -t cifs : File system type to be mount
seams to work better is some cases :-)

example:
mount -t cifs //server/share /mnt –verbose -o user=username

more info:
http://www.die.net/doc/linux/man/man8/mount.cifs.8.html

Reply

5 michael August 2, 2007

I tried this command on my Ubuntu system but got the following error:
mount: wrong fs type, bad option, bad superblock on //server_name/Ubuntu_Backups,
missing codepage or other error
In some cases useful info is found in syslog – try
dmesg | tail or so

I also tried nfs but still no good. I have a windows server 2003 machine I am sharing to the ubuntu box.

Reply

6 baljinder May 14, 2011

hii michael

i do help u,,,u install the nfs-comon utility package… then try it…

Reply

7 martin August 3, 2007

Hi,

i have exactly the same issue michael…
Does anyone know, what the problem is?

thanks a lot,

martin

Reply

8 vivek August 3, 2007

michael / martin,

Use cifs option instead of smbfs (outdated and not supported).

HTH

Reply

9 franco November 28, 2007

Martin, Michael, you must have smbfs installed to run cifs, so

$sudo aptitude install smbfs

Reply

10 adam July 17, 2008

i did a \\\ and din work (nothing happened, it just stucked)

added –verbose and saw some external ip it’s trying to connect to.

in the end, i did \\192.168.0.164\ and it worked cheerfully….

Reply

11 Gerardo Costilla August 21, 2008

Awesome, it worked great from my Virtual PC installation of Suse Linux 10.2. Thank you very much.

Reply

12 Muralidhar September 12, 2008

Hi all,
I have tried the above approach, but it didn’t work. I tried the following approach and it worked

Step 1: # mkdir -p /mnt/ntserver

Step 2: Check what the Windows server is providing with smbclient # smbclient –L -W -U

Eg. # smbclient -L muralidhar12 -W windom -U murali
password:

If the command executes succesfully you will see the name of the shared folder of Windows

Step 3: Mounting the Windows Shared folder
# mount -t cifs : -ousername=,domain=

Eg. # mount -t cifs CORESERVER:F\$ /mnt/temp -ousername=nimda,domain=WINLAB
Password:

If all the steps carried out well, then you will be able to access the share folder.

Step 4: Now every time you restart the system, you have to carry out the Step 3. If you wish you can mount the share folder at startup too. To do this, add the following entry to your /etc/fstab file

MachineName:ShareFolderName /mnt/MountFolderName cifs username=UserName,domain=DomainName,password=Password 0 0

Eg.

TomsComputer:MyShare /mnt/winshare cifs username=tom,domain=work,password=secret 0 0

Reply

13 sampath July 1, 2010

Hi,

I have one shared folder in my remote desktop (windows XP), I am working in linux server through terminal in my pc. I want to mount that folder to linux server. can you help me.

Thanks in advance……

Reply

14 siva October 7, 2011

Thanks a lot. this saved me a bunch of time..

+ Siva +

Reply

15 Raja.E September 19, 2008

I have tried for above apporch.But it didn’t work on my pc.Why because i want mount remote windows(win XP OS) partion ntfs in my local linux(fedora 6.0)pc.Please help me.

My official mail id is resudoss@velankani.com
Personal id is raajaacbe@gmail.com

Reply

16 LH October 7, 2008

Thanks for you tip. it worked like a charm on clarkconnect community edition.
keep up the good work! and keep posting

Reply

17 amitgandhi February 17, 2009

This may useful when any one Got this error like

mount -t cifs //hostname/share /mnt/temp -o username=someuser,password=somepassword
mount error 13 = Permission denied
Refer to the mount.cifs(8) manual page (e.g.man mount.cifs)

Do like this:
=========

mount -t cifs //amit99.indusa1234.com/abc /mnt/ntserver -o username=indusa1234.com/amitgandhi,password=”tost123490″

This will work… Enjoy

Reply

18 frustrated February 19, 2009

thanks amitgandhi ,

my problem was not putting the password in double quotes; wasted hours figuring this out, shees linux needs some decent docs.

Reply

19 G.karthick.,B.E(manamadurai) April 8, 2009

it is very useful to sloved the problems.thanks for all

Reply

20 Jaiprakash April 24, 2009

Dear All,

Please help how to share Windows 2003 Folder and files to a OPENsuse linux11. What is th ecommand. and how to apply. Please help me out.

Thanks to all…

Reply

21 Nathan April 24, 2009

I like the way your censored your password… the first time you referred to it…

Reply

22 Nick October 28, 2009

This topic is discussed extensively at:

The digest is the following.
Win XP/2003 has built-in firewall that restricts access to SMB share ports (TCP 139, 445) by unusual and non-documented way . Win-to-Win connection to those ports is allowed, while Samba-to-Win is disallowed.
Remedy variants:
1) Disable built-in firewall (this is very bad solution)
2) Disable built-in firewall, install “independent” firewall (this is a good solution, but free firewall suites are not available for Win2003 server)
3) Modify rule for built-in Windows firewall using several mouse clicks (I’d recommend it).
For this, (a) open list of firewall exceptions; (b) locate “File and Print Sharing” item in the list of exceptions and click on its line to select this item; (c) press button “Edit…”; (d) select row “TCP 139″; (e) press button “Change Scope…”; (f) select item “Any computer”.
(g) Press OK; (h) repeat steps d-g for “TCP 445″. Save settings. Be happy.

Reply

23 Stephane October 28, 2009

If the Linux server is behind a Firewall, what ports are required to be opened to connect to a remote Windows Drive?

Thinking of tcp port 137 & 139!!!

Thanks for your help!

Reply

24 Vivek Gite October 28, 2009

See Samba: Linux Iptables Firewall Configuration and What ports need to be open for Samba to communicate with other windows/linux systems?

HTH

Reply

25 Rajesh Varma November 4, 2009

Thanks a Lot it worked for me well….
good job simple step to understand :-)

Reply

26 al February 23, 2010

Thank You!! Ive been trying off and on for 2 weeks to get my ubuntu machine to access my windows shares and no luck. Trying the GUI and command line smb connect commands, everything said login failure and/or access denied when I would enter windows credentials. This worked like a charm! As a side note, I was able to setup samba sharing rather quickly and have been able to browse the samba shares from my windows box, but not the other way arround. Not sure what the difference is between the samba GUI and this method, just glad it works (Would love to know why if anyone cares to share).

Thanks,

al

Reply

27 Anonymous May 13, 2010

Thank you very much for your clear instructions on the various mount options.

Do you know the settings to allow a linux mount to go through a windows firewall.
i.e. the setting on the firewall.

Regards

Noel

Reply

28 dee May 14, 2010

i got samba installed at linux, anything to install in windows?

tried that but got error:
mount: wrong fs type, bad option, bad superblock on //MRCM/downloads,
missing codepage or other error
In some cases useful info is found in syslog – try
dmesg | tail or so

dmesg shows:
CIFS VFS: cifs_mount failed w/return code = -22

tried search above error but solution found not working

Reply

29 Jason May 17, 2010

“-o : are options passed to mount command, in this example I had passed two options. First argument is password (vivek) and second argument is password to connect remote windows box”

Hi – I think you need to amend the first argument to “username”, not “password”.
Otherwise great tutorial!
- Jason

Reply

30 Satya June 4, 2010

I got mount with above…command…good.

Reply

31 VicOEM August 18, 2010

Cool, it works (Debian -> //WindowsXP/Share) !
Thank you!

Reply

32 jay September 8, 2010

hello every one
i am install window xp then i create vartual pc in fedora11. how can i mount windows partition in vartual pc? pls help me?

Reply

33 g September 22, 2010

hmmm… I see, the smbfs command is still working here
I’m using Ubuntu Server and everything works fine.

this is the example command i used before
referenced from your articles as well.
[quote]
$> mount -t smbfs //myTargetWindowsIP/aDirectory /home/myOwnLinuxDirectory -o username=windowsUserName,password=windowsPassword
[/quote]

Enter! Done!

great thanks!

but, anyway, is this permanent?
is it at the time we restart the Linux machine,
we need to RE MOUNT it again?

Reply

34 Julio Cesar October 6, 2010

Nice post, it worked, but what I need is to used the shared content on windows as my repo for my ubuntu, as I read that smb protocol isn’t supported in the /etc/apt/sources.list I figure that mountin the filsystem an put in the sources.list as

deb file:///mnt/ubuntu lucid restricted main

but it doesn’t work on apt-update I get this error

Failed to fetch file:/mnt/ubuntu/dists/lucid/restricted/binary-i386/Packages.gz File not found

and some others like this, so how can I use the repository in this way? some ideas?
thanks

Reply

35 Devious October 19, 2010

To all with the following error: CIFS VFS: cifs_mount failed w/return code = -22

You must install samba-client or the kernel will not know the fs type.

Under CentOS/Redhat variants: yum install samba-client

Note: samba (the server) is not the same as samba-client.

Reply

36 prakash February 5, 2011

Thanks , it was useful
I was able to mount my windows Filesystem onto linux.

Reply

37 Parvathy February 9, 2011

Amazing !

Superb and simple command to share a folder on a linux Box from Windows ..

Thanks a lot !!

Reply

38 Sreeram March 23, 2011

Hey, thanks a lot! didn’t know it was this simple to access a windows share on linux.

Reply

39 baljinder May 14, 2011

i have use redhat linux 5 on hyper-v,,then configure the NIS server & create in users..first i wont access user profile every users from window server 2008 create in AD,, i wont my window domain users profile mount at my linux NIS users….am waiting

Reply

40 baljinder May 14, 2011

i have use redhat linux 5 on hyper-v,,then configure the NIS server & create in users..first i wont access user profile every users from window server 2008 create in AD,, i wont my window domain users profile mount at my linux NIS users….

am usesing this command mount -t cifs //ntserver/baljinder -o username=baljinder,password=myPassword /NIS/User/baljinder…but only root user read & wright everything not a baljinder user……pllz tell me any

Reply

41 Eric June 29, 2011

This procedure worked perfectly for me, as I mounted a Win7-exposed share from a Fedora 14 client. Many, many thanks!!!

Reply

42 Alastair Battrick August 17, 2011

I had this problem on CentOS 6:
CIFS VFS: No username specified
CIFS VFS: cifs_mount failed w/return code = -22

Which was happening because mount.cifs could not be found. I resolved this by:
yum install cifs-utils

Reply

43 hari September 8, 2011

I actually tried this in mt linux terminal-

mkdir /mnt/ntserver
mount -t cifs /// -o username=user,password=password /mnt/ntserver

and it didn’t work. Am I missing something here?

Reply

44 hari September 8, 2011

I actually tried this in mt linux terminal-

mkdir /mnt/ntserver
mount -t cifs //serverip/ -o username=user,password=password /mnt/ntserver

and it didn’t work. Am I missing something here?

Reply

45 hari September 8, 2011

**username=Administrator

Reply

46 subbu September 11, 2011

-o : are options passed to mount command, in this example I had passed two options. First argument is ”””’password ”””’(vivek) and second argument is password to connect remote windows box

above line i think its username not password,

Reply

47 Sabyasachi Pramanik January 13, 2012

Hi,
my smb client is windows 7, fews are in the workgroup and fews within domain. I’m able to access smb share from windows 7 client. but not able to access windows 7 share from smb server. I’m using RHEL5.
Using the below command.
# mount -t cifs //servername/sharename /mnt/mountpoint \
-o username=myusername,password=mypassword
Error getting: “error “mount error 110 = Connection timed out”.
please suggest.

Reply

Leave a Comment

You can use these HTML tags and attributes for your code and commands: <strong> <em> <ol> <li> <u> <ul> <blockquote> <pre> <a href="" title="">
What is 14 + 15 ?
Please leave these two fields as-is:
Are you a human being? Solve the simple math so we know that you are a human and not a bot.




Previous post:

Next post: