Introduction
我已在Windows 7主机上的虚拟化VMware Workstation 9会话中以Guest虚拟机的身份运行Ubuntu 12.04。 Windows计算机通过CIFS和Ubuntu计算机与Ubuntu计算机共享一个文件夹. This setup has been done on a Ubuntu Jaunty 9.04 workstation, but it should work on any later version. Packages Installation. First thing to do is to install smbfs & automount packages: # sudo apt-get install cifs-utils autofs. Automount configuration. Moreover, autofs will actually spawn an automount process, which will THEN call mount and/or umount, and as far as I can see (checking the strings in /usr/sbin/automount), it doesn't look like it runs /bin/mount or /bin/umount, rather it performs a system call into the kernel to have the filesystems mounted.
Autofs also referred as Automount is a nice feature in linux used to mount the filesystems automatically on user's demand. There are two ways available in linux by which we can mount the file system i.e. /etc/fstab and another one is Autofs. /etc/fstab is used to mount the filesystems automatically at when system bootsup and Autofs is also doing the same thing.
Difference Between /etc/fstab and Autofs (AutoMount)
You might thinking that if both are doing the same thing then why to use Autofs (Automount) instade of /etc/fstab. and what is the difference between /etc/fstab and Autofs. Here I am going to explain you what is the exact difference between /etc/fstab and Autofs.
As we know that /etc/fstab is used for permanent mounting of file systems but it will be useful only if you have less mount points connected to your /etc/fstab file but if you are working on a large organisation and have so many mount points linked to your /etc/fstab file then in that case your overall system's performance will be get effected.
But Autofs mounts the file systems on user's demand. Bydefault the mount point's configured in Autofs is in unmounted state till the user access the mount point, once user try to access the mount point it will mount automatically and if user dont use the mount point for some time then it will automatically go to unmount state.
For example if we have Two NFS (Network File System) exported share drives and configured in Autofs to automatically mount in directory named /myautoshares for users. In that case till the user didnt access to the mountpoint it will be on unmounted state and you unable to see any mounted filesystem in /myautoshares directory, once user access the mount point it will automatically get mounted and will be in mount state till user uses that mountpoint. once user stop using that mount point it will unmount automatically. Here we are using Autofs to mount the NFS exported shares automatically.
Note : We can set time for after what time the filesystem unmount automatically once user stop using the mountpoint.
Follow the below Steps to configure Autofs
Step : 1 Requires Packages
Before we start the configuration of Autofs we have to install required packages. The main package we have to install is autofs.xxx.xxx.rpm. you can check if the packages is already installed or not by using below command.
Install the autofs packages by using yum command as shown below.
As we can see the autofs package installed successfully, we can confirm the autofs packages installation status by using below command.
Step : 2 Configure /etc/auto.master
Here we are going to use NFS exported shares with Autofs to automatically mount it. To check the NFS exports just run the below command.
As we can see above we have two NFS exports i.e. /package and /database. Now create a directory for Autofs to mount the filesystems.
The main configuration files of Autofs is /etc/auto.master where we can link the file in which we are going to mention all NFS mount points. The syntax to enter in /etc/auto.master file is shown below :
Autofs Ubuntu Windows 10
Note : It is not mandatory to mention timeout syntax in /etc/auto.master configuration file but It is recomended to do so.
Configuration part is Highlighted in Blue Color.
Where :
- /myautoshares – This is the directory where Autofs will mount the filesystems
- /etc/auto.sharedfs – In this file we have to mention the file systems which will automatically mounted by Autofs
- –timeout=35 – This is states that if user will don's use the mount point for 35 Seconds, then it will unmounted automatically.
Also Read :
Step : 3 Create and Configure /etc/auto.sharedfs
Now we have to create /etc/auto.sharedfs file which we have mentioned in /etc/auto.master file to mention the file systems.
Just copy the /etc/auto.misc file as /etc/auto.sharedfs as shown below. /etc/auto.misc file is the sample file which is created automatically after autofs package installation.
Now just edit the /etc/auto.sharedfs file and mention the filesystems to be mount, the Syntax shown below :
Note : Configuration Part are Highlighted in Blue Color.
We are done with configuration part, now let's go ahead and start the autofs service using below command.
Now it's time for testing. So let's list our Autofs mount point i.e. /myautoshares using ls -l command.
As we can see above currently there is no active mounts are available because as i explained earlier till user don't access the mount it will be in unmount state.
Now let's go ahead and access our first NFS export i.e. /packages by using below command.
As we can see above we able to access the NFS mount successfully. Now let's again list our mount point i.e. /myautoshares and I am sure it will definitely show the NFS mount points shared by Autofs. Refer the Output below.
Now let's access our second NFS export i.e. /database.
Autofs Ubuntu Windows 7
As we can see on the output below we able to access our both NFS Exported shares.
Now if user don't use access this NFS shares for 35 Seconds it will be automatically unmounted.
Autofs Ubuntu
So this is how we can configure Autofs (Automount) in Linux, If you found this article useful then Please Like Us, Subscribe Us or If you have something to say then feel free to comment on the comment box below.