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:

  1. You have a computer running Windows XP (or may be Vista) on your home/office network on a workgroup or domain.
  2. You have another computer running Linux say Debian Linux.
  3. 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:

  1. Debian Linux (4.0) running 2.6.24 kernel with IP address 192.168.0.2
  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.

Error 4: mount: wrong fs type, bad option, bad superblock on //infohighway/drivers missing codepage or helper program, or other error
(for several filesystems (e.g. nfs, cifs) you might
need a /sbin/mount. helper program)

Solution: modprobe cifs

As usual, please leave a comment/feedback if you have any. Comments encourages bloggers to post more and keep their spirits high.

Check out the latest collection of testking EX0-101 questions and testking 642-832 answers prepared to help you pass certification exam. Get highest score in real test using testking 640-863 recourses.

Be Sociable, Share!