Loop mount not automatically cleaned 

Newsgroups: gmane.linux.distributions.grml.user
Subject: Re: Loop mount not automatically cleaned
Date: Wed, 7 Feb 2007 03:05:08 +0000 (UTC)
>> I noticed that loop mounts are not automatically cleaned in my system.
>> Is there any way that I can fix it?
>>
>> Each time after I loop mount, the loop device number increased. When I do
>> ps, I found that there are many loop process in execution:
> [...]
>
> Which mount version are you using? 'dpkg -S =mount ; mount --version'
> I'm using mount of package loop-aes-utils and did not notice the
> mentioned behaviour.

Strange to me too. Here is the required info:

$ mount --version
mount: mount-2.12r
$ apt-cache policy mount
mount:
  Installed: 2.12r-16
  Candidate: 2.12r-16
$ apt-cache policy loop-aes-utils
loop-aes-utils:
  Installed: 2.12r-15
  Candidate: 2.12r-15
$ sudo mount -o loop grml_small_0.3.iso /mnt/os2/
$ mount | grep os2
/dev/loop2 on /mnt/os2 type iso9660 (ro)
$ sudo umount /mnt/os2/
$ ps -e | grep loop
32721 ?        00:00:00 loop0
 3332 ?        00:00:00 loop1
 2776 ?        00:00:00 loop2

Loop mount not automatically cleaned 

> $ ps -e | grep loop
> 32721 ?        00:00:00 loop0
>  3332 ?        00:00:00 loop1
>  2776 ?        00:00:00 loop2

Run 'losetup -d /dev/loop2' to fix the issue manually. To fix the issue for the future remove the symlink /etc/mtab pointing to /proc/mounts:

rm /etc/mtab
cp /proc/mounts /etc/mtab

from now on your system should remove the loop device automatically.

mika

Loop mount not automatically cleaned 

How do you mount it (with "-o loop" or with losetup)? How do you unmount it (by giving the mountpoint, the image file or the loop device)? Is your /etc/mtab a file or is it a symbolic link to /proc/mounts?

The behaviour I know is that the loop device will *not* be freed if

  1. /etc/mtab is a link to /proc/mounts *or*
  2. you gave the loop device explicitly as umount argument *or*
  3. you mounted it with losetup explicitly *or*
  4. you used -n when mounting (so the mountpoint does not end up in mtab)

But different mount versions do it differently (busybox mount even has its own parameter for it, because embedded systems usually use the /mtab symlink).

You can always free your loop devices with losetup.

Michael Schierl