Mount a NAS device at startup in Ubuntu (8.04)
I have made the move to Ubuntu Hardy Heron, and a painless experience it was too. My only problem came when I tried to mount my NAS device using my previous method, which I used to use for Ubuntu 7.10, and it wouldn’t mount. I kept recieving this error:
mount error 20 = Not a directory
After a bit of Googling, it would appear that the ’smbfs’ is deprecated and that users should now use ‘cifs’.
As such…
How to automatically mount a NAS device at startup in Ubuntu Hardy Heron
First, using the console get the prerequisites for the samba file system:
sudo aptitude install samba smbfs
I have two folders on my NAS device which I wish to mount on startup; these are, ‘music’ and ’svn’. You should replace ‘music’ and ’svn’ with the names of the folders you wish to mount. Therefore, we next need to create mount locations for these folders. I’ll be using my home directory (/home/harris/) to create my mount points, change these as appropriate:
mkdir /home/harris/SVN
Note: I didn’t need to create a ‘Music’ folder because Ubuntu creates one automatically.
Now it’s time to edit our fstab file. Better make a backup first in case it all goes tits up:
sudo cp /etc/fstab /etc/fstab_bk sudo gedit /etc/fstab
Now we need to add some new entries to the fstab file. My Ubuntu username is ‘harris’ and the IP address of my NAS device is 192.168.2.185. You should obviously change ‘harris’ to your own username and change the IP to the IP of your NAS device and also change the name of ‘MUSIC’ and ‘SVN’ to the folders you wish to mount. Add the following lines to the end of your fstab file:
//192.168.2.185/SVN /home/harris/SVN/ cifs nounix,uid=harris,gid=harris,file_mode=0777,dir_mode=0777 0 0 //192.168.2.185/MUSIC /home/harris/Music/ cifs nounix,uid=harris,gid=harris,file_mode=0777,dir_mode=0777 0 0
Save the changes and close gedit.
Finally, lets reload fstab
sudo mount -a
Your NAS device folders should now be mounted.
It would seem, however, that Ubuntu has had a long standing BUG which causes a delay in shutting down. It appears that the network is shutdown before the samba shares are unmounted causing the following error when you shut down your Ubuntu box (a fuller explanation can be found here):
CIFS VFS: no response for cmd 50
The fix is simple, however; we need to create two symbolic links to the umountnfs.sh script.
sudo ln -s /etc/init.d/umountnfs.sh /etc/rc0.d/K15umountnfs.sh sudo ln -s /etc/init.d/umountnfs.sh /etc/rc6.d/K15umountnfs.sh
You should now have error free shutdowns.
How to manually mount a NAS device in Ubuntu Hardy Heron
First, using the console get the prerequisites for the samba file system:
sudo aptitude install samba smbfs
I have two folders on my NAS device which I wish to mount; these are, ‘music’ and ’svn’. You should replace ‘music’ and ’svn’ with the names of the folders you wish to mount. Therefore, we next need to create mount locations for these folders. I’ll be using my home directory (/home/harris/) to create my mount points, change these as appropriate:
mkdir /home/harris/SVN
Note: I didn’t need to create a ‘Music’ folder because Ubuntu creates one automatically.
Next, I run the following commands to mount my folders:
sudo mount -t cifs //192.168.2.185/MUSIC /home/harris/Music -o nounix,uid=harris,gid=harris,file_mode=0777,dir_mode=0777 sudo mount -t cifs //192.168.2.185/SVN /home/harris/SVN -o nounix,uid=harris,gid=harris,file_mode=0777,dir_mode=0777
Note: This is still prey to the Ubuntu BUG listed above.
15 Comments so far
Leave a reply

[...] FOR UBUNTU HARDY HERON (8.04) SEE THIS [...]
Tried to follow exactly but get asked for a password - entered password associated with username (i.e. equivelent of your harris) then error comes up. What password should this be? Any ideas?
mount error 13 = Permission denied
Refer to the mount.cifs(8) manual page (e.g.man mount.cifs)
I am having the same issue as Colin. I know that I am a newbie and this is probably a newbie mistake on my part but I sure would appreciate some help. Thanks in advance.
Same mount error 13 here. Im using a Lacie Ethernet Disk which has separate shares defined but also set up with its own user access with a separate set of user names and passwords. Ive set up an NAS username/passwd that is exactly as my ubuntu login/passwd, but to no avail. Will keep searching for a solution.
Ahh! Not 5 minutes after last post, found the key to mounting a “password protected share”. You need to add the following to the options string of the fstab entry.
,username=[shareusername],password=[sharepassword]
where info in the brackets is replaced with your specific info.
Mounted up perfectly after this short addition. Dont like my password hanging around out there like that, but dont know what to do … yet.
If you don’t want your password hanging out there, replace
,username=[shareusername],password=[sharepassword]
with
,credentials=/path/to/credentials.file
where credentials.file has
shareusername
sharepassword
and you can make credentials.file only readable by root.
Never mind. The credentials= bit didn’t work. I thought I had tested it, but I now I see that it doesn’t work. Yes, the only way I’ve managed to get the mount to work is to include the username and password in /etc/fstab, something I’d prefer not to do.
This helped. Thank you.
//192.168.2.254/SHARE /media/NAS cifs nounix,uid=stijn,gid=stijn,file_mode=0777,dir_mode=0777,credentials=/home/stijn/.verstoptpaswdje 0 0
The line above is what I’ve put in /etc/fstab to mount my LaCie Ethernet Big Disk at startup.
In .verstoptpaswdje, I wrote
username=
password=
Changed the permissions of .verstoptpaswdje with
chmod 600 .verstoptpaswdje
This way it is only me who can read and write to it.
Works perfectly for me.
Good luck
Apparently sth went wrong in the post above…Retry
In .verstoptpaswdje, I wrote
username=[YourNASUsername]
password=[YourNasPassword]
@stijn, thanks for your comment. It would seem that different NAS drives act differently. Some people have had success using credentials, others have had success adding the password to the mount command in fstab. It would seem that if one way doesn’t work try the other.
Hi,
Many thanks for the above. I can get my NAS to mount bu using the manual method but even with the entry in the fstab file it will not mount at boot.
Am wondering if the fstab executes before my wireless connection is up and running.
Any help in getting it to connect automatically would be fantastic
Colin
@Colin
If you are using an encrypted wireless connection (WEP etc), you will have stored a password that is only accessed once the desktop is loaded. As you have said, fstab is loaded prior to this. What may work is adding the manual command to your start up sessions.
I am trying to mount my NAS drives and I keep getting the same error as everyone else (error 13: permission denied). The thing is, I have no user or pass for my NAS drives. What do I do?
Thanks! your post worked. I mounted my DNS-321 on xubuntu 9.10 using your method and that worked! i used empty for user id i.e. uid=,gid=, and that worked. BTW, your anti-spamming image gen deters people from leave the comment (too pessimistic, 0 and o, 1 and I etc are used) as this is my 7th try to leave a comment!