Friday, 12 August 2011

HOWTO: Direct mapping with autofs

I wrote an article on autofs for creating indirect mounts a while back but now I need to mount a directory in the / (root) directory of a machine.

To do this I will use autofs in "direct mapping" mode.

First, if you don't have the automounter service installed, install it now.

sudo apt-get install autofs

Next we need to edit the auto.master file and add a line to tell it which file contains our direct mapping definitions;

sudo vi /etc/auto.master

Add this line;

/- /etc/auto.direct


Now we need to create the auto.direct file;

sudo vi /etc/auto.direct

To mount "my_nfs_server" to "/nas" add this line;

/nas -rw my_nfs_server:/storage

Note: The directory "/nas" should not be created by you, it will be created automatically by autofs


Restart the automounter service;

sudo service autofs restart

Check to see if it has worked;

brettg@zen:$ ls /nas

files movies music pictures
brettg@zen:$ df -h
my_nfs_server:/storage 1.4T 126G 1.2T 10% /nas

No comments: