mount: could not find any free loop device

Linux howto's, compile information, information on whatever we learned on working with linux, MACOs and - of course - Products of the big evil....
Post Reply
User avatar
^rooker
Site Admin
Posts: 1481
Joined: Fri Aug 29, 2003 8:39 pm

mount: could not find any free loop device

Post by ^rooker »

[PROBLEM]
I've got a multi-ISO tftpboot setup running. Awesome!
Today, I've updated the xubuntu ISO images, but forgot to unmount them before deleting the old versions. :oops:

So, I've done a "lazy umount "(umount -l) which worked fine.

But, when I tried to mount the new ISOs, I now got the error:
mount: could not find any free loop device
I've tried unmounting all ISOs, then removing the "loop" kernel module:

Code: Select all

$ rmmod loop
That returned:
Error: Module loop is in use
The only hack I've found to see which loop devices might still be in use is to check their date/time. For example:
brw-rw---T 1 root disk 7, 0 Feb 25 13:00 /dev/loop0
brw-rw---T 1 root disk 7, 1 Aug 19 2014 /dev/loop1
brw-rw---T 1 root disk 7, 2 Aug 19 2014 /dev/loop2
brw-rw---T 1 root disk 7, 3 Feb 25 13:02 /dev/loop3
brw-rw---T 1 root disk 7, 4 Aug 19 2014 /dev/loop4
brw-rw---T 1 root disk 7, 5 Feb 25 13:02 /dev/loop5
brw-rw---T 1 root disk 7, 6 Feb 25 13:02 /dev/loop6
brw-rw---T 1 root disk 7, 7 Feb 25 13:02 /dev/loop7
You can see that loop{1,2,4} date back to 2014. Those are still in use and not released.

"lsof" confirms that:

Code: Select all

$ sudo lsof | grep loop
it returns:

Code: Select all

loop1      4263             root  cwd       DIR      179,2     4096          2 /
loop1      4263             root  rtd       DIR      179,2     4096          2 /
loop1      4263             root  txt   unknown                                /proc/4263/exe
loop2      4274             root  cwd       DIR      179,2     4096          2 /
loop2      4274             root  rtd       DIR      179,2     4096          2 /
loop2      4274             root  txt   unknown                                /proc/4274/exe
loop4      4287             root  cwd       DIR      179,2     4096          2 /
loop4      4287             root  rtd       DIR      179,2     4096          2 /
loop4      4287             root  txt   unknown                                /proc/4287/exe
The process status seems to be "sleeping":

Code: Select all

$ sudo cat /proc/4263/status
Name: loop1
State: S (sleeping)
Tgid: 4263
Pid: 4263
PPid: 2
TracerPid: 0
Uid: 0 0 0 0
Gid: 0 0 0 0
FDSize: 32
Groups:
Threads: 1
SigQ: 1/3372
SigPnd: 0000000000000000
ShdPnd: 0000000000000000
SigBlk: 0000000000000000
SigIgn: ffffffffffffffff
SigCgt: 0000000000000000
CapInh: 0000000000000000
CapPrm: 0000001fffffffff
CapEff: 0000001fffffffff
CapBnd: 0000001fffffffff
Seccomp: 0
Cpus_allowed: 1
Cpus_allowed_list: 0
voluntary_ctxt_switches: 25598
nonvoluntary_ctxt_switches: 94

So now, what?


[SOLUTION]
I could create more "/dev/loopX" devices manually, but I think it'd be better to find a way to actually release the unused ones - without requiring a reboot of the server.

To be continued...


Links:
Jumping out of an airplane is not a basic instinct. Neither is breathing underwater. But put the two together and you're traveling through space!
Post Reply