IgnorantGuru's Blog

Linux software, news, and tips

HOW TO: Allow Mounting Of ISO Files By A Regular User

The following HOW-TO describes a method to allow mounting of ISO files by a regular (non-root) user, something normally lacking in Linux. This method, including setup, has also been automated in the new mountiso script. Also note that bic and Xtract have been updated to make use of mountiso if installed.

Setting Up The System

Edit your /etc/fstab file and add these lines:

/tmp/mountiso-image.iso /mnt/iso auto ro,loop=/dev/loop7,user,noexec,noauto 0 0
/dev/loop7 /mnt/iso auto user,noexec,noauto 0 0

2) Issue these commands to ensure you have seven loop devices and a mount point:

sudo mknod -m660 /dev/loop0 b 7 0
sudo mknod -m660 /dev/loop1 b 7 1
sudo mknod -m660 /dev/loop2 b 7 2
sudo mknod -m660 /dev/loop3 b 7 3
sudo mknod -m660 /dev/loop4 b 7 4
sudo mknod -m660 /dev/loop5 b 7 5
sudo mknod -m660 /dev/loop6 b 7 6
sudo mknod -m660 /dev/loop7 b 7 7
sudo chown root:disk /dev/loop*
sudo mkdir /mnt/iso

Note that you can use any loop device and any mount point you prefer. In this example /dev/loop7 and /mnt/iso are used. A higher loop device is used so that it won’t be in use by the system for other purposes.

Mounting And Unmounting

Once the above changes are saved, the file “/tmp/mountiso-image.iso” can be mounted and unmounted by a normal user. This file can also be a link to any ISO file you choose.

For example, to mount /home/user/example.iso (all commands issued as a normal user):

# First create link:
ln -s /home/user/example.iso /tmp/mountiso-image.iso

# Then mount it:
mount /tmp/mountiso-image.iso

# Then you can delete the link immediately:
rm /tmp/mountiso-image.iso

# You can now browse the contents of the ISO:
ls /mnt/iso

# To unmount:
umount /mnt/iso

Note that when unmounting you may receive the error message:
loop: can’t delete device /dev/loop7: No such device or address

This error may be ignored – the unmount will be successful and will return a zero error code.

January 22, 2011 - Posted by | Scripts, Tips


  1. Excellent and detailed explanation. Thanks.
    However, I spent far too much time to find out why this did not work for me: I could mount ISO files, but I could not dismount them as a normal user (“only root can umount …”). Apparently, on my version of Linux, the option to use is “users”, with an “s” rather than “user”, even though the man page (dated 2010) still indicates the option “user”.
    I run Linux version 3.4.34-server-1.mga2 (iurt@ecosse.mageia.org) (gcc version 4.6.3 (GCC) ) #1 SMP Thu Feb 28 21:30:46 UTC 2013.
    Actually “user” without “s” works too, for everything I tried, except for dismounting ISO files.

    Comment by babou | March 23, 2013

    • That’s odd. Also give the newer udevil a try.

      Comment by Anonymous | March 23, 2013

  2. I would love to understand the problem. Actually the option “users” is often not documented. According to “rine” in https://bbs.archlinux.org/viewtopic.php?id=68064 : “With “user” you can mount and unmount, but only the user who mounted a device can unmount it. The option “users” on the other hand lets everyone mount/unmount everything.”. Confirmed by jahoua in http://www.linuxforums.org/forum/networking/46134-user-option-fstab.html
    A situation similar to mine, in a different context, seems to be described in http://permalink.gmane.org/gmane.comp.file-systems.fuse.devel/12552 .

    I have been searching the net, and I am rather surprised not to find a single complete and systematic description of /etc/fstab describing its use for mount and for umount. The best I found is probably https://wiki.archlinux.org/index.php/Fstab, and it does not even talk about umount. But I am far from an expert on all this.

    Thanks for the reference to udevil. I will test it.

    Comment by babou | March 24, 2013

    • This blog post helped me understand much better the working of mount, umount, /etc/fstab and other reloated tables and command. I extended IgnorantGuru’s solution, so that it can be used with much more flexibility, to mount any number of files on any mount point.
      This solution is described at http://unix.stackexchange.com/questions/32008/mount-an-loop-file-without-root-permission/76002#76002 – it is still the last answer at the time of this writing.
      I am however concerned that these techniques might have an effect on the security of the system. Mounting limitations exist for a good purpose. I would welcome the point of view of Linux users experienced with security issues.

      Comment by babou | May 16, 2013

      • You’re right that there can be significant security issues here. udevil handles this carefully while still giving the user quite a bit of ability.

        Comment by IgnorantGuru | October 18, 2013

Sorry, the comment form is closed at this time.

%d bloggers like this: