Mount Windows SMB/CIFS Share with Linux

I'm setting up virtual machines again. This always means sharing files between host and guest. I basically follow this guide on the Ubuntu Forums, but I tweak it a little bit for permissions reasons. It goes something like this:

1. Install tools to mount a SMB/CIFS share
[code]sudo aptitude install smbfs[code]

2. Make a mount-point
[code]sudo mkdir /h[code]

3. Store credentials some place safe
[code]sudo vim /root/.smbcredentials[code]
and type them in the following format:
username=winusername
password=winpassword
Save and close.

4. Add a line to fstab so that we're mounted automatically
[code]sudo vim /etc/fstab[code]
At the end, add the following:
//netbiosname/sharename    /media/sharename        cifs    credentials=/root/.smbcredentials,iocharset=utf8,file_mode=0774,dir_mode=0774,gid=plugdev,uid=mainuser 0 0
This is where I deviate from the instructions. I use file permissions 0774 instead of 0777. Why? I don't like the would world screwing with my files (though they can poke if they need to). I also change the user-id so that the mounted files are owned by my main user. And I make plugdev the group so that any plugdevs can play with the files too. (This is helpful for daemons that don't run as my main user).

5. Test
Make mount process everything in /etc/fstab
[code]sudo mount -a[code]
Now browse through the mountpoint and see if it worked. Golden? You're done!


Colin

 

Edit:

That was all fine and dandy until my network shares stared dropping and failing to mount with message:

mount error(12): Cannot allocate memory

Yup, its a Windows problem. Tell windows to allocate more resouces for file sharing: http://alan.lamielle.net/2009/09/03/windows-7-nonpaged-pool-srv-error-2017