≡ Menu

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

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.

Tweet itFacebook itGoogle+ itPDF itFound an error/typo on this page?

{ 65 comments… add one }

  • D'Angelo February 2, 2007, 12:40 am

    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?

  • nixCraft February 2, 2007, 3:23 am

    D’Angelo,

    Is it a dual boot system or networked system?

  • Nandkishor May 8, 2007, 7:31 am

    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

  • nadav May 8, 2007, 1:57 pm

    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

  • michael August 2, 2007, 12:32 pm

    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.

    • baljinder May 14, 2011, 10:54 am

      hii michael

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

    • jolster November 10, 2012, 2:56 am

      Use IP address of server, instead of share name. So instead of //ntserver/download, use something like //192.168.24.24/download

      • JC April 3, 2013, 10:30 am

        Thanks a million!!!!

        I had exactly same error and I was not able to find a solution. Then I went through the comment, see your comment and… it works! so simple! like a charm!

        Thanks a lot!

  • martin August 3, 2007, 11:50 am

    Hi,

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

    thanks a lot,

    martin

  • nixCraft August 3, 2007, 2:51 pm

    michael / martin,

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

    HTH

  • franco November 28, 2007, 7:56 pm

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

    $sudo aptitude install smbfs

  • adam July 17, 2008, 1:47 am

    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….

  • Gerardo Costilla August 21, 2008, 5:41 pm

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

  • Muralidhar September 12, 2008, 6:22 pm

    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

    • sampath July 1, 2010, 9:11 am

      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……

    • siva October 7, 2011, 9:52 am

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

      + Siva +

  • Raja.E September 19, 2008, 11:21 am

    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

  • LH October 7, 2008, 6:08 pm

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

  • amitgandhi February 17, 2009, 7:28 am

    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

  • frustrated February 19, 2009, 7:01 am

    thanks amitgandhi ,

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

  • G.karthick.,B.E(manamadurai) April 8, 2009, 7:42 am

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

  • Jaiprakash April 24, 2009, 5:41 am

    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…

  • Nathan April 24, 2009, 9:39 am

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

  • Nick October 28, 2009, 2:51 pm

    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.

  • Stephane October 28, 2009, 7:32 pm

    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!

  • Rajesh Varma November 4, 2009, 3:27 pm

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

  • al February 23, 2010, 5:32 am

    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

  • Anonymous May 13, 2010, 4:07 pm

    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

  • dee May 14, 2010, 7:02 am

    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

  • Jason May 17, 2010, 12:18 pm

    “-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

  • Satya June 4, 2010, 5:27 am

    I got mount with above…command…good.

  • VicOEM August 18, 2010, 10:04 am

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

  • jay September 8, 2010, 7:58 am

    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?

  • g September 22, 2010, 2:54 am

    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?

  • Julio Cesar October 6, 2010, 7:37 pm

    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

  • Devious October 19, 2010, 3:31 am

    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.

  • Oz N November 1, 2010, 3:22 pm

    In my organization we have a windows shared folder that people can drop files too.
    I want to access it from my Debian.
    The Internet is full with guides that show how to do it, but with and .
    In our organization they don’t require a user and pass to access this folder, and the GUI tool of gnome, expects me to type in a user name and pass, but there simply isn’t.

    So I tried with the following command:
    sudo mount -t cifs //iif00/Institut /home/oz/win/

    I get the following error:
    mount: wrong fs type, bad option, bad superblock on //iif00/Institut,
    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

    dmesg tail shows:
    [ 152.030382] CIFS VFS: cifs_mount failed w/return code = -22

    I Installed samba-client via apt-get and restarted the computer, but I still get an error.

    Ideas would be great !
    Thanks in advance.

  • Oz N November 1, 2010, 3:25 pm

    Well, I helped myself via google:

    Solution to “cifs_mount failed w/return code = -22″

    When trying to mount my network drive from campus at home I received the following message in dmesg:
    view source
    print?
    1 CIFS VFS: cifs_mount failed w/return code = -22

    Well it turns out that I needed to have the smbfs package installed. This quickly solved my problem.
    view source
    print?
    1 sudo apt-get install smbfs

  • prakash February 5, 2011, 9:11 pm

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

  • Parvathy February 9, 2011, 11:46 am

    Amazing !

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

    Thanks a lot !!

  • Sreeram March 23, 2011, 10:59 pm

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

  • baljinder May 14, 2011, 11:42 am

    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

  • baljinder May 14, 2011, 11:50 am

    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

  • Eric June 29, 2011, 2:23 am

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

  • Alastair Battrick August 17, 2011, 3:20 pm

    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

  • hari September 8, 2011, 5:57 am

    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?

  • hari September 8, 2011, 5:58 am

    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?

    • hari September 8, 2011, 6:01 am

      **username=Administrator

  • subbu September 11, 2011, 5:04 am

    -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,

  • Sabyasachi Pramanik January 13, 2012, 1:25 pm

    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.

  • Muhammad Kamran April 3, 2012, 6:52 am

    greate job

  • shrirang September 4, 2012, 7:38 am

    +1 to your site! Thanks!

  • siddhesh February 21, 2013, 5:42 am

    Hi Vivek
    Very usefull tip ……
    Thanks a lot

  • Ken March 14, 2013, 8:21 pm

    These mount procedures work for me but after mounting you have be be root to do any thing. Can’t even do an ls without sudo prefacing. Also I can’t chown or chmod, even as root.

    Any ideas?

    Thanks,
    Ken

  • ranjeet May 10, 2013, 5:48 am

    Hi all, I have Windows7 host and Backbox as guest using VirtualBox. I want to Access my Windows D drive in Backbox.

    So, I ran the command on backbox

    root@autobot:/home/ranjeet# mount -t cifs //ntserver/D -o username=ranjeet,password=mypassword /mnt/server

    And output was –

    mount: wrong fs type, bad option, bad superblock on //ntserver/D,
    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

    What should I do?

  • Thirumoorthi August 13, 2013, 10:31 am

    hey i got an error during the following process

    mount error(13): Permission denied
    Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)

    Plz anyone help me

    • Praveen September 3, 2013, 7:22 am

      use the below command:
      mount.cifs //server/share /localfolder -o user=,dom=,pass=

  • annie September 20, 2013, 4:43 am

    Im trying to mount to my share on my windows 7 pc using
    mnt -t cifs //Ipaddress /share name /mnt -o username=domain/administrator.name
    but comes up mnt not command when I use mount -t cifs //Ipaddress /share name /mnt -o username=domain/administrator.name

    displays all the mount functions and want proceed any suggestions

  • K. Newman December 10, 2013, 5:40 pm

    Thanks. Succinct and effective.

  • GR January 2, 2014, 10:10 pm

    Hi,

    Happy New Year!!!

    I am trying to mount my share on win 2003, from zyxel NSA320, and I get message:
    ls: cannot open directory .: Value too large for defined data type

    Does anybody knows what is the problem?

  • Ben Francom January 30, 2014, 5:10 pm

    Thank you Muralidhar!
    I was able to mount a CIFS share from a newer Netapp Filer using those instructions.

  • vinod November 22, 2014, 5:36 am

    I am to mount my share Hard Disk Drive on windows xp through the linux file server

    Please give procedure to share disk drive my client system windows xp .

  • Stan Huang December 26, 2014, 6:19 am

    I installed cifs-utils in my ubuntu 9.04 and use command

    “mount -t cifs //192.168.0.5/rd2 //mnt/samba -o username=rd2,password=,codepage=cp950”, where cp950 is Chinese codepage at Windows.

    It works fine. I did the same at Ubuntu 14.04, it doesn’t work.

    I used command “mount -t cifs //192.168.0.5/rd2 //mnt/samba -o username=rd2,password=,codepage=cp950”, It showed “mount error(22): Invalid argument”.

    I used command “mount -t cifs //192.168.0.5/rd2 //mnt/samba -o username=rd2,password=”, It showed “mount error(13): Permission denied”.

    I used command “”mount -t cifs //192.168.0.5/rd2 //mnt/samba -o username=rd2”, I was prompted to input password. After inputting password, It showed “mount error(13): Permission denied”.

    How come?

  • Gaston February 15, 2015, 12:31 pm

    From a linux box, I mounted a Windows share using cifs.

    The intend was to “locally” use rsync to backup my windows machine. The command line used to mount the Windows drive is something like:

    mount \\192.168.1.74\share /cifs1 -t cifs -o noserverino,iocharset=utf8,ro

    Please also note that the drive attached to the linux box is formatted ntfs.

    When doing a sample backup, rsync was always re-copying the directories (names), but not the files. After looking more closely at the “ls -lh ” output at both ends, I noticed that on the linux side the size of the directory level is always 0:

    TTT-Admin@1080-Router:/tmp/mnt/RT-1080/tmp# ls -lh
    drwxrwxrwx 1 TTT-Admi root 0 Feb 8 12:14 DeltaCopy

    but the size of the directory level on the cifs side was always different from 0:

    TTT-Admin@1080-Router:/cifs1/temp/Rsync-Packages# ls -lh

    drwxr-xr-x 1 TTT-Admi root 8.0K Feb 8 12:14 DeltaCopy

    This difference explains why rsync was always recopying directories, but not recopying the folders(which was correct, folder sizes and time stamps being the same on both ends).

    > rsync -av /cifs1/Temp/Rsync-Packages/DeltaCopy /mnt/RT-1080/tmp/rsync
    -av /cifs1/Temp/Rsync-Packages/DeltaCopy /mnt/RT-1080/tmp/

    Is a directory supposed to “have a size” or not ? What should I do to solve this discrepancy ?

Leave a Comment