Project D

Autofs in Gentoo

Attracted to the automount ability that autofs has to offer, I decided to install it in my gentoo box.

Here is the steps that I finally managed to get it to work on my box.

Recompile Kernel

I got custom kernel for my gentoo box and in order for autofs to work I need to enable File Systems -> Kernel automounter version 4 support (also supports v3) . it can be build as module or static in the kernel.

I choose to build it static in the kernel, because if in the future I might need to mount something before init.d loads the kernel module the autofs will works. Well that is just my paranoid thought, I think its perfectly safe to build this as module if you wanted to.

cd /usr/src/linux
make menuconfig
##choose the options and enable the kernel automounter version 4 support##
make all ; make modules_install ; make install
check if everything build fine
reboot

Install the userspace program

Remember what automounter kernel version that you build, if you build the version 4 then you will need to get the userspace program for that version. Mixed version between kernel and userspace will not work.

Mask the portage to get autofs version the same as your kernel (I choose version 4, check yours).

echo >=net-fs/autofs-5 >> /etc/portage/package.use

now install the autofs.

Reminder : Check the version of the autofs and ensure its the same as the kernel.

emerge -va net-fs/auto-fs

Configure it to works

Edit /etc/autofs/auto.master
I edit it to mount it in /home/duckz/Samba with configuration file in /etc/autofs/auto.samba, yours may vary.

# $Id: auto.master,v 1.3 2004/12/09 08:25:48 robbat2 Exp $
# Sample auto.master file
# Format of this file:
# mountpoint map options
# For details of the format look at autofs(8).
#/net   /etc/autofs/auto.net
#/misc  /etc/autofs/auto.misc
#/home  /etc/autofs/auto.home
#mount point           # config file for that mount point
/home/duckz/Samba /etc/autofs/auto.samba

Edit or create /etc/autofs/auto.samba
I use “Entrance” as mount point ( so the final mount point will be /home/duckz/Samba/Entrance), specifies file system for the mount point as smbfs, with credentials (password and username file) in /etc/autofs/auto.smb and the source of the mounted partition is in computer name/ip “192.168.2.2″ share folder “entrance”.

echo "Entrance -fstype=smbfs,credentials=/etc/autofs/auto.smb ://192.168.2.2/entrance" >> /etc/autofs/auto.smb

Edit or create /etc/autofs/auto.smb for samba credentials file. You may not need this if you are using nfs or locally mounted filesystem.

Reminder : For samba, the username and password must be valid in the winbloz machine.
Hint : go to windows explorer, click on the shared drive properties -> tab sharing -> button advanced sharing -> button permissions -> button add -> input box “enter object names….”

Put your username (in my case is duckz)

for the password, the password must be the same as winbloz “duckz” username which is XXXXXX.

echo username=duckz >> /etc/autofs/auto.smb
echo password=XXXXXX >> /etc/autofs/auto.smb
chmod 600 /etc/autofs/auto.smb 

Edit /etc/fstab , you will need to remove all the entries in the fstab for /home/duckz/Samba. autofs doesnt need to use /etc/fstab in fact an entry in fstab that point to the same entry in the autofs will conflict in such way that autofs will fails to load.

Create the mount point

remember to create /home/duckz/Samba directory, as autofs needs it. but DON’T create the subdirectory Entrance, autofs will automatically creates it upon mount.

su duckz
mkdir /home/duckz/Samba
exit

Start the autofs

Cross your tits and armpits, then start the autofs.

/etc/init.d/autofs start

hopefully it will load autofs without error.

After you start the autofs, when you go to the mount point (/home/duckz/Samba) you’ll find out that the directory is empty, why?

This is because autofs will only mount the directory if there is a request / access request occurs, as stupid or strange it may be, the solution is simple, ignore the empty dir and do ACCESS the mount point.

ls -al /home/duckz/Samba/Entrance

now autofs got a command to access the mount point and VOILAA!!! the mount point will exist.

Linking the mount point

This step is purely optional, you can do a symlink pointing to the mount point. I did this because I am lazy to change my freevo configuration, so I just did a symlink to an existing freevo mount point.

ln -s  /home/duckz/Samba/Entrance /home/duckz/Multimedia/Movie 

Hope this guide will help you installing autofs. if not… dont bug me for anything since I write this just as a reminder for myself in case I need to reinstall autofs again

-= end transmission =-

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • LinkedIn
  • Slashdot
  • StumbleUpon
  • blinkbits
  • eKudos
  • Live
  • Share/Save/Bookmark

RSS Fresh Ebuild