You are here

Mounting a Windows samba share in Linux a.k.a. how to avoid having to download a shared file in order to access it

Submitted by Druss on Wed, 2007-01-10 01:59

Problem: I've set up Samba on my Linux box and can access my Windows shares fine. However, every time I want to access a file from my Windows share, Linux, difficult motherfucker that it is, downloads the file, stores it in a temp directory and then plays it.. So, if I want to play .. say a 1.4 GB movie, I have to download the entire damn thing across my network to see it.. Not Good Enough.

Solution: The solution is to mount the Windows share locally in Linux (not unlike Map Network Drive in Winblows), and this problem goes away. To accomplish this, the following steps have to be followed:

  • Install smbfs: This package is usually not installed by default.
    sudo apt-get install smbfs
  • Create a directory where you can mount the shared directory. I want to access the MP3 directory from my Windows box on my kubuntu box. So, I just create a directory named mp3 in /media.
    cd /media
    sudo mkdir mp3
  • Now to actually mount the directory, type:
    sudo mount -t smbfs -o username=jubal //10.0.0.7/MP3 mp3
    10.0.0.7 is the IP of my windows box and MP3 is the name of my share. You should now be asked to enter the password to access the share. Do so, and you are done.

If necessary, you can dump the mount information into /etc/fstab to mount the share on every boot.


An update from 11 years later:

smbfs is now deprecated. Use cifs instead. You will very likely need to install the cifs-utils package beforehand for this to work seamlessly. The command now reads:

sudo mount -t cifs -o username=jubal,vers=1.0,uid=1000,gid=1000 //192.168.1.1/MP3 /media/mp3

The other new things are the use of the vers=1.0 option which, in my case, allowed a 2018 version of Kubuntu to mount an NTFS share in an old XP box. The default is 2.1.

The uid and gid is to mount the Windows share in a mount point which is assigned the ownership of the user with the specified uid and gid.