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

Comments

Thanks!

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

Thanks alot

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

for he new folks

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.

Very Helpful

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

Yes

Thank You for this helpful info!

I used this for accesing my

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!

Thanks - worked first time,

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

Thanks, this worked great

Thanks, this worked great

...

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

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

apt-get install smbfs

if you get this

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

10 points.You rule!

10 points.You rule!

many thanks

thank you very much, very clear and helpful guide

Truly an excellent guide

Found this very useful, thank you so much!!

Thanks Your Walk Through Worked The First Time

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

Thanks!

Excellent Guide, but a warning for thereafter...

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.

Nice one! I,ve been trying

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

Excellent!

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!

Thanks so much

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

Not working

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 =(

I followed te instructions

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?

Wow... just Wow...

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.

DHCP?

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?

you use static IPs for

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

Exactly.

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.

just what i was looking for,

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

Thanks so much

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

Works... thanks

works very well, thanks for the post...

also try with type=smbfs...

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

Mounting Windows Shares In Ubuntu

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

connecting to windows share from ubuntu linux box

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!

Yeah, but you can't "Save As..." Into That Shortcut

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.

Actually...

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.

This is just what I was looking for.

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

Thanks.
-T

Great work!

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

Thanks!

Brilliant - Many Thank yous

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

Nearly works

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

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

thanks mate, worked for me

thanks mate, worked for me :thumbsup:

cheers for the help. its

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.