Skip to content

Using autofs to mount ISO images

Henryk Paluch edited this page Aug 28, 2017 · 3 revisions

There are many ways to mount ISOs with loopback device. However good IT professional is lazy (i.e. - doing least amount of work to get acceptable results). So it is good idea to use autofs

Setup for Ubuntu 16.04 LTS

Everything bellow is done as root superuser

Install autofs:

apt-get install autofs

Create master include file:

mkdir /etc/auto.master.d
echo '/isos /etc/auto.isos' > /etc/auto.master.d/isos.autofs

Create autofs mount directory:

mkdir /isos

Create /etc/auto.isos text file with contents like (obviously you need to have specified ISO files!):

centos7-minimal -fstype=iso9660,loop    :/opt/install/OS/CentOS7/CentOS-7.0-1406-x86_64-Minimal.iso
centos6_dvd1    -fstype=iso9660,loop    :/opt/install/OS/CentOS6.6/CentOS-6.6-x86_64-bin-DVD1.iso
centos6_dvd2    -fstype=iso9660,loop    :/opt/install/OS/CentOS6.6/CentOS-6.6-x86_64-bin-DVD2.iso

Edit /etc/autofs.conf and enable browse mode using:

browse_mode = yes

Finally (re)start autofs:

systemctl restart autofs

Now you should see somehting like that:

ls -l /isos/
total 0
dr-xr-xr-x 2 root root 0 Jul  6 08:59 centos6_dvd1
dr-xr-xr-x 2 root root 0 Jul  6 08:59 centos6_dvd2
dr-xr-xr-x 2 root root 0 Jul  6 08:59 centos7-minimal

ls -l /isos/centos6_dvd1
total 712
-r--r--r-- 2 root root     14 Oct 24  2014 CentOS_BuildTag
dr-xr-xr-x 3 root root   2048 Oct 24  2014 EFI
-r--r--r-- 2 root root    212 Nov 27  2013 EULA
-r--r--r-- 2 root root  18009 Nov 27  2013 GPL
...

That's all!

Clone this wiki locally