Anyway, as good (or quite frankly brilliant) as the Pi is, the capacity of an SD card isn't going to go far; so connecting to my trusty NAS drive (e.g. shared folder) was going to be a neccessity and as I was going to be using it a lot, automatically mounting it when the Pi started was also needed.
I was going to be need Samba to connect to my NAS, which can be installed using:
Install/Update Samba
(using Debian Squeeze)
Smbfs is required and while smbclient is not, its a useful tool that I thought I might need in the future.
sudo apt-get install smbfs smbclient
(using Raspian)
Samba is already installed and smbfs has been depreciated in wheezy.
(using Raspbmc)
Samba is already installed but I needed to installed cifs-utils in order to mount my NAS drive.
sudo apt-get install cifs-utils
Make a directory to mount your NAS too
I choose to put it in the pi user's home directory using the structure /home/pi/server/share:
cd /home/pi
mkdir myNAS
cd myNAS
mkdir myShareEdit fstab file
I needed to edit the fstab file to mount the NAS drive at startup:
sudo nano /etc/fstab
I added the following line to the bottom of the file:
//myNAS/myShare /home/pi/myNAS/myShare cifs username=your_username,password=your_password,workgroup=your_workgroup,users,auto,user_xattr 0 0
And saved the changes.
WARNING - this will mean your username & password is stored in plain text viewable to all on the device, if this is going to be a problem you can use a credentials file, see http://anothersysadmin.wordpress.com/2007/12/17/howto-mount-samba-shares-in-fstab-using-a-credential-file/
Test
I tested the change by mounting the NAS drive using the command:
sudo mount -a
I then navigated to the mount directory and successfully retreived a directory listing from my NAS:
cd /home/pi/MyNAS/MyShare
ls
Success!
Reboot
To be double sure, reboot and make sure your NAS is connected:
sudo shutdown -r now
This comment has been removed by the author.
ReplyDeleteHi there,
ReplyDeletefirst of all thanks for your tutorials...they are really useful!
I'm trying to mount my WD MYBOOKWORLD on the Raspberry, but I'm facing some issues...
My NAS is on 192.168.1.101, so the line added on /etc/fstab is:
//192.168.1.101/PUBLIC/backup_raspberry /mnt/NAS username=USERNAME,password=PASSWORD,workgroup=WORKGROUP,users,auto,user_xattr 0 0
Then I try to mount it, but I'm having this error:
mount: unknown filesystem type 'user_xattr'
Any suggestion on that?
Regards
Thank you for a great tutorial.
ReplyDeleteOnly thing I want to add, on mine I didn't have write permissions for the shared folder/files. I added....in the fstab statement
file_mode=0777,dir_mode=0777,
Regards, Sofaman
Great tip, thanks
DeleteHey Nigel I tried this and it comes with an error,
DeleteOption 'file_mode0777' requires a numerical argument
Any ideas about how to fix this?
Please advise
Hi, thanks for the tutorial. When I type sudo mount -a it asks for my password but then after a pause I'm told "Mount point 0 does not exist". I'm not really sure what the mount point refers to so I'm bereft of ideas to fix it. Can you help?
ReplyDeleteThanks
Its not an error ive come across before. Its odd that its asking you for your password, it shouldnt if its in the fstab correctly. Id check there first and make sure the username and password are correct.
DeleteThanks, I'll try that
DeleteAny solution to this? I get the same password prompt and then same error but the file system actually mounts, it's just read only... :( Any help?
DeleteI'm getting the same error, but without it asking for my password. Any advice?
DeleteIt suggests you have got an error in your /etc/fstab file, like its badly formatted, make sure there is no odd characters or line breaks in it and the that mount point you create i.e. the directory exists, remember its case sensitive too. If you send me the contents of the fstab file im happy to have a look.
DeleteI had the prompting for the password issue. I wound up adding the following to 1 line:
ReplyDelete//myNAS/myShare /home/pi/myNAS/myShare cifs username=your_username,password=your_password,workgroup=your_workgroup,users,auto,user_xattr 0 0
I'm pretty much a noob at command line, but I got this to work. You just have to remember to change //myNAS/myShare, your_username and your_password in the fstab to what those values for the device are. When you're done your fstab additions should look something like this:
ReplyDelete//192.168.xxx.xxx/myLibrary /home/pi/myNAS/myShare cifs username=JoeBob,password=12345,workgroup=Workgroup,users,auto,user_xattr 0 0
Thanks for the help man. I'm happily streaming music from my Nas through my Pi! Cheers!
ReplyDeleteHi! It's a good guide. I try it nce, and it works... But I need to re-install my raspbmc, and now it doesn't work...
ReplyDeletei get this message:
mount error(13): Permission denied
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
in my fstab:
//192.168.16.40/public/ /media/NAGYFEHER(this is the name of NAS) cifs username=my_username,password=my_password,workgroup=MSHOME,users,auto,user_xattr 0 0
what's the problem?
I try it, with "admin" password too...