Thursday, February 18, 2010

Automounting on Linux !!

Let's learn the concept of automounting quickly.
To enable a Samba share to be mounted when a machine boots,
edit the /etc/fstab file to include the following:

//server/share /mount/point smbfs username=[username],password=[password] 0 0

Where server is the Samba server name, share is the Samba share and /mount/point is the directoy on the local machine to mount to. The username and password options are of a valid user on the Samba server who has access to the Samba share you are trying to access.

Edit the /etc/fstab file

LABEL=/ / ext3 defaults 1 1
LABEL=/boot /boot ext3 defaults 1 2
none /dev/pts devpts gid=5,mode=620 0 0
none /proc proc defaults 0 0
none /dev/shm tmpfs defaults 0 0
/dev/hda3 swap swap defaults 0 0
/dev/cdrom /mnt/cdrom udf,iso9660 noauto,owner,kudzu,ro 0 0
/dev/fd0 /mnt/floppy auto noauto,owner,kudzu 0 0
//server/share /mount/point smbfs username=[username],password=[password] 0 0

Substitue [username] and [password] with the appropriate credentials of a valid user on the Samba server.

If you want to use the autofs service to mount SMB shares then follow the instructions below.

Edit the /etc/auto.master file

# $Id: auto.master,v 1.2 1997/10/06 21:52:03 hpa Exp $
# Sample auto.master file
# Format of this file:
# mountpoint map options
# For details of the format look at autofs(8).
/misc /etc/auto.misc --timeout=60

Edit the /etc/auto.misc file

# $Id: auto.misc,v 1.2 1997/10/06 21:52:04 hpa Exp $
# This is an automounter map and it has the following format
# key [ -mount-options-separated-by-comma ] location
# Details may be found in the autofs(5) manpage

cd -fstype=iso9660,ro,nosuid,nodev :/dev/cdrom

samba -fstype=smbfs,username=[username],password=[password] ://server/share

# the following entries are samples to pique your imagination
#linux -ro,soft,intr
#boot -fstype=ext2 :/dev/hda1
#floppy -fstype=auto :/dev/fd0
#floppy -fstype=ext2 :/dev/fd0
#e2floppy -fstype=ext2 :/dev/fd0
#jaz -fstype=ext2 :/dev/sdc1
#removable -fstype=ext2 :/dev/hdd

Issue the command service autofs restart so that the new changes will take effect.

Browsing to the /misc/samba directory should reveal the Samba mount.

No comments:

Post a Comment