Mounting Windows Shares In Linux

I want to access the music collection on our big Windows XP-running game-playing desktop PC from my recycled Linux laptop down in the basement. I found a lot of information on connecting to a Linux file server from a Windows client, but not much on going the other way round. A bit here, and bit there, and this is what I came up with.

First, edit your /etc/hosts file and give the Windows machine a name:

192.168.1.2   pootie

Next, install the samba and smbfs packages using your method of choice.

Create a directory where the share will appear on your local filesystem.

$ sudo mkdir /mnt/music

Edit /etc/fstab and add a line for the mount. Here "pootie" is the name of the machine and "music" is the name of the share.

//pootie/music  /mnt/music  cifs exec,credentials=/etc/cifspw 0 0

Create a password file /etc/cifspw with the login credentials for your Windows account.

username=Jason
password=ImNotGonnaTellYouThat

And secure the file:

$ sudo chmod 600 /etc/cifspw

Giddyup.

$ sudo mount -a

Update: If you're still stuck, check out this page on the Ubuntu wiki for more tips.


Flattr this

Filed under: Home & Family

Following the instructions I get: -

root@tf-intranet:~# mount -a
mount: wrong fs type, bad option, bad superblock on //tf/COMPANYDATA,
missing codepage or other error
In some cases useful info is found in syslog - try
dmesg | tail or so

however if I use

mount //172.16.1.2/COMPANYDATA

all works fine, any idea’s why?

Your computer does not have the samba filesystem installed which is required in order to access the share... enter

sudo apt-get install smbfs

in a console and then retry the stuff above… worked for me...

cheers for the help. its always a struggle when you update a working file at home, the out in the field you find that your laptop has an older version of the file. now, a simple winSCP into my box at home and i'm laughing!

thanks again.

Well written, and to the point. I think I might actually remember it now it’s been put so easily.

thanks mate, worked for me :thumbsup:

It worked fine after I corrected the hosts IP.. ;)

Thanks!

Like you I had found plenty of HOWTOS on going from *nix to Windows but very little about going the other way.

Thanks.
-T

my ubuntu install had a bar at the top with applications, places and systems and if you click on places and then "connect to server" you can specify the parameters to connect to a windows share. very fast and easy :)

love the command line, but fuck the command line, if you know what i mean!

When you use the "Connect to Server" functionality from the "Places" menu, you're right -- it creates a shortcut to the network share. Unfortunately, it's not easily used by many programs. For example, if you're download an MP3 from Firefox and you use the "Save Link As..." menu, you're not able to save your file to that location. Likewise, programs like OpenOffice don't allow for saving files directly to those network locations.

Mounting the share as shown in the above article provides a read/write virtual folder that's mapped directly to the Windows share.

Yes you can, at least in Edgy it works.

The share shows up as an option on the left side of the Save As... dialog (along with the options like "filesystem" and "username"(home).

What you can't easily do with the "Connect to Server" functionality is use your command-line tools to works with the filesystem, which is where mounting it to the local filesystem really comes in handy, it will work seamlessly with any program because it will appear to be just another folder.

Fantastic!

Worked perfectly first time. The only thing I changed was

//pootie/music /mnt/music cifs exec,credentials=/etc/cifspw 0 0

to

//pootie/music /mnt/music cifs exec 0 0

as I don't have a user/pass for my windows shares.

Thanks,
plarge

If you have any trouble mounting with:
mount -t cifs

You might also try:
mount -t smbfs

Usually, both will work, but sometimes only one or the other. If I knew why, I'd say, but I don't...

works very well, thanks for the post...

This code and tutorial is such a life saver, ive been searching Ubuntu forums for weeks! This code works and all you have to do is learn a little coding. Took me two tries to get it to work, and Im a comment newbie running Xubuntu 7.10. I thought it would only work for Ubuntu but there is proof now that it works for XFCE :-)

thanks so much
Jason

just what i was looking for, thanks so much!!!

Great tip!! I've been searching and searching, to no avail, for how to set this up. Though lots of folks try to be helpful, this is the first methodology which has completely worked for me. One question, though. What happens when there is a power failure, or for some other reason the router gets reset, and hands out a whole different set of IP addresses to the computers on the network? The names of the computers don't change, but they get associated with different IPs. Is there a way in Step #1 to make this dynamic by computer name instead of associated to a specific IP?

Thank you very much for writing this up. I've been looking for this for a long time. I'm sorry i don't have a clever or even original comment, but damn it's true.

I have tried doing this for so long...

WOW... just Wow....

I stand in awe.

I followed te instructions to the letter, but when i run the 'sudo mount -a' command i get 'mount error 6 = No such device or address'. Does anyone have any ideas?

I know you did this back in 06 but its still great. Just tried it.

