bino oetomo
2011-Aug-13 06:59 UTC
[Samba] use autofs to mount spesific to user home directory
Dear All My box is an Ubuntu Maverick I want to have 1. User with username as : binosmb, 2. that have home directory at the local box at /home/binosmb, 3. and all cifs mountpoint will go at /home/binosmb/network, 4. So that if the server have share named "produksi" it will mounted to /home/binosmb/network/produksi and my samba server is http://www.turnkeylinux.org/fileserver run on VirtualBox Ok, here is my steps (on my box) A. Testing samba username (produksi01) and password (1234) to mount to my own (/home/bino/mysmb) directory bino at bino-desktop:~$ sudo mount -t cifs //192.168.232.2/produksi mysmb -o username=produksi01,password=1234,rw,uid=bino bino at bino-desktop:~$ pwd /home/bino bino at bino-desktop:~$ more mysmb/produksi.txt hello world bino at bino-desktop:~$ Notes : Looks like the samba server is fine B. Create user "binosmb" with passwd 1234 bino at bino-desktop:~$ sudo useradd -m -U binosmb bino at bino-desktop:~$ sudo passwd binosmb Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully bino at bino-desktop:~$ ls -la /home/binosmb/ total 24 drwxr-xr-x 2 binosmb binosmb 4096 2011-08-13 12:59 . drwxr-xr-x 6 root root 4096 2011-08-13 12:59 .. -rw-r--r-- 1 binosmb binosmb 220 2010-08-11 02:58 .bash_logout -rw-r--r-- 1 binosmb binosmb 3353 2010-08-11 02:58 .bashrc -rw-r--r-- 1 binosmb binosmb 675 2010-08-11 02:58 .profile -rw-r--r-- 1 binosmb binosmb 1817 2010-08-15 22:13 .Xdefaults C. Editing /home/binosmb/.auto.smb bino at bino-desktop:~$ sudo pico /home/binosmb/.auto.smb bino at bino-desktop:~$ sudo chown binosmb:binosmb /home/binosmb/.auto.smb bino at bino-desktop:~$ ls -la /home/binosmb/ total 28 drwxr-xr-x 2 binosmb binosmb 4096 2011-08-13 13:03 . drwxr-xr-x 6 root root 4096 2011-08-13 12:59 .. -rw-r--r-- 1 binosmb binosmb 128 2011-08-13 13:06 .auto.smb -rw-r--r-- 1 binosmb binosmb 220 2010-08-11 02:58 .bash_logout -rw-r--r-- 1 binosmb binosmb 3353 2010-08-11 02:58 .bashrc -rw-r--r-- 1 binosmb binosmb 675 2010-08-11 02:58 .profile -rw-r--r-- 1 binosmb binosmb 1817 2010-08-15 22:13 .Xdefaults bino at bino-desktop:~$ more /home/binosmb/.auto.smb produksi -fstype=cifs,file_mode=0644,dir_mode=0775,uid=binosmb,credentials=/home/binosmb/.credentials://192.168.232.2/produksi D. credentials file bino at bino-desktop:~$ ls -la /home/binosmb/ total 32 drwxr-xr-x 2 binosmb binosmb 4096 2011-08-13 13:11 . drwxr-xr-x 6 root root 4096 2011-08-13 12:59 .. -rw-r--r-- 1 binosmb binosmb 128 2011-08-13 13:06 .auto.smb -rw-r--r-- 1 binosmb binosmb 220 2010-08-11 02:58 .bash_logout -rw-r--r-- 1 binosmb binosmb 3353 2010-08-11 02:58 .bashrc -rw-r--r-- 1 binosmb binosmb 39 2011-08-13 13:12 .credentials -rw-r--r-- 1 binosmb binosmb 675 2010-08-11 02:58 .profile -rw-r--r-- 1 binosmb binosmb 1817 2010-08-15 22:13 .Xdefaults bino at bino-desktop:~$ sudo cat /home/binosmb/.credentials username = produksi01 password = 1234 E. Here is my /etc/autofs.master bino at bino-desktop:~$ more /etc/auto.master |sed -e '/^#/d' /home/binosmb/network/ /home/binosmb/.auto.smb --timeout=60 +auto.master F. Ok, lets try the autofs service bino at bino-desktop:~$ sudo service autofs start autofs start/running, process 28739 G Check for mounts bino at bino-desktop:~$ su binosmb Password: $ cd $ pwd /home/binosmb $ ls network $ ls -l total 0 drwxr-xr-x 2 root root 0 2011-08-13 13:38 network Note : Looks loke the /home/binosmb/network is autogenerated by autofs $ cd network $ ls $ Note : I wis I have "produksi" sub directory there under /home/binosmb/network , but it's not there $ mount -l /dev/sda1 on / type ext4 (rw,errors=remount-ro,commit=0) proc on /proc type proc (rw,noexec,nosuid,nodev) none on /sys type sysfs (rw,noexec,nosuid,nodev) fusectl on /sys/fs/fuse/connections type fusectl (rw) none on /sys/kernel/debug type debugfs (rw) none on /sys/kernel/security type securityfs (rw) none on /dev type devtmpfs (rw,mode=0755) none on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620) none on /dev/shm type tmpfs (rw,nosuid,nodev) none on /var/run type tmpfs (rw,nosuid,mode=0755) none on /var/lock type tmpfs (rw,noexec,nosuid,nodev) binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,noexec,nosuid,nodev) gvfs-fuse-daemon on /home/bino/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev,user=bino) Just incase the utofs have "ondemand" behavior $ echo "test this" >~/network/produksi/myfile.txt sh: cannot create /home/binosmb/network/produksi/myfile.txt: Directory nonexistent Note : yup .. I thing the mounting process did not work So , kindly please give me your enlightmen on what/how to look/edit/fix Sincerely -bino-