9 June 2008 - 1:49Mounting a Samba Share on Boot
Now that my file server project is out of the way, I needed a way to mount its massive share on my linux servers. I also wanted to keep some home directories on the filer, however when I mounted it, the directory was owned by root and the user wasn’t allowed to write files to it.
To get around this, I started looking into various ways of controlling the permissions. I also wanted this to be mounted during boot, but first I needed to make a mount point.
mkdir /filer
Now I started playing with various methods to mount the share. The best method I was able to find was as follows.
mount //server/share /filer -t cifs -o gid=99,uid=99,dir_mode=0777,file_mode=0777,rw
In the above example, you can see that the share is mounted to /filer using the group id of 99 and user id of 99. On my system, these id’s are owned by the nobody user. Which is basically just a guest account. This will allow everyone to write to the mounted share.
The next step is to have the share mounted during boot up. So I needed to add an entry to the /etc/fstab file. Below is the entry I placed in my fstab file.
//(Servers IP)/filer /filer cifs gid=99,uid=99,dir_mode=0777,file_mode=0777,rw 0 0
Now whenever the server is restarted I can be assured that the share will be mounted with the permissions I wanted. After a quick test reboot I can now see that my share is mounted, and the permissions I wanted are set aswell.
root@myserver ~]# ls -ld /filer drwxrwxrwx 1 nobody nobody 0 Sep 16 23:58 /filer
No Comments | Tags: posts