I just installed Ubuntu server, gave it gnome desktop and noticed it won't see my windows shares, so I added all this and it says the address doesn't exist. CentOS 5 was able to see my shares perfectly, but I did not like the lack of repositories (or adding unsupported ones and having to rely on priorities) Not sure what's up =(

Now I can finally run a backup script and save my Ubuntu server files out to an external hard drive which is shared via a Windows network. Thanks!

Nice one! I,ve been trying to sort this for the last 2 hours! Works a treat.. :-)

you use static IPs for servers. If you have a smb share, you have a server and you don't use DHCP.

Absolutely an excellent guide - have used for a long time, come back to each time I flatten my laptop, and works beautifully. For folks using while on Ubuntu, (don't know about other distros) and using wireless, a minor caution: once you enable, unfortunately there'll now be an issue with your shutdown sequence as your wireless card will shutdown before cifs unmounts your Windows share, (thereby making auto cifs umount impossible).

No progress has been made on this issue, (Bug #211631 on bugs.launchpad.net/ubuntu) for at least 6 mths, so after a while, you'll get used to having to force quit for every shutdown/reboot, (by holding down the power button of your laptop for >5 secs, for instance) and/or manually change the shutdown order yourself.

I have reviewed several walkthoughs about mounting Windows SMB shares, and yours was the only one that had worked on the first time.

Thanks!

Found this very useful, thank you so much!!

thank you very much, very clear and helpful guide

10 points.You rule!

i followed the instructions, took about 30 seconds, and mounted.. and it worked beautifully. i was dumbfounded. usually trying to make something work takes a little "doing" if you will, as all machines are different. I dubiously copied some music files over and unmounted. They're playing right now. unreal! lol

you may need to install smbfs , i had to but then it worked fine

apt-get install smbfs

if you get this error:

mount: wrong fs type, bad option, bad superblock on //droboshare_a/Drobo_IV,
missing codepage or helper program, or other error
In some cases useful info is found in syslog - try
dmesg | tail or so

install smbfs i.e. apt-get install smbfs

Thanks, this worked great

Thanks - worked first time, very useful having not done this before.

I used this for accesing my files on a windows computer that is located in my office from home using hamachi instead of samba, all i did was give the hosts file the ip of the computer i wanted to access that was asigned by hamachi and followed the rest of the steps given here. I did get the error message when I did $ sudo mount -a but when i tryed to browse through hamachi I could see my files without a problem :)
A REAL BIG THANKS TO YOU!

Thank You for this helpful info!

Worked great, thanks - didn't help that I got my own server IP address wrong, but I figured it out in the end {;v)

works perfect!

for those new to the terminal however, i think a hint to VIM should be given when referring to 'editing' a file. I know there's an implied understanding, however, if you were trying to figure things out and searching...'edit' would be sort of cryptic.

Set static IPs, or even set up your router to assign a specific IP to a given MAC address. That's what I do. Then I don't need to remember which IP goes to what PC when it's time to reinstall an OS; it's all there in my router's DHCP info.

thanks aloot!!! man.....
I was searching, searchin......
u rocked!

This is the key to the solution I was looking for. Thanks for posting!

Thanks, short and sweet... work great for me

Hello.

I am getting this error:

mount error(5): Input/output error
Refer to the mount.cifs(8) manual page (e.g.man mount.cifs)

Any clue?

getting: mount: unknown filesystem type 'credentials=/etc/cifspw' when i have the same /etc/fstab line as you which is:
//winserver/sharepath /newmount/folder exec,credentials=/etc/cifspw 0 0

any ideas?

ThinkMud

You forgot the filesystem type 'cifs' before exec,.....

Re-read the post to see where it goes.

I am new to Ubuntu. I followed the instructions exactly. When I enter 'sudo mount -a' nothing happens. The terminal looks like this

lthomas@lthomas-laptop:/etc$ sudo mount -a

Once I enter the the command 'sudo mount -a' the command line disappears. Don't know what is going on pls help

New to Linux and I have been trying for the past 2 hrs to do this. Works Great.... Thanks

Thank-you so much for making it that easy!

Very, very good tutorial. Excellent work! -Jason

Using Linux Mint 8

did the mkdir ... new share and then //pootie/music /mnt/music cifs exec 0 0

but only pootie was comming up.

Ran sudo mount -a and received the error message about end of line

sudo apt-get install smbfs, fixed the problem and all is now good.

Surely there could be inclusion at a later date of the network icon on the side location bar for those leaving their windoz world behind, thus reducing the need to manually intervean....

Thanks again
mags

Thank you very much! It worked like a charm under Ubuntu 10.04 Server ;)

I am Jason Perkins (starkos), the founder of Industrious One. I'm yammering on about life as an indie, getting things done, finding inspiration and, eventually, creating the big audacious stuff.

projects:


categories